本文整理汇总了C#中DotNetMatrix.GeneralMatrix.Norm1方法的典型用法代码示例。如果您正苦于以下问题:C# GeneralMatrix.Norm1方法的具体用法?C# GeneralMatrix.Norm1怎么用?C# GeneralMatrix.Norm1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetMatrix.GeneralMatrix
的用法示例。
在下文中一共展示了GeneralMatrix.Norm1方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: check
/// <summary>Check norm of difference of Matrices. *</summary>
private static void check(GeneralMatrix X, GeneralMatrix Y)
{
double eps = System.Math.Pow(2.0, - 52.0);
if (X.Norm1() == 0.0 & Y.Norm1() < 10 * eps)
return ;
if (Y.Norm1() == 0.0 & X.Norm1() < 10 * eps)
return ;
if (X.Subtract(Y).Norm1() > 1000 * eps * System.Math.Max(X.Norm1(), Y.Norm1()))
{
throw new System.SystemException("The norm of (X-Y) is too large: " + X.Subtract(Y).Norm1().ToString());
}
}
示例2: Main
//.........这里部分代码省略.........
errorCount = try_failure(errorCount, "SetMatrix(int[],int[],GeneralMatrix)... ", "Unexpected ArrayIndexOutOfBoundsException");
System.Console.Out.WriteLine(e1.Message);
}
/// <summary>Array-like methods:
/// Subtract
/// SubtractEquals
/// Add
/// AddEquals
/// ArrayLeftDivide
/// ArrayLeftDivideEquals
/// ArrayRightDivide
/// ArrayRightDivideEquals
/// arrayTimes
/// ArrayMultiplyEquals
/// uminus
///
/// </summary>
print("\nTesting array-like methods...\n");
S = new GeneralMatrix(columnwise, nonconformld);
R = GeneralMatrix.Random(A.RowDimension, A.ColumnDimension);
A = R;
try
{
S = A.Subtract(S);
errorCount = try_failure(errorCount, "Subtract conformance check... ", "nonconformance not raised");
}
catch (System.ArgumentException e)
{
try_success("Subtract conformance check... ", "");
System.Console.Out.WriteLine(e.Message);
}
if (A.Subtract(R).Norm1() != 0.0)
{
errorCount = try_failure(errorCount, "Subtract... ", "(difference of identical Matrices is nonzero,\nSubsequent use of Subtract should be suspect)");
}
else
{
try_success("Subtract... ", "");
}
A = R.Copy();
A.SubtractEquals(R);
Z = new GeneralMatrix(A.RowDimension, A.ColumnDimension);
try
{
A.SubtractEquals(S);
errorCount = try_failure(errorCount, "SubtractEquals conformance check... ", "nonconformance not raised");
}
catch (System.ArgumentException e)
{
try_success("SubtractEquals conformance check... ", "");
System.Console.Out.WriteLine(e.Message);
}
if (A.Subtract(Z).Norm1() != 0.0)
{
errorCount = try_failure(errorCount, "SubtractEquals... ", "(difference of identical Matrices is nonzero,\nSubsequent use of Subtract should be suspect)");
}
else
{
try_success("SubtractEquals... ", "");
}
A = R.Copy();
B = GeneralMatrix.Random(A.RowDimension, A.ColumnDimension);
C = A.Subtract(B);
示例3: TestNorm1
public void TestNorm1()
{
GeneralMatrix _gm = new GeneralMatrix(2,2);
_gm.SetElement(0,0,1);
_gm.SetElement(0,1,2);
_gm.SetElement(1,0,3);
_gm.SetElement(1,1,4);
Assert.AreEqual(6,_gm.Norm1());
}
示例4: Identity
public void Identity()
{
double[][] ivals = {new double[]{1.0, 0.0, 0.0, 0.0}, new double[]{0.0, 1.0, 0.0, 0.0}, new double[]{0.0, 0.0, 1.0, 0.0}};
GeneralMatrix I = new GeneralMatrix(ivals);
GeneralMatrix K = GeneralMatrix.Identity(3,4);
Assert.IsTrue(I.Norm1()==K.Norm1()&&I.Norm1()==1);
}
示例5: Check
/// <summary>Check norm of difference of Matrices.
/// </summary>
public static bool Check(GeneralMatrix X, GeneralMatrix Y)
{
bool result=false;
double eps = System.Math.Pow(2.0, - 52.0);
if (X.Norm1() == 0.0 & Y.Norm1() < 10 * eps)
result = true ;
else if (Y.Norm1() == 0.0 & X.Norm1() < 10 * eps)
result = true ;
else if (X.Subtract(Y).Norm1() > 1000 * eps * System.Math.Max(X.Norm1(), Y.Norm1()))
{
throw new System.SystemException("The norm of (X-Y) is too large: " + X.Subtract(Y).Norm1().ToString());
}
else result = true;
return result;
}
示例6: check
//General
/// <summary>Check norm of difference of Matrices. *</summary>
private static bool check(GeneralMatrix x, GeneralMatrix y)
{
double eps = Math.Pow(2.0, -52.0);
if (x.Norm1() == 0.0 & y.Norm1() < 10 * eps)
return true;
if (y.Norm1() == 0.0 & x.Norm1() < 10 * eps)
return true;
return (x.Subtract(y).Norm1() > 1000*eps*Math.Max(x.Norm1(), y.Norm1()));
}
示例7: SubstractEquals
public void SubstractEquals()
{
A = R.Copy();
Assert.IsFalse(A.Norm1()==0.0);
A.SubtractEquals(R);
Assert.IsTrue(A.Norm1() == 0.0);
}