MathNet.Numerics.LinearAlgebra.Single.DenseMatrix.DoSubtract C# (CSharp) Method

DoSubtract() protected method

Subtracts another matrix from this matrix.
protected DoSubtract ( Matrix other, Matrix result ) : void
other Matrix The matrix to subtract.
result Matrix The matrix to store the result of the subtraction.
return void
        protected override void DoSubtract(Matrix<float> other, Matrix<float> result)
        {
            // dense + dense = dense
            var denseOther = other.Storage as DenseColumnMajorMatrixStorage<float>;
            var denseResult = result.Storage as DenseColumnMajorMatrixStorage<float>;
            if (denseOther != null && denseResult != null)
            {
                Control.LinearAlgebraProvider.SubtractArrays(_values, denseOther.Data, denseResult.Data);
                return;
            }

            // dense + diagonal = matrix
            var diagonalOther = other.Storage as DiagonalMatrixStorage<float>;
            if (diagonalOther != null)
            {
                CopyTo(result);
                var diagonal = diagonalOther.Data;
                for (int i = 0; i < diagonal.Length; i++)
                {
                    result.At(i, i, result.At(i, i) - diagonal[i]);
                }
                return;
            }

            base.DoSubtract(other, result);
        }

Same methods

DenseMatrix::DoSubtract ( float scalar, Matrix result ) : void