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 @@ +