diff --git a/src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
index c3af5888..0253b556 100644
--- a/src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex/DenseMatrix.cs
@@ -264,66 +264,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
base.SetSubMatrix(rowIndex, rowCount, columnIndex, columnCount, subMatrix);
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override Complex this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override Complex At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, Complex value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Returns the transpose of this matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
index de481cf2..e31ff9ae 100644
--- a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
@@ -149,63 +149,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
}
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override Complex this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override Complex At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- /// When trying to set an off diagonal element.
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override void At(int row, int column, Complex value)
- {
- _storage.At(row, column, value);
- }
-
///
/// Creates a DiagonalMatrix for the given number of rows and columns.
///
@@ -235,14 +178,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return new SparseVector(size);
}
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Indicates whether the current object is equal to another object of the same type.
///
diff --git a/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
index feb5b6d3..f44ca9af 100644
--- a/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex/SparseMatrix.cs
@@ -613,66 +613,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
return ret;
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override Complex this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override Complex At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, Complex value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Copies the elements of this matrix to the given matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
index 2a3537a9..ba91ef2e 100644
--- a/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/DenseMatrix.cs
@@ -264,66 +264,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
base.SetSubMatrix(rowIndex, rowCount, columnIndex, columnCount, subMatrix);
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override Complex32 this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override Complex32 At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, Complex32 value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Returns the transpose of this matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
index 5067f368..38d859f1 100644
--- a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
@@ -149,63 +149,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
}
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override Complex32 this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override Complex32 At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- /// When trying to set an off diagonal element.
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override void At(int row, int column, Complex32 value)
- {
- _storage.At(row, column, value);
- }
-
///
/// Creates a DiagonalMatrix for the given number of rows and columns.
///
@@ -235,14 +178,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return new SparseVector(size);
}
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Indicates whether the current object is equal to another object of the same type.
///
diff --git a/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
index 4026f892..c7e5d95c 100644
--- a/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/SparseMatrix.cs
@@ -613,66 +613,6 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
return ret;
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override Complex32 this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override Complex32 At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, Complex32 value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Copies the elements of this matrix to the given matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
index 0d6f2d76..24732e24 100644
--- a/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Double/DenseMatrix.cs
@@ -264,66 +264,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
base.SetSubMatrix(rowIndex, rowCount, columnIndex, columnCount, subMatrix);
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override double this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override double At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, double value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Returns the transpose of this matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
index dbf75904..b6613928 100644
--- a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
@@ -148,63 +148,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
}
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override double this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override double At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- /// When trying to set an off diagonal element.
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override void At(int row, int column, double value)
- {
- _storage.At(row, column, value);
- }
-
///
/// Creates a DiagonalMatrix for the given number of rows and columns.
///
@@ -234,14 +177,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return new SparseVector(size);
}
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Indicates whether the current object is equal to another object of the same type.
///
diff --git a/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
index 28a249e6..e3971bff 100644
--- a/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Double/SparseMatrix.cs
@@ -612,66 +612,6 @@ namespace MathNet.Numerics.LinearAlgebra.Double
return ret;
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override double this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override double At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, double value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Copies the elements of this matrix to the given matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.cs
index 0d9d7695..55c19cd5 100644
--- a/src/Numerics/LinearAlgebra/Generic/Matrix.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Matrix.cs
@@ -24,8 +24,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-using MathNet.Numerics.LinearAlgebra.Storage;
-
namespace MathNet.Numerics.LinearAlgebra.Generic
{
using System;
@@ -35,6 +33,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
using Factorization;
using Numerics;
using Properties;
+ using Storage;
using Threading;
///
@@ -154,7 +153,7 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
}
///
- /// Gets or sets the value at the given row and column.
+ /// Gets or sets the value at the given row and column, with range checking.
///
///
/// The row of the element.
@@ -165,19 +164,10 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// The value to get or set.
/// This method is ranged checked. and
/// to get and set values without range checking.
- public virtual T this[int row, int column]
+ public T this[int row, int column]
{
- get
- {
- RangeCheck(row, column);
- return At(row, column);
- }
-
- set
- {
- RangeCheck(row, column);
- At(row, column, value);
- }
+ get { return Storage[row, column]; }
+ set { Storage[row, column] = value; }
}
///
@@ -192,10 +182,13 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
///
/// The requested element.
///
- public abstract T At(int row, int column);
+ public T At(int row, int column)
+ {
+ return Storage.At(row, column);
+ }
///
- /// Sets the value of the given element.
+ /// Sets the value of the given element without range checking.
///
///
/// The row of the element.
@@ -206,7 +199,18 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
///
/// The value to set the element to.
///
- public abstract void At(int row, int column, T value);
+ public void At(int row, int column, T value)
+ {
+ Storage.At(row, column, value);
+ }
+
+ ///
+ /// Sets all values to zero.
+ ///
+ public void Clear()
+ {
+ Storage.Clear();
+ }
///
/// Creates a clone of this instance.
@@ -1412,28 +1416,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
#endregion
- ///
- /// Checks the range of the requested row, column.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- private void RangeCheck(int row, int column)
- {
- if (row < 0 || row >= RowCount)
- {
- throw new ArgumentOutOfRangeException("row");
- }
-
- if (column < 0 || column >= ColumnCount)
- {
- throw new ArgumentOutOfRangeException("column");
- }
- }
-
#region System.Object overrides
///
@@ -1475,20 +1457,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
#endregion
- ///
- /// Sets all values to zero.
- ///
- public virtual void Clear()
- {
- for (var i = 0; i < RowCount; i++)
- {
- for (var j = 0; j < ColumnCount; j++)
- {
- At(i, j, default(T));
- }
- }
- }
-
///
/// Returns the transpose of this matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Single/DenseMatrix.cs b/src/Numerics/LinearAlgebra/Single/DenseMatrix.cs
index e6607d76..9ead7f02 100644
--- a/src/Numerics/LinearAlgebra/Single/DenseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/DenseMatrix.cs
@@ -264,66 +264,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
base.SetSubMatrix(rowIndex, rowCount, columnIndex, columnCount, subMatrix);
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override float this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override float At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, float value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Returns the transpose of this matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
index 94934d13..3789185e 100644
--- a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
@@ -148,63 +148,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
}
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override float this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override float At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- /// When trying to set an off diagonal element.
- /// Depending on the implementation, an
- /// may be thrown if one of the indices is outside the dimensions of the matrix.
- public override void At(int row, int column, float value)
- {
- _storage.At(row, column, value);
- }
-
///
/// Creates a DiagonalMatrix for the given number of rows and columns.
///
@@ -234,14 +177,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return new SparseVector(size);
}
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Indicates whether the current object is equal to another object of the same type.
///
diff --git a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
index d9b08890..65a5763d 100644
--- a/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/SparseMatrix.cs
@@ -612,66 +612,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single
return ret;
}
- ///
- /// Gets or sets the value at the given row and column, with range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- /// The value to get or set.
- /// This method is ranged checked. and
- /// to get and set values without range checking.
- public override float this[int row, int column]
- {
- get { return _storage[row, column]; }
- set { _storage[row, column] = value; }
- }
-
- ///
- /// Retrieves the requested element without range checking.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The requested element.
- ///
- public override float At(int row, int column)
- {
- return _storage.At(row, column);
- }
-
- ///
- /// Sets the value of the given element.
- ///
- ///
- /// The row of the element.
- ///
- ///
- /// The column of the element.
- ///
- ///
- /// The value to set the element to.
- ///
- public override void At(int row, int column, float value)
- {
- _storage.At(row, column, value);
- }
-
- ///
- /// Sets all values to zero.
- ///
- public override void Clear()
- {
- _storage.Clear();
- }
-
///
/// Copies the elements of this matrix to the given matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs
index f6d04d51..a0ee24bc 100644
--- a/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs
@@ -115,8 +115,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
throw new NotSupportedException();
}
- ArgumentValidation.CopySubMatrixTo(RowCount, ColumnCount,
- target.RowCount, target.ColumnCount,
+ ValidateSubMatrixRange(target,
sourceRowIndex, targetRowIndex, rowCount,
sourceColumnIndex, targetColumnIndex, columnCount);
diff --git a/src/Numerics/LinearAlgebra/Storage/ArgumentValidation.cs b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.Validation.cs
similarity index 65%
rename from src/Numerics/LinearAlgebra/Storage/ArgumentValidation.cs
rename to src/Numerics/LinearAlgebra/Storage/MatrixStorage.Validation.cs
index 58810168..b8eda87d 100644
--- a/src/Numerics/LinearAlgebra/Storage/ArgumentValidation.cs
+++ b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.Validation.cs
@@ -4,11 +4,22 @@ using MathNet.Numerics.Properties;
namespace MathNet.Numerics.LinearAlgebra.Storage
{
// ReSharper disable UnusedParameter.Global
- internal static class ArgumentValidation
+ public partial class MatrixStorage
{
- public static void CopySubMatrixTo(
- int sourceRowCount, int sourceColumnCount,
- int targetRowCount, int targetColumnCount,
+ protected void ValidateRange(int row, int column)
+ {
+ if (row < 0 || row >= RowCount)
+ {
+ throw new ArgumentOutOfRangeException("row");
+ }
+
+ if (column < 0 || column >= ColumnCount)
+ {
+ throw new ArgumentOutOfRangeException("column");
+ }
+ }
+
+ protected void ValidateSubMatrixRange(MatrixStorage target,
int sourceRowIndex, int targetRowIndex, int rowCount,
int sourceColumnIndex, int targetColumnIndex, int columnCount)
{
@@ -24,12 +35,12 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
// Verify Source
- if (sourceRowIndex >= sourceRowCount || sourceRowIndex < 0)
+ if (sourceRowIndex >= RowCount || sourceRowIndex < 0)
{
throw new ArgumentOutOfRangeException("sourceRowIndex");
}
- if (sourceColumnIndex >= sourceColumnCount || sourceColumnIndex < 0)
+ if (sourceColumnIndex >= ColumnCount || sourceColumnIndex < 0)
{
throw new ArgumentOutOfRangeException("sourceColumnIndex");
}
@@ -37,24 +48,24 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
var sourceRowMax = sourceRowIndex + rowCount;
var sourceColumnMax = sourceColumnIndex + columnCount;
- if (sourceRowMax > sourceRowCount)
+ if (sourceRowMax > RowCount)
{
throw new ArgumentOutOfRangeException("rowCount");
}
- if (sourceColumnMax > sourceColumnCount)
+ if (sourceColumnMax > ColumnCount)
{
throw new ArgumentOutOfRangeException("columnCount");
}
// Verify Target
- if (targetRowIndex >= targetRowCount || targetRowIndex < 0)
+ if (targetRowIndex >= target.RowCount || targetRowIndex < 0)
{
throw new ArgumentOutOfRangeException("targetRowIndex");
}
- if (targetColumnIndex >= targetColumnCount || targetColumnIndex < 0)
+ if (targetColumnIndex >= target.ColumnCount || targetColumnIndex < 0)
{
throw new ArgumentOutOfRangeException("targetColumnIndex");
}
@@ -62,12 +73,12 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
var targetRowMax = targetRowIndex + rowCount;
var targetColumnMax = targetColumnIndex + columnCount;
- if (targetRowMax > targetRowCount)
+ if (targetRowMax > target.RowCount)
{
throw new ArgumentOutOfRangeException("rowCount");
}
- if (targetColumnMax > targetColumnCount)
+ if (targetColumnMax > target.ColumnCount)
{
throw new ArgumentOutOfRangeException("columnCount");
}
diff --git a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
index 2d7ac6a7..614fbf8c 100644
--- a/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
@@ -3,7 +3,7 @@ using MathNet.Numerics.Properties;
namespace MathNet.Numerics.LinearAlgebra.Storage
{
- public abstract class MatrixStorage where T : struct, IEquatable, IFormattable
+ public abstract partial class MatrixStorage where T : struct, IEquatable, IFormattable
{
// [ruegg] public fields are OK here
@@ -42,31 +42,13 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{
get
{
- if (row < 0 || row >= RowCount)
- {
- throw new ArgumentOutOfRangeException("row");
- }
-
- if (column < 0 || column >= ColumnCount)
- {
- throw new ArgumentOutOfRangeException("column");
- }
-
+ ValidateRange(row, column);
return At(row, column);
}
set
{
- if (row < 0 || row >= RowCount)
- {
- throw new ArgumentOutOfRangeException("row");
- }
-
- if (column < 0 || column >= ColumnCount)
- {
- throw new ArgumentOutOfRangeException("column");
- }
-
+ ValidateRange(row, column);
At(row, column, value);
}
}
@@ -95,6 +77,15 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
/// WARNING: This method is not thread safe. Use "lock" with it and be sure to avoid deadlocks.
public abstract void At(int row, int column, T value);
- public abstract void Clear();
+ public virtual void Clear()
+ {
+ for (var i = 0; i < RowCount; i++)
+ {
+ for (var j = 0; j < ColumnCount; j++)
+ {
+ At(i, j, default(T));
+ }
+ }
+ }
}
}
diff --git a/src/Numerics/LinearAlgebra/Storage/SparseDiagonalMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/SparseDiagonalMatrixStorage.cs
index 4e60bceb..39c5f9cf 100644
--- a/src/Numerics/LinearAlgebra/Storage/SparseDiagonalMatrixStorage.cs
+++ b/src/Numerics/LinearAlgebra/Storage/SparseDiagonalMatrixStorage.cs
@@ -180,8 +180,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
throw new ArgumentNullException("target");
}
- ArgumentValidation.CopySubMatrixTo(RowCount, ColumnCount,
- target.RowCount, target.ColumnCount,
+ ValidateSubMatrixRange(target,
sourceRowIndex, targetRowIndex, rowCount,
sourceColumnIndex, targetColumnIndex, columnCount);
@@ -241,8 +240,7 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
throw new ArgumentNullException("target");
}
- ArgumentValidation.CopySubMatrixTo(RowCount, ColumnCount,
- target.RowCount, target.ColumnCount,
+ ValidateSubMatrixRange(target,
sourceRowIndex, targetRowIndex, rowCount,
sourceColumnIndex, targetColumnIndex, columnCount);
diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj
index 2e64b192..591677ef 100644
--- a/src/Numerics/Numerics.csproj
+++ b/src/Numerics/Numerics.csproj
@@ -122,7 +122,7 @@
-
+
diff --git a/src/Portable/Portable.csproj b/src/Portable/Portable.csproj
index c994bf26..0bc55fdd 100644
--- a/src/Portable/Portable.csproj
+++ b/src/Portable/Portable.csproj
@@ -888,15 +888,15 @@
LinearAlgebra\Single\Vector.cs
-
- LinearAlgebra\Storage\ArgumentValidation.cs
-
LinearAlgebra\Storage\DenseColumnMajorMatrixStorage.cs
LinearAlgebra\Storage\MatrixStorage.cs
+
+ LinearAlgebra\Storage\MatrixStorage.Validation.cs
+
LinearAlgebra\Storage\SparseCompressedRowMatrixStorage.cs
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs
index 11d5dc16..8803c84c 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs
@@ -108,28 +108,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
}
- ///
- /// Retrieves the requested element without range checking.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The requested element.
- public override Complex At(int row, int column)
- {
- return _data[row, column];
- }
-
- ///
- /// Sets the value of the given element.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The value to set the element to.
- public override void At(int row, int column, Complex value)
- {
- _data[row, column] = value;
- }
-
///
/// Creates a matrix for the given number of rows and columns.
///
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs
index a2b82f8f..fe193197 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs
@@ -108,28 +108,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
}
- ///
- /// Retrieves the requested element without range checking.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The requested element.
- public override Complex32 At(int row, int column)
- {
- return _data[row, column];
- }
-
- ///
- /// Sets the value of the given element.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The value to set the element to.
- public override void At(int row, int column, Complex32 value)
- {
- _data[row, column] = value;
- }
-
///
/// Creates a matrix for the given number of rows and columns.
///
diff --git a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs
index f0e8ee35..b6a0df9d 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs
@@ -107,28 +107,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
}
- ///
- /// Retrieves the requested element without range checking.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The requested element.
- public override double At(int row, int column)
- {
- return _data[row, column];
- }
-
- ///
- /// Sets the value of the given element.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The value to set the element to.
- public override void At(int row, int column, double value)
- {
- _data[row, column] = value;
- }
-
///
/// Creates a matrix for the given number of rows and columns.
///
diff --git a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs
index 75e71b9d..3cd4e2cd 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs
@@ -107,28 +107,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
}
- ///
- /// Retrieves the requested element without range checking.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The requested element.
- public override float At(int row, int column)
- {
- return _data[row, column];
- }
-
- ///
- /// Sets the value of the given element.
- ///
- /// The row of the element.
- /// The column of the element.
- /// The value to set the element to.
- public override void At(int row, int column, float value)
- {
- _data[row, column] = value;
- }
-
///
/// Creates a matrix for the given number of rows and columns.
///