From 38a8b1f01b610a8d25effcf35088c1bbea73cd51 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 26 Nov 2012 20:55:13 +0200 Subject: [PATCH] [SymmetricMatrix] Disable SetRow/Column() for symmetric matrices Signed-off-by: Alexander Karatarakis --- .../LinearAlgebra/Complex/SymmetricMatrix.cs | 80 +------------------ .../Complex32/SymmetricMatrix.cs | 80 +------------------ .../LinearAlgebra/Double/SymmetricMatrix.cs | 80 +------------------ .../LinearAlgebra/Single/SymmetricMatrix.cs | 80 +------------------ 4 files changed, 16 insertions(+), 304 deletions(-) diff --git a/src/Numerics/LinearAlgebra/Complex/SymmetricMatrix.cs b/src/Numerics/LinearAlgebra/Complex/SymmetricMatrix.cs index ba6d712f..9b996511 100644 --- a/src/Numerics/LinearAlgebra/Complex/SymmetricMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex/SymmetricMatrix.cs @@ -574,25 +574,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, Complex[] column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Length != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -607,25 +589,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, Vector column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Count != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -654,25 +618,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, Vector row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Count != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -687,25 +633,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, Complex[] row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Length != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } } } diff --git a/src/Numerics/LinearAlgebra/Complex32/SymmetricMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/SymmetricMatrix.cs index 099df458..6d84785b 100644 --- a/src/Numerics/LinearAlgebra/Complex32/SymmetricMatrix.cs +++ b/src/Numerics/LinearAlgebra/Complex32/SymmetricMatrix.cs @@ -574,25 +574,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, Complex32[] column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Length != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -607,25 +589,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, Vector column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Count != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -654,25 +618,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, Vector row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Count != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -687,25 +633,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32 /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, Complex32[] row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Length != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } } } diff --git a/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs b/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs index eabc0072..a00a0206 100644 --- a/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs +++ b/src/Numerics/LinearAlgebra/Double/SymmetricMatrix.cs @@ -588,25 +588,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, double[] column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Length != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -621,25 +603,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, Vector column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Count != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -668,25 +632,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, Vector row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Count != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -701,25 +647,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, double[] row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Length != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } } } diff --git a/src/Numerics/LinearAlgebra/Single/SymmetricMatrix.cs b/src/Numerics/LinearAlgebra/Single/SymmetricMatrix.cs index 8cb1bc70..1ec1d112 100644 --- a/src/Numerics/LinearAlgebra/Single/SymmetricMatrix.cs +++ b/src/Numerics/LinearAlgebra/Single/SymmetricMatrix.cs @@ -588,25 +588,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, float[] column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Length != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -621,25 +603,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// equal the number of rows of this Matrix. public override void SetColumn(int columnIndex, Vector column) { - if (columnIndex < 0 || columnIndex >= ColumnCount) - { - throw new ArgumentOutOfRangeException("columnIndex"); - } - - if (column == null) - { - throw new ArgumentNullException("column"); - } - - if (column.Count != RowCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "column"); - } - - for (var i = 0; i < columnIndex; i++) - { - At(i, columnIndex, column[i]); - } + throw new InvalidOperationException("Setting a column is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -668,25 +632,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, Vector row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Count != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } /// @@ -701,25 +647,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single /// equal the number of columns of this Matrix. public override void SetRow(int rowIndex, float[] row) { - if (rowIndex < 0 || rowIndex >= RowCount) - { - throw new ArgumentOutOfRangeException("rowIndex"); - } - - if (row == null) - { - throw new ArgumentNullException("row"); - } - - if (row.Length != ColumnCount) - { - throw new ArgumentException(Resources.ArgumentMatrixSameRowDimension, "row"); - } - - for (var i = rowIndex; i < ColumnCount; i++) - { - At(rowIndex, i, row[i]); - } + throw new InvalidOperationException("Setting a row is not supported on a symmetric matrix. It will violate symmetry"); } } }