Browse Source

Add new abstract class: SquareMatrix

Signed-off-by: Alexander Karatarakis <alex@karatarakis.com>
pull/59/head
Alexander Karatarakis 14 years ago
parent
commit
e774bf4be4
  1. 39
      src/Numerics/LinearAlgebra/Generic/SquareMatrix.cs
  2. 1
      src/Numerics/Numerics.csproj

39
src/Numerics/LinearAlgebra/Generic/SquareMatrix.cs

@ -0,0 +1,39 @@
namespace MathNet.Numerics.LinearAlgebra.Generic
{
using System;
using MathNet.Numerics.LinearAlgebra.Storage;
using Properties;
/// <summary>
/// Abstract class for square matrices.
/// </summary>
/// <typeparam name="T">Supported data types are <c>double</c>, <c>single</c>, <see cref="Complex"/>, and <see cref="Complex32"/>.</typeparam>
[Serializable]
public abstract class SquareMatrix<T> : Matrix<T>
where T : struct, IEquatable<T>, IFormattable
{
/// <summary>
/// Number of rows or columns.
/// </summary>
protected readonly int Order;
/// <summary>
/// Initializes a new instance of the <see cref="SquareMatrix{T}"/> class.
/// </summary>
/// <exception cref="ArgumentException">
/// If the matrix is not square.
/// </exception>
protected SquareMatrix(MatrixStorage<T> storage)
: base(storage)
{
if (storage.RowCount != storage.ColumnCount)
{
throw new ArgumentException(Resources.ArgumentMatrixSquare);
}
Order = storage.RowCount;
}
}
}

1
src/Numerics/Numerics.csproj

@ -140,6 +140,7 @@
<Compile Include="Distributions\Multivariate\InverseWishart.cs" />
<Compile Include="Distributions\Multivariate\MatrixNormal.cs" />
<Compile Include="Distributions\Multivariate\Wishart.cs" />
<Compile Include="LinearAlgebra\Generic\SquareMatrix.cs" />
<Compile Include="LinearAlgebra\Storage\DenseColumnMajorSymmetricMatrixStorage.cs" />
<Compile Include="LinearAlgebra\Storage\DenseVectorStorage.cs" />
<Compile Include="LinearAlgebra\Storage\Indexers\IStorageIndexer.cs" />

Loading…
Cancel
Save