Browse Source

LA: expose publicly whether a matrix/vector storage format is dense or not

pull/163/head
Christoph Ruegg 13 years ago
parent
commit
fdd2c5368f
  1. 26
      src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs
  2. 8
      src/Numerics/LinearAlgebra/Storage/DenseVectorStorage.cs
  3. 36
      src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs
  4. 35
      src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs
  5. 26
      src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs
  6. 8
      src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs
  7. 23
      src/Numerics/LinearAlgebra/Storage/VectorStorage.cs
  8. 15
      src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs
  9. 5
      src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVector.cs
  10. 15
      src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs
  11. 5
      src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVector.cs
  12. 15
      src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs
  13. 5
      src/UnitTests/LinearAlgebraTests/Double/UserDefinedVector.cs
  14. 15
      src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs
  15. 5
      src/UnitTests/LinearAlgebraTests/Single/UserDefinedVector.cs

26
src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs

@ -66,6 +66,32 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
Data = data;
}
/// <summary>
/// True if the matrix storage format is dense.
/// </summary>
public override bool IsDense
{
get { return true; }
}
/// <summary>
/// True if all fields of this matrix can be set to any value.
/// False if some fields are fixed, like on a diagonal matrix.
/// </summary>
public override bool IsFullyMutable
{
get { return true; }
}
/// <summary>
/// True if the specified field can be set to any value.
/// False if the field is fixed, like an off-diagonal field on a diagonal matrix.
/// </summary>
public override bool IsMutableAt(int row, int column)
{
return true;
}
/// <summary>
/// Retrieves the requested element without range checking.
/// </summary>

8
src/Numerics/LinearAlgebra/Storage/DenseVectorStorage.cs

@ -66,6 +66,14 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
Data = data;
}
/// <summary>
/// True if the vector storage format is dense.
/// </summary>
public override bool IsDense
{
get { return true; }
}
/// <summary>
/// Retrieves the requested element without range checking.
/// </summary>

36
src/Numerics/LinearAlgebra/Storage/DiagonalMatrixStorage.cs

@ -66,6 +66,32 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
Data = data;
}
/// <summary>
/// True if the matrix storage format is dense.
/// </summary>
public override bool IsDense
{
get { return false; }
}
/// <summary>
/// True if all fields of this matrix can be set to any value.
/// False if some fields are fixed, like on a diagonal matrix.
/// </summary>
public override bool IsFullyMutable
{
get { return false; }
}
/// <summary>
/// True if the specified field can be set to any value.
/// False if the field is fixed, like an off-diagonal field on a diagonal matrix.
/// </summary>
public override bool IsMutableAt(int row, int column)
{
return row == column;
}
/// <summary>
/// Retrieves the requested element without range checking.
/// </summary>
@ -89,16 +115,6 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
}
}
public override bool IsFullyMutable
{
get { return false; }
}
public override bool IsMutable(int row, int column)
{
return row == column;
}
public override void Clear()
{
Array.Clear(Data, 0, Data.Length);

35
src/Numerics/LinearAlgebra/Storage/MatrixStorage.cs

@ -60,6 +60,23 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
ColumnCount = columnCount;
}
/// <summary>
/// True if the matrix storage format is dense.
/// </summary>
public abstract bool IsDense { get; }
/// <summary>
/// True if all fields of this matrix can be set to any value.
/// False if some fields are fixed, like on a diagonal matrix.
/// </summary>
public abstract bool IsFullyMutable { get; }
/// <summary>
/// True if the specified field can be set to any value.
/// False if the field is fixed, like an off-diagonal field on a diagonal matrix.
/// </summary>
public abstract bool IsMutableAt(int row, int column);
/// <summary>
/// Gets or sets the value at the given row and column, with range checking.
/// </summary>
@ -111,24 +128,6 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
/// <remarks>WARNING: This method is not thread safe. Use "lock" with it and be sure to avoid deadlocks.</remarks>
public abstract void At(int row, int column, T value);
/// <summary>
/// True if all fields of this matrix can be set to any value.
/// False if some fields are fixed, like on a diagonal matrix.
/// </summary>
public virtual bool IsFullyMutable
{
get { return true; }
}
/// <summary>
/// True if the specified field can be set to any value.
/// False if the field is fixed, like an off-diagonal field on a diagonal matrix.
/// </summary>
public virtual bool IsMutable(int row, int column)
{
return true;
}
public virtual void Clear()
{
for (var i = 0; i < RowCount; i++)

26
src/Numerics/LinearAlgebra/Storage/SparseCompressedRowMatrixStorage.cs

@ -74,6 +74,32 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
ValueCount = 0;
}
/// <summary>
/// True if the matrix storage format is dense.
/// </summary>
public override bool IsDense
{
get { return false; }
}
/// <summary>
/// True if all fields of this matrix can be set to any value.
/// False if some fields are fixed, like on a diagonal matrix.
/// </summary>
public override bool IsFullyMutable
{
get { return true; }
}
/// <summary>
/// True if the specified field can be set to any value.
/// False if the field is fixed, like an off-diagonal field on a diagonal matrix.
/// </summary>
public override bool IsMutableAt(int row, int column)
{
return true;
}
/// <summary>
/// Retrieves the requested element without range checking.
/// </summary>

8
src/Numerics/LinearAlgebra/Storage/SparseVectorStorage.cs

@ -64,6 +64,14 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
ValueCount = 0;
}
/// <summary>
/// True if the vector storage format is dense.
/// </summary>
public override bool IsDense
{
get { return false; }
}
/// <summary>
/// Retrieves the requested element without range checking.
/// </summary>

23
src/Numerics/LinearAlgebra/Storage/VectorStorage.cs

@ -53,6 +53,11 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
Length = length;
}
/// <summary>
/// True if the vector storage format is dense.
/// </summary>
public abstract bool IsDense { get; }
/// <summary>
/// Gets or sets the value at the given index, with range checking.
/// </summary>
@ -93,24 +98,6 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
/// <remarks>WARNING: This method is not thread safe. Use "lock" with it and be sure to avoid deadlocks.</remarks>
public abstract void At(int index, T value);
/// <summary>
/// True if all fields of this vector can be set to any value.
/// False if some fields are fixed.
/// </summary>
public virtual bool IsFullyMutable
{
get { return true; }
}
/// <summary>
/// True if the specified field can be set to any value.
/// False if the field is fixed.
/// </summary>
public virtual bool IsMutable(int index)
{
return true;
}
public virtual void Clear()
{
for (var i = 0; i < Length; i++)

15
src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs

@ -53,6 +53,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override bool IsFullyMutable
{
get { return true; }
}
public override bool IsMutableAt(int row, int column)
{
return true;
}
public override Complex At(int row, int column)
{
return Data[row, column];

5
src/UnitTests/LinearAlgebraTests/Complex/UserDefinedVector.cs

@ -53,6 +53,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override Complex At(int index)
{
return Data[index];

15
src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs

@ -53,6 +53,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override bool IsFullyMutable
{
get { return true; }
}
public override bool IsMutableAt(int row, int column)
{
return true;
}
public override Complex32 At(int row, int column)
{
return Data[row, column];

5
src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedVector.cs

@ -53,6 +53,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override Complex32 At(int index)
{
return Data[index];

15
src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs

@ -51,6 +51,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override bool IsFullyMutable
{
get { return true; }
}
public override bool IsMutableAt(int row, int column)
{
return true;
}
public override double At(int row, int column)
{
return Data[row, column];

5
src/UnitTests/LinearAlgebraTests/Double/UserDefinedVector.cs

@ -51,6 +51,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override double At(int index)
{
return Data[index];

15
src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs

@ -51,6 +51,21 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override bool IsFullyMutable
{
get { return true; }
}
public override bool IsMutableAt(int row, int column)
{
return true;
}
public override float At(int row, int column)
{
return Data[row, column];

5
src/UnitTests/LinearAlgebraTests/Single/UserDefinedVector.cs

@ -51,6 +51,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Data = data;
}
public override bool IsDense
{
get { return true; }
}
public override float At(int index)
{
return Data[index];

Loading…
Cancel
Save