本文整理汇总了C#中IMatrix.CopyToJaggedArray方法的典型用法代码示例。如果您正苦于以下问题:C# IMatrix.CopyToJaggedArray方法的具体用法?C# IMatrix.CopyToJaggedArray怎么用?C# IMatrix.CopyToJaggedArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatrix
的用法示例。
在下文中一共展示了IMatrix.CopyToJaggedArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SingularValueDecomposition
/// <summary>
/// Initializes a new instance of the SingularValueDecomposition class.
/// </summary>
/// <remarks>Provides access to U, S and V.</remarks>
/// <param name="arg">Rectangular matrix</param>
public SingularValueDecomposition(IMatrix<double> arg)
{
_transpose = (arg.RowCount < arg.ColumnCount);
// Derived from LINPACK code.
// Initialize.
double[][] a;
if(_transpose)
{
// copy of internal data, independent of Arg
a = Matrix.Transpose(arg).GetArray();
_m = arg.ColumnCount;
_n = arg.RowCount;
}
else
{
a = arg.CopyToJaggedArray();
_m = arg.RowCount;
_n = arg.ColumnCount;
}
int nu = Math.Min(_m, _n);
double[] s = new double[Math.Min(_m + 1, _n)];
double[][] u = Matrix.CreateMatrixData(_m, nu);
double[][] v = Matrix.CreateMatrixData(_n, _n);
double[] e = new double[_n];
double[] work = new double[_m];
/*
Reduce A to bidiagonal form, storing the diagonal elements
in s and the super-diagonal elements in e.
*/
int nct = Math.Min(_m - 1, _n);
int nrt = Math.Max(0, Math.Min(_n - 2, _m));
for(int k = 0; k < Math.Max(nct, nrt); k++)
{
if(k < nct)
{
// Compute the transformation for the k-th column and
// place the k-th diagonal in s[k].
// Compute 2-norm of k-th column without under/overflow.
s[k] = 0;
for(int i = k; i < _m; i++)
{
s[k] = Fn.Hypot(s[k], a[i][k]);
}
if(s[k] != 0.0)
{
if(a[k][k] < 0.0)
{
s[k] = -s[k];
}
for(int i = k; i < _m; i++)
{
a[i][k] /= s[k];
}
a[k][k] += 1.0;
}
s[k] = -s[k];
}
for(int j = k + 1; j < _n; j++)
{
if((k < nct) & (s[k] != 0.0))
{
/* Apply the transformation */
double t = 0;
for(int i = k; i < _m; i++)
{
t += a[i][k] * a[i][j];
}
t = (-t) / a[k][k];
for(int i = k; i < _m; i++)
{
a[i][j] += t * a[i][k];
}
}
/*
Place the k-th row of A into e for the
subsequent calculation of the row transformation.
*/
e[j] = a[k][j];
}
//.........这里部分代码省略.........