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