本文整理汇总了C#中Altaxo.Calc.LinearAlgebra.ComplexFloatVector.GetNorm方法的典型用法代码示例。如果您正苦于以下问题:C# ComplexFloatVector.GetNorm方法的具体用法?C# ComplexFloatVector.GetNorm怎么用?C# ComplexFloatVector.GetNorm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Altaxo.Calc.LinearAlgebra.ComplexFloatVector
的用法示例。
在下文中一共展示了ComplexFloatVector.GetNorm方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateRow
public static ComplexFloatVector GenerateRow(IComplexFloatMatrix A, int r, int c1, int c2)
{
int cu = c2 - c1 + 1;
ComplexFloatVector u = new ComplexFloatVector(cu);
for (int j = c1; j <= c2; j++)
{
u[j - c1] = A[r, j];
A[r, j] = ComplexFloat.Zero;
}
float norm = u.GetNorm();
if (c1 == c2 || norm == 0)
{
A[r, c1] = new ComplexFloat(-u[0].Real, -u[0].Imag);
u[0] = (float)System.Math.Sqrt(2);
return u;
}
ComplexFloat scale = new ComplexFloat(1 / norm);
ComplexFloat t = ComplexFloat.Zero;
ComplexFloat t1 = ComplexFloat.Zero;
if (u[0].Real != 0 || u[0].Imag != 0)
{
t = u[0];
t1 = ComplexMath.Conjugate(u[0]);
t = ComplexMath.Absolute(t);
t = t1 / t;
scale = scale * t;
}
A[r, c1] = -ComplexFloat.One / scale;
for (int j = 0; j < cu; j++)
{
u[j] *= scale;
}
u[0] = new ComplexFloat(u[0].Real + 1);
float s = (float)System.Math.Sqrt(1 / u[0].Real);
for (int j = 0; j < cu; j++)
{
u[j] = new ComplexFloat(s * u[j].Real, -s * u[j].Imag);
}
return u;
}
示例2: GetNorm
public void GetNorm()
{
ComplexFloatVector a = new ComplexFloatVector(new float[4] { 0, 1, 2, 3 });
ComplexFloatVector b = new ComplexFloatVector(new float[4] { 4, 5, 6, 7 });
Assert.AreEqual(a.GetNorm(), System.Math.Sqrt(14), TOLERENCE);
Assert.AreEqual(a.GetNorm(), a.GetNorm(2));
Assert.AreEqual(a.GetNorm(0), 3);
Assert.AreEqual(b.GetNorm(), 3 * System.Math.Sqrt(14), TOLERENCE);
Assert.AreEqual(b.GetNorm(), b.GetNorm(2));
Assert.AreEqual(b.GetNorm(0), 7);
}
示例3: GenerateColumn
public static ComplexFloatVector GenerateColumn(IComplexFloatMatrix A, int r1, int r2, int c)
{
int ru = r2 - r1 + 1;
ComplexFloatVector u = new ComplexFloatVector(r2 - r1 + 1);
for (int i = r1; i <= r2; i++)
{
u[i - r1] = A[i, c];
A[i, c] = ComplexFloat.Zero;
}
float norm = u.GetNorm();
if (r1 == r2 || norm == 0)
{
A[r1, c] = new ComplexFloat(-u[0]);
u[0] = (float)System.Math.Sqrt(2);
return u;
}
ComplexFloat scale = new ComplexFloat(1 / norm, 0);
ComplexFloat t = ComplexFloat.Zero;
ComplexFloat t1 = ComplexFloat.Zero;
if (u[0].Real != 0 || u[0].Imag != 0)
{
t = u[0];
t1 = ComplexMath.Conjugate(u[0]);
t = ComplexMath.Absolute(t);
t = t1 / t;
scale = scale * t;
}
A[r1, c] = -ComplexFloat.One / scale;
for (int i = 0; i < ru; i++)
{
u[i] = u[i] * scale;
}
u[0] = new ComplexFloat(u[0].Real + 1, 0);
float s = (float)System.Math.Sqrt(1 / u[0].Real);
for (int i = 0; i < ru; i++)
{
u[i] = new ComplexFloat(s * u[i].Real, s * u[i].Imag);
}
return u;
}