MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.DoAdd C# (CSharp) Method

DoAdd() protected method

Adds another matrix to this matrix.
If the other matrix is . If the two matrices don't have the same dimensions.
protected DoAdd ( Matrix other, Matrix result ) : void
other Matrix The matrix to add to this matrix.
result Matrix The matrix to store the result of add
return void
        protected override void DoAdd(Matrix<double> other, Matrix<double> result)
        {
            // dense + dense = dense
            var denseOther = other.Storage as DenseColumnMajorMatrixStorage<double>;
            var denseResult = result.Storage as DenseColumnMajorMatrixStorage<double>;
            if (denseOther != null && denseResult != null)
            {
                Control.LinearAlgebraProvider.AddArrays(_values, denseOther.Data, denseResult.Data);
                return;
            }

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

            base.DoAdd(other, result);
        }

Same methods

DenseMatrix::DoAdd ( double scalar, Matrix result ) : void