本文整理汇总了C#中SparseMatrix.Subtract方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.Subtract方法的具体用法?C# SparseMatrix.Subtract怎么用?C# SparseMatrix.Subtract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix.Subtract方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSubtractSparseMatricesBothWays
public void CanSubtractSparseMatricesBothWays()
{
var m1 = new SparseMatrix(1, 3);
var m2 = new SparseMatrix(new Complex32[,] { { 0, 1, 1 } });
var diff1 = m1 - m2;
var diff2 = m2 - m1;
Assert.IsTrue(diff1.Equals(m2.Negate()));
Assert.IsTrue(diff1.Equals(diff2.Negate()));
var sparseResult = new SparseMatrix(1, 3);
sparseResult.Subtract(m2, sparseResult);
Assert.IsTrue(sparseResult.Equals(diff1));
sparseResult = new SparseMatrix(new Complex32[,] { { 0, 1, 1 } });
sparseResult.Subtract(m1, sparseResult);
Assert.IsTrue(sparseResult.Equals(diff2));
sparseResult = new SparseMatrix(new Complex32[,] { { 0, 1, 1 } });
m1.Subtract(sparseResult, sparseResult);
Assert.IsTrue(sparseResult.Equals(diff1));
sparseResult = new SparseMatrix(new Complex32[,] { { 0, 1, 1 } });
sparseResult.Subtract(sparseResult, sparseResult);
Assert.IsTrue(sparseResult.Equals(0 * diff1));
var denseResult = new DenseMatrix(1, 3);
denseResult.Subtract(m2, denseResult);
Assert.IsTrue(denseResult.Equals(diff1));
denseResult = new DenseMatrix(new Complex32[,] { { 0, 1, 1 } });
denseResult.Subtract(m1, denseResult);
Assert.IsTrue(denseResult.Equals(diff2));
var m3 = new DenseMatrix(new Complex32[,] { { 0, 1, 1 } });
var diff3 = m1 - m3;
var diff4 = m3 - m1;
Assert.IsTrue(diff3.Equals(m3.Negate()));
Assert.IsTrue(diff3.Equals(diff4.Negate()));
}
示例2: button10_Click
private void button10_Click(object sender, EventArgs e)
{
if (Ainv != null && lAinv != null)
{
Matrix Aigiv = new SparseMatrix(Ainv.m);
Aigiv.Subtract(lAinv);
double t1 = Aigiv.L1Norm();
if (t1 > eps)
show(t1.ToString() + " > " + eps + " -> Incorect !");
else
show(t1.ToString() + " < " + eps + " -> Corect !");
show("Inverse Norm Tested !");
}
else
MessageBox.Show("Calculate both inverses 1st !");
}