本文整理汇总了C#中System.Complex.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.ToArray方法的具体用法?C# Complex.ToArray怎么用?C# Complex.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Complex
的用法示例。
在下文中一共展示了Complex.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CSVD
/// <summary>
/// Initializes a new instance of the CSVD class,
/// computing the Singular Value Decomposition of a general complex matrix,
/// with the possibility of computing only the singular values.
/// </summary>
/// <param name="matrix">A general complex matrix.</param>
/// <param name="singularValuesOnly">A value that indicating whether only the singular values will be computed.</param>
public CSVD(CMatrix matrix, bool singularValuesOnly)
{
_m = matrix.RowCount;
_n = matrix.ColumnCount;
var nm = Math.Min(matrix.RowCount, matrix.ColumnCount);
var s = new Complex[nm];
var u = new Complex[matrix.RowCount * matrix.RowCount];
var vt = new Complex[matrix.ColumnCount * matrix.ColumnCount];
new ManagedLinearAlgebraProvider().SingularValueDecomposition(!singularValuesOnly, matrix.To1DimArray(), matrix.RowCount, matrix.ColumnCount, s, u, vt);
_s = s.ToArray().Select(x => x.Re).ToArray();
_u = new CMatrix(matrix.RowCount, matrix.RowCount);
for (int i = 0; i < matrix.RowCount; i++)
{
for (int j = 0; j < matrix.RowCount; j++)
{
_u[i, j] = u[j * matrix.RowCount + i];
}
}
_vt = new CMatrix(matrix.ColumnCount, matrix.ColumnCount);
for (int i = 0; i < matrix.ColumnCount; i++)
{
for (int j = 0; j < matrix.ColumnCount; j++)
{
_vt[i, j] = vt[j * matrix.ColumnCount + i];
}
}
}