MathNet.Numerics.LinearAlgebra.Single.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<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.AddArrays(_values, denseOther.Data, denseResult.Data);
                return;
            }

            // dense + diagonal = any
            var diagonalOther = other.Storage as DiagonalMatrixStorage<float>;
            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 ( float scalar, Matrix result ) : void