diff --git a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
index 9e5d9716..1e1180f0 100644
--- a/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex/DiagonalMatrix.cs
@@ -228,34 +228,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// The matrix to store the result of the addition.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Add(Matrix other, Matrix result)
+ protected override void DoAdd(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, result, "result");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Add(other, result);
+ base.DoAdd(other, result);
}
else
{
@@ -303,34 +283,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex
/// The matrix to store the result of the subtraction.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Subtract(Matrix other, Matrix result)
+ protected override void DoSubtract(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Subtract(other, result);
+ base.DoSubtract(other, result);
}
else
{
diff --git a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
index e503bdfb..aa6152a5 100644
--- a/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Complex32/DiagonalMatrix.cs
@@ -228,34 +228,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// The matrix to store the result of the addition.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Add(Matrix other, Matrix result)
+ protected override void DoAdd(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Add(other, result);
+ base.DoAdd(other, result);
}
else
{
@@ -303,34 +283,14 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32
/// The matrix to store the result of the subtraction.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Subtract(Matrix other, Matrix result)
+ protected override void DoSubtract(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "result");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Subtract(other, result);
+ base.DoSubtract(other, result);
}
else
{
diff --git a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
index a7222099..10b64224 100644
--- a/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Double/DiagonalMatrix.cs
@@ -227,38 +227,18 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// The matrix to store the result of the addition.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Add(Matrix other, Matrix result)
+ protected override void DoAdd(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, result, "result");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Add(other, result);
+ base.DoAdd(other, result);
}
else
{
- Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
+ Control.LinearAlgebraProvider.AddArrays(_data, diagOther._data, diagResult._data);
}
}
@@ -302,34 +282,14 @@ namespace MathNet.Numerics.LinearAlgebra.Double
/// The matrix to store the result of the subtraction.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Subtract(Matrix other, Matrix result)
+ protected override void DoSubtract(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, result, "result");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Subtract(other, result);
+ base.DoSubtract(other, result);
}
else
{
diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
index e479875e..9e24dd12 100644
--- a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
@@ -81,13 +81,18 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// The matrix to store the result of the addition.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public virtual void Add(Matrix other, Matrix result)
+ public void Add(Matrix other, Matrix result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
+ if (result == null)
+ {
+ throw new ArgumentNullException("result");
+ }
+
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
throw DimensionsDontMatch(this, other, "other");
@@ -141,16 +146,26 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
/// The matrix to store the result of the subtraction.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public virtual void Subtract(Matrix other, Matrix result)
+ public void Subtract(Matrix other, Matrix result)
{
if (other == null)
{
throw new ArgumentNullException("other");
}
+ if (result == null)
+ {
+ throw new ArgumentNullException("result");
+ }
+
if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
{
- throw DimensionsDontMatch(this, other);
+ throw DimensionsDontMatch(this, other, "other");
+ }
+
+ if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
+ {
+ throw DimensionsDontMatch(this, result, "result");
}
DoSubtract(other, result);
diff --git a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
index b137b0bb..f94d23ec 100644
--- a/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
+++ b/src/Numerics/LinearAlgebra/Single/DiagonalMatrix.cs
@@ -227,34 +227,14 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// The matrix to store the result of the addition.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Add(Matrix other, Matrix result)
+ protected override void DoAdd(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, result, "result");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Add(other, result);
+ base.DoAdd(other, result);
}
else
{
@@ -302,34 +282,14 @@ namespace MathNet.Numerics.LinearAlgebra.Single
/// The matrix to store the result of the subtraction.
/// If the other matrix is .
/// If the two matrices don't have the same dimensions.
- public override void Subtract(Matrix other, Matrix result)
+ protected override void DoSubtract(Matrix other, Matrix result)
{
- if (other == null)
- {
- throw new ArgumentNullException("other");
- }
-
- if (result == null)
- {
- throw new ArgumentNullException("result");
- }
-
- if (other.RowCount != RowCount || other.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, other, "other");
- }
-
- if (result.RowCount != RowCount || result.ColumnCount != ColumnCount)
- {
- throw DimensionsDontMatch(this, result, "result");
- }
-
var diagOther = other as DiagonalMatrix;
var diagResult = result as DiagonalMatrix;
if (diagOther == null || diagResult == null)
{
- base.Subtract(other, result);
+ base.DoSubtract(other, result);
}
else
{