diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.cs index d95d2f76..8b16cf46 100644 --- a/src/Numerics/LinearAlgebra/Generic/Matrix.cs +++ b/src/Numerics/LinearAlgebra/Generic/Matrix.cs @@ -212,6 +212,60 @@ namespace MathNet.Numerics.LinearAlgebra.Generic Storage.Clear(); } + /// + /// Sets all values of a column to zero. + /// + public void ClearColumn(int columnIndex) + { + if (columnIndex < 0 || columnIndex >= ColumnCount) + { + throw new ArgumentOutOfRangeException("columnIndex"); + } + + Storage.Clear(0,RowCount,columnIndex,1); + } + + /// + /// Sets all values of a row to zero. + /// + public void ClearRow(int rowIndex) + { + if (rowIndex < 0 || rowIndex >= RowCount) + { + throw new ArgumentOutOfRangeException("rowIndex"); + } + + Storage.Clear(rowIndex, 1, 0, ColumnCount); + } + + /// + /// Sets all values of a submatrix to zero. + /// + public void ClearSubMatrix(int rowIndex, int rowCount, int columnIndex, int columnCount) + { + if (rowCount < 1) + { + throw new ArgumentOutOfRangeException("rowCount", Resources.ArgumentMustBePositive); + } + + if (columnCount < 1) + { + throw new ArgumentOutOfRangeException("columnCount", Resources.ArgumentMustBePositive); + } + + if (rowIndex + rowCount > RowCount || rowIndex < 0) + { + throw new ArgumentOutOfRangeException("rowIndex"); + } + + if (columnIndex + columnCount > ColumnCount || columnIndex < 0) + { + throw new ArgumentOutOfRangeException("columnIndex"); + } + + Storage.Clear(rowIndex, rowCount, columnIndex, columnCount); + } + /// /// Creates a clone of this instance. ///