本文整理汇总了C#中MathNet.Numerics.LinearAlgebra.Complex32.DenseMatrix.Subtract方法的典型用法代码示例。如果您正苦于以下问题:C# DenseMatrix.Subtract方法的具体用法?C# DenseMatrix.Subtract怎么用?C# DenseMatrix.Subtract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MathNet.Numerics.LinearAlgebra.Complex32.DenseMatrix
的用法示例。
在下文中一共展示了DenseMatrix.Subtract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSubtractSparseMatricesBothWays
public void CanSubtractSparseMatricesBothWays()
{
var m1 = new SparseMatrix(1, 3);
var m2 = SparseMatrix.OfArray(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 = SparseMatrix.OfArray(new Complex32[,] { { 0, 1, 1 } });
sparseResult.Subtract(m1, sparseResult);
Assert.IsTrue(sparseResult.Equals(diff2));
sparseResult = SparseMatrix.OfArray(new Complex32[,] { { 0, 1, 1 } });
m1.Subtract(sparseResult, sparseResult);
Assert.IsTrue(sparseResult.Equals(diff1));
sparseResult = SparseMatrix.OfArray(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 = DenseMatrix.OfArray(new Complex32[,] {{0, 1, 1}});
denseResult.Subtract(m1, denseResult);
Assert.IsTrue(denseResult.Equals(diff2));
var m3 = DenseMatrix.OfArray(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()));
}