Browse Source

Add new abstract class: PackedStorageIndexer

Signed-off-by: Alexander Karatarakis <alex@karatarakis.com>
pull/59/head
Alexander Karatarakis 14 years ago
parent
commit
18b5790a7c
  1. 50
      src/Numerics/LinearAlgebra/Storage/Indexers/Static/PackedStorageIndexer.cs
  2. 1
      src/Numerics/Numerics.csproj

50
src/Numerics/LinearAlgebra/Storage/Indexers/Static/PackedStorageIndexer.cs

@ -0,0 +1,50 @@
namespace MathNet.Numerics.LinearAlgebra.Storage.Indexers.Static
{
using System;
using Properties;
/// <summary>
/// A class for managing indexing when using Packed Storage indexer, which is a column-major packing scheme for dense Symmetric, Hermitian or Triangular square matrices.
/// </summary>
public abstract class PackedStorageIndexer : StaticStorageIndexer
{
/// <summary>
/// Number of rows or columns.
/// </summary>
protected readonly int Order;
/// <summary>
/// Length of the stored data.
/// </summary>
private readonly int _dataLength;
/// <summary>
/// Initializes a new instance of the <see cref="PackedStorageIndexer"/> class.
/// </summary>
/// <param name="order">
/// The order of the matrix.
/// </param>
/// <exception cref="ArgumentOutOfRangeException"><c></c> is out of range.</exception>
protected PackedStorageIndexer(int order)
{
if (order <= 0)
{
throw new ArgumentOutOfRangeException(Resources.MatrixRowsOrColumnsMustBePositive);
}
Order = order;
_dataLength = order * (order + 1) / 2;
}
/// <summary>
/// Gets the length of the stored data.
/// </summary>
public override int DataLength
{
get
{
return _dataLength;
}
}
}
}

1
src/Numerics/Numerics.csproj

@ -142,6 +142,7 @@
<Compile Include="Distributions\Multivariate\Wishart.cs" />
<Compile Include="LinearAlgebra\Storage\DenseVectorStorage.cs" />
<Compile Include="LinearAlgebra\Storage\Indexers\IStorageIndexer.cs" />
<Compile Include="LinearAlgebra\Storage\Indexers\Static\PackedStorageIndexer.cs" />
<Compile Include="LinearAlgebra\Storage\Indexers\Static\StaticStorageIndexer.cs" />
<Compile Include="LinearAlgebra\Storage\MatrixStorage.Validation.cs" />
<Compile Include="LinearAlgebra\Complex32\ExtensionMethods.cs" />

Loading…
Cancel
Save