From e774bf4be4b2ded5838d383d09b78b043c0c4e33 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 21 Nov 2012 17:32:48 +0200 Subject: [PATCH] Add new abstract class: SquareMatrix Signed-off-by: Alexander Karatarakis --- .../LinearAlgebra/Generic/SquareMatrix.cs | 39 +++++++++++++++++++ src/Numerics/Numerics.csproj | 1 + 2 files changed, 40 insertions(+) create mode 100644 src/Numerics/LinearAlgebra/Generic/SquareMatrix.cs diff --git a/src/Numerics/LinearAlgebra/Generic/SquareMatrix.cs b/src/Numerics/LinearAlgebra/Generic/SquareMatrix.cs new file mode 100644 index 00000000..ca4ba3e2 --- /dev/null +++ b/src/Numerics/LinearAlgebra/Generic/SquareMatrix.cs @@ -0,0 +1,39 @@ +namespace MathNet.Numerics.LinearAlgebra.Generic +{ + using System; + + using MathNet.Numerics.LinearAlgebra.Storage; + + using Properties; + + /// + /// Abstract class for square matrices. + /// + /// Supported data types are double, single, , and . + [Serializable] + public abstract class SquareMatrix : Matrix + where T : struct, IEquatable, IFormattable + { + /// + /// Number of rows or columns. + /// + protected readonly int Order; + + /// + /// Initializes a new instance of the class. + /// + /// + /// If the matrix is not square. + /// + protected SquareMatrix(MatrixStorage storage) + : base(storage) + { + if (storage.RowCount != storage.ColumnCount) + { + throw new ArgumentException(Resources.ArgumentMatrixSquare); + } + + Order = storage.RowCount; + } + } +} diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index 12d2ad78..64c39dbd 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -140,6 +140,7 @@ +