diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
index b0826bac..581543ac 100644
--- a/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
+++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Arithmetic.cs
@@ -28,15 +28,12 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-
-using System.Runtime.CompilerServices;
+using System;
+using MathNet.Numerics.LinearAlgebra.Generic.Factorization;
+using MathNet.Numerics.Properties;
namespace MathNet.Numerics.LinearAlgebra.Generic
{
- using System;
- using Factorization;
- using Properties;
-
///
/// Defines the base class for Matrix classes.
///
@@ -982,198 +979,6 @@ namespace MathNet.Numerics.LinearAlgebra.Generic
DoModulus(divisor, result);
}
- ///
- /// Returns a Matrix containing the same values of .
- ///
- /// The matrix to get the values from.
- /// A matrix containing a the same values as .
- /// If is .
- public static Matrix operator +(Matrix rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return rightSide.Clone();
- }
-
- ///
- /// Negates each element of the matrix.
- ///
- /// The matrix to negate.
- /// A matrix containing the negated values.
- /// If is .
- public static Matrix operator -(Matrix rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return rightSide.Negate();
- }
-
- ///
- /// Adds two matrices together and returns the results.
- ///
- /// This operator will allocate new memory for the result. It will
- /// choose the representation of either or depending on which
- /// is denser.
- /// The left matrix to add.
- /// The right matrix to add.
- /// The result of the addition.
- /// If and don't have the same dimensions.
- /// If or is .
- public static Matrix operator +(Matrix leftSide, Matrix rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return leftSide.Add(rightSide);
- }
-
- ///
- /// Subtracts two matrices together and returns the results.
- ///
- /// This operator will allocate new memory for the result. It will
- /// choose the representation of either or depending on which
- /// is denser.
- /// The left matrix to subtract.
- /// The right matrix to subtract.
- /// The result of the addition.
- /// If and don't have the same dimensions.
- /// If or is .
- public static Matrix operator -(Matrix leftSide, Matrix rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return leftSide.Subtract(rightSide);
- }
-
- ///
- /// Multiplies a Matrix by a constant and returns the result.
- ///
- /// The matrix to multiply.
- /// The constant to multiply the matrix by.
- /// The result of the multiplication.
- /// If is .
- public static Matrix operator *(Matrix leftSide, T rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return leftSide.Multiply(rightSide);
- }
-
- ///
- /// Multiplies a Matrix by a constant and returns the result.
- ///
- /// The matrix to multiply.
- /// The constant to multiply the matrix by.
- /// The result of the multiplication.
- /// If is .
- public static Matrix operator *(T leftSide, Matrix rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return rightSide.Multiply(leftSide);
- }
-
- ///
- /// Multiplies two matrices.
- ///
- /// This operator will allocate new memory for the result. It will
- /// choose the representation of either or depending on which
- /// is denser.
- /// The left matrix to multiply.
- /// The right matrix to multiply.
- /// The result of multiplication.
- /// If or is .
- /// If the dimensions of or don't conform.
- public static Matrix operator *(Matrix leftSide, Matrix rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return leftSide.Multiply(rightSide);
- }
-
- ///
- /// Multiplies a Matrix and a Vector.
- ///
- /// The matrix to multiply.
- /// The vector to multiply.
- /// The result of multiplication.
- /// If or is .
- public static Vector operator *(Matrix leftSide, Vector rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return leftSide.Multiply(rightSide);
- }
-
- ///
- /// Multiplies a Vector and a Matrix.
- ///
- /// The vector to multiply.
- /// The matrix to multiply.
- /// The result of multiplication.
- /// If or is .
- public static Vector operator *(Vector leftSide, Matrix rightSide)
- {
- if (rightSide == null)
- {
- throw new ArgumentNullException("rightSide");
- }
-
- return rightSide.LeftMultiply(leftSide);
- }
-
- ///
- /// Multiplies a Matrix by a constant and returns the result.
- ///
- /// The matrix to multiply.
- /// The constant to multiply the matrix by.
- /// The result of the multiplication.
- /// If is .
- public static Matrix operator %(Matrix leftSide, T rightSide)
- {
- if (leftSide == null)
- {
- throw new ArgumentNullException("leftSide");
- }
-
- return leftSide.Modulus(rightSide);
- }
-
- [SpecialName]
- public static Matrix op_DotMultiply(Matrix x, Matrix y)
- {
- return x.PointwiseMultiply(y);
- }
-
- [SpecialName]
- public static Matrix op_DotDivide(Matrix x, Matrix y)
- {
- return x.PointwiseDivide(y);
- }
-
///
/// Computes the trace of this matrix.
///
diff --git a/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs b/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs
new file mode 100644
index 00000000..1462d071
--- /dev/null
+++ b/src/Numerics/LinearAlgebra/Generic/Matrix.Operators.cs
@@ -0,0 +1,233 @@
+//
+// Math.NET Numerics, part of the Math.NET Project
+// http://numerics.mathdotnet.com
+// http://github.com/mathnet/mathnet-numerics
+// http://mathnetnumerics.codeplex.com
+//
+// Copyright (c) 2009-2013 Math.NET
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.CompilerServices;
+
+namespace MathNet.Numerics.LinearAlgebra.Generic
+{
+ ///
+ /// Defines the base class for Matrix classes.
+ ///
+ public abstract partial class Matrix
+ {
+ ///
+ /// Returns a Matrix containing the same values of .
+ ///
+ /// The matrix to get the values from.
+ /// A matrix containing a the same values as .
+ /// If is .
+ public static Matrix operator +(Matrix rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return rightSide.Clone();
+ }
+
+ ///
+ /// Negates each element of the matrix.
+ ///
+ /// The matrix to negate.
+ /// A matrix containing the negated values.
+ /// If is .
+ public static Matrix operator -(Matrix rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return rightSide.Negate();
+ }
+
+ ///
+ /// Adds two matrices together and returns the results.
+ ///
+ /// This operator will allocate new memory for the result. It will
+ /// choose the representation of either or depending on which
+ /// is denser.
+ /// The left matrix to add.
+ /// The right matrix to add.
+ /// The result of the addition.
+ /// If and don't have the same dimensions.
+ /// If or is .
+ public static Matrix operator +(Matrix leftSide, Matrix rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.Add(rightSide);
+ }
+
+ ///
+ /// Subtracts two matrices together and returns the results.
+ ///
+ /// This operator will allocate new memory for the result. It will
+ /// choose the representation of either or depending on which
+ /// is denser.
+ /// The left matrix to subtract.
+ /// The right matrix to subtract.
+ /// The result of the addition.
+ /// If and don't have the same dimensions.
+ /// If or is .
+ public static Matrix operator -(Matrix leftSide, Matrix rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.Subtract(rightSide);
+ }
+
+ ///
+ /// Multiplies a Matrix by a constant and returns the result.
+ ///
+ /// The matrix to multiply.
+ /// The constant to multiply the matrix by.
+ /// The result of the multiplication.
+ /// If is .
+ public static Matrix operator *(Matrix leftSide, T rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.Multiply(rightSide);
+ }
+
+ ///
+ /// Multiplies a Matrix by a constant and returns the result.
+ ///
+ /// The matrix to multiply.
+ /// The constant to multiply the matrix by.
+ /// The result of the multiplication.
+ /// If is .
+ public static Matrix operator *(T leftSide, Matrix rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return rightSide.Multiply(leftSide);
+ }
+
+ ///
+ /// Multiplies two matrices.
+ ///
+ /// This operator will allocate new memory for the result. It will
+ /// choose the representation of either or depending on which
+ /// is denser.
+ /// The left matrix to multiply.
+ /// The right matrix to multiply.
+ /// The result of multiplication.
+ /// If or is .
+ /// If the dimensions of or don't conform.
+ public static Matrix operator *(Matrix leftSide, Matrix rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.Multiply(rightSide);
+ }
+
+ ///
+ /// Multiplies a Matrix and a Vector.
+ ///
+ /// The matrix to multiply.
+ /// The vector to multiply.
+ /// The result of multiplication.
+ /// If or is .
+ public static Vector operator *(Matrix leftSide, Vector rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.Multiply(rightSide);
+ }
+
+ ///
+ /// Multiplies a Vector and a Matrix.
+ ///
+ /// The vector to multiply.
+ /// The matrix to multiply.
+ /// The result of multiplication.
+ /// If or is .
+ public static Vector operator *(Vector leftSide, Matrix rightSide)
+ {
+ if (rightSide == null)
+ {
+ throw new ArgumentNullException("rightSide");
+ }
+
+ return rightSide.LeftMultiply(leftSide);
+ }
+
+ ///
+ /// Multiplies a Matrix by a constant and returns the result.
+ ///
+ /// The matrix to multiply.
+ /// The constant to multiply the matrix by.
+ /// The result of the multiplication.
+ /// If is .
+ public static Matrix operator %(Matrix leftSide, T rightSide)
+ {
+ if (leftSide == null)
+ {
+ throw new ArgumentNullException("leftSide");
+ }
+
+ return leftSide.Modulus(rightSide);
+ }
+
+ [SpecialName]
+ public static Matrix op_DotMultiply(Matrix x, Matrix y)
+ {
+ return x.PointwiseMultiply(y);
+ }
+
+ [SpecialName]
+ public static Matrix op_DotDivide(Matrix x, Matrix y)
+ {
+ return x.PointwiseDivide(y);
+ }
+ }
+}