本文整理汇总了C#中System.Complex.Aggregate方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.Aggregate方法的具体用法?C# Complex.Aggregate怎么用?C# Complex.Aggregate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Complex
的用法示例。
在下文中一共展示了Complex.Aggregate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateColumn
/// <summary>
/// Generate column from initial matrix to work array
/// </summary>
/// <param name="a">Initial matrix</param>
/// <param name="row">The first row</param>
/// <param name="column">Column index</param>
/// <returns>Generated vector</returns>
private static Complex[] GenerateColumn(Matrix<Complex> a, int row, int column)
{
var ru = a.RowCount - row;
var u = new Complex[ru];
for (var i = row; i < a.RowCount; i++)
{
u[i - row] = a.At(i, column);
a.At(i, column, 0.0);
}
var norm = u.Aggregate(Complex.Zero, (current, t) => current + (t.Magnitude * t.Magnitude));
norm = norm.SquareRoot();
if (row == a.RowCount - 1 || norm.Magnitude == 0)
{
a.At(row, column, -u[0]);
u[0] = Math.Sqrt(2.0);
return u;
}
if (u[0].Magnitude != 0.0)
{
norm = norm.Magnitude * (u[0] / u[0].Magnitude);
}
a.At(row, column, -norm);
for (var i = 0; i < ru; i++)
{
u[i] /= norm;
}
u[0] += 1.0;
var s = (1.0 / u[0]).SquareRoot();
for (var i = 0; i < ru; i++)
{
u[i] = u[i].Conjugate() * s;
}
return u;
}