Browse Source

Tests: simplify user-defined matrix type

la-knuth
Christoph Ruegg 14 years ago
parent
commit
2133c6845d
  1. 23
      src/UnitTests/LinearAlgebraTests/Complex/UserDefinedMatrix.cs
  2. 23
      src/UnitTests/LinearAlgebraTests/Complex32/UserDefinedMatrix.cs
  3. 23
      src/UnitTests/LinearAlgebraTests/Double/UserDefinedMatrix.cs
  4. 23
      src/UnitTests/LinearAlgebraTests/Single/UserDefinedMatrix.cs

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

@ -63,21 +63,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{ {
Data[row, column] = value; Data[row, column] = value;
} }
public override void Clear()
{
Array.Clear(Data, 0, RowCount * ColumnCount);
}
}
readonly UserDefinedMatrixStorage _storage;
readonly Complex[,] _data;
private UserDefinedMatrix(UserDefinedMatrixStorage storage)
: base(storage)
{
_storage = storage;
_data = _storage.Data;
} }
/// <summary> /// <summary>
@ -85,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary> /// </summary>
/// <param name="order">the size of the square matrix.</param> /// <param name="order">the size of the square matrix.</param>
public UserDefinedMatrix(int order) public UserDefinedMatrix(int order)
: this(new UserDefinedMatrixStorage(order, order)) : base(new UserDefinedMatrixStorage(order, order))
{ {
} }
@ -95,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <param name="rows">The number of rows.</param> /// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param> /// <param name="columns">The number of columns.</param>
public UserDefinedMatrix(int rows, int columns) public UserDefinedMatrix(int rows, int columns)
: this(new UserDefinedMatrixStorage(rows, columns)) : base(new UserDefinedMatrixStorage(rows, columns))
{ {
} }
@ -104,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// </summary> /// </summary>
/// <param name="data">The 2D array to create this matrix from.</param> /// <param name="data">The 2D array to create this matrix from.</param>
public UserDefinedMatrix(Complex[,] data) public UserDefinedMatrix(Complex[,] data)
: this(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (Complex[,]) data.Clone())) : base(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (Complex[,])data.Clone()))
{ {
} }
@ -139,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
var m = new UserDefinedMatrix(order, order); var m = new UserDefinedMatrix(order, order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
m[i, i] = 1.0; m[i, i] = 1d;
} }
return m; return m;

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

@ -63,21 +63,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{ {
Data[row, column] = value; Data[row, column] = value;
} }
public override void Clear()
{
Array.Clear(Data, 0, RowCount * ColumnCount);
}
}
readonly UserDefinedMatrixStorage _storage;
readonly Complex32[,] _data;
private UserDefinedMatrix(UserDefinedMatrixStorage storage)
: base(storage)
{
_storage = storage;
_data = _storage.Data;
} }
/// <summary> /// <summary>
@ -85,7 +70,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary> /// </summary>
/// <param name="order">the size of the square matrix.</param> /// <param name="order">the size of the square matrix.</param>
public UserDefinedMatrix(int order) public UserDefinedMatrix(int order)
: this(new UserDefinedMatrixStorage(order, order)) : base(new UserDefinedMatrixStorage(order, order))
{ {
} }
@ -95,7 +80,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <param name="rows">The number of rows.</param> /// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param> /// <param name="columns">The number of columns.</param>
public UserDefinedMatrix(int rows, int columns) public UserDefinedMatrix(int rows, int columns)
: this(new UserDefinedMatrixStorage(rows, columns)) : base(new UserDefinedMatrixStorage(rows, columns))
{ {
} }
@ -104,7 +89,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// </summary> /// </summary>
/// <param name="data">The 2D array to create this matrix from.</param> /// <param name="data">The 2D array to create this matrix from.</param>
public UserDefinedMatrix(Complex32[,] data) public UserDefinedMatrix(Complex32[,] data)
: this(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (Complex32[,])data.Clone())) : base(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (Complex32[,])data.Clone()))
{ {
} }
@ -139,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
var m = new UserDefinedMatrix(order, order); var m = new UserDefinedMatrix(order, order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
m[i, i] = 1.0f; m[i, i] = 1f;
} }
return m; return m;

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

@ -62,21 +62,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{ {
Data[row, column] = value; Data[row, column] = value;
} }
public override void Clear()
{
Array.Clear(Data, 0, RowCount * ColumnCount);
}
}
readonly UserDefinedMatrixStorage _storage;
readonly double[,] _data;
private UserDefinedMatrix(UserDefinedMatrixStorage storage)
: base(storage)
{
_storage = storage;
_data = _storage.Data;
} }
/// <summary> /// <summary>
@ -84,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary> /// </summary>
/// <param name="order">the size of the square matrix.</param> /// <param name="order">the size of the square matrix.</param>
public UserDefinedMatrix(int order) public UserDefinedMatrix(int order)
: this(new UserDefinedMatrixStorage(order, order)) : base(new UserDefinedMatrixStorage(order, order))
{ {
} }
@ -94,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <param name="rows">The number of rows.</param> /// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param> /// <param name="columns">The number of columns.</param>
public UserDefinedMatrix(int rows, int columns) public UserDefinedMatrix(int rows, int columns)
: this(new UserDefinedMatrixStorage(rows, columns)) : base(new UserDefinedMatrixStorage(rows, columns))
{ {
} }
@ -103,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// </summary> /// </summary>
/// <param name="data">The 2D array to create this matrix from.</param> /// <param name="data">The 2D array to create this matrix from.</param>
public UserDefinedMatrix(double[,] data) public UserDefinedMatrix(double[,] data)
: this(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (double[,])data.Clone())) : base(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (double[,])data.Clone()))
{ {
} }
@ -138,7 +123,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
var m = new UserDefinedMatrix(order, order); var m = new UserDefinedMatrix(order, order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
m[i, i] = 1.0; m[i, i] = 1d;
} }
return m; return m;

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

@ -62,21 +62,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{ {
Data[row, column] = value; Data[row, column] = value;
} }
public override void Clear()
{
Array.Clear(Data, 0, RowCount*ColumnCount);
}
}
readonly UserDefinedMatrixStorage _storage;
readonly float[,] _data;
private UserDefinedMatrix(UserDefinedMatrixStorage storage)
: base(storage)
{
_storage = storage;
_data = _storage.Data;
} }
/// <summary> /// <summary>
@ -84,7 +69,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary> /// </summary>
/// <param name="order">the size of the square matrix.</param> /// <param name="order">the size of the square matrix.</param>
public UserDefinedMatrix(int order) public UserDefinedMatrix(int order)
: this(new UserDefinedMatrixStorage(order, order)) : base(new UserDefinedMatrixStorage(order, order))
{ {
} }
@ -94,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <param name="rows">The number of rows.</param> /// <param name="rows">The number of rows.</param>
/// <param name="columns">The number of columns.</param> /// <param name="columns">The number of columns.</param>
public UserDefinedMatrix(int rows, int columns) public UserDefinedMatrix(int rows, int columns)
: this(new UserDefinedMatrixStorage(rows, columns)) : base(new UserDefinedMatrixStorage(rows, columns))
{ {
} }
@ -103,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// </summary> /// </summary>
/// <param name="data">The 2D array to create this matrix from.</param> /// <param name="data">The 2D array to create this matrix from.</param>
public UserDefinedMatrix(float[,] data) public UserDefinedMatrix(float[,] data)
: this(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (float[,])data.Clone())) : base(new UserDefinedMatrixStorage(data.GetLength(0), data.GetLength(1), (float[,])data.Clone()))
{ {
} }
@ -138,7 +123,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
var m = new UserDefinedMatrix(order, order); var m = new UserDefinedMatrix(order, order);
for (var i = 0; i < order; i++) for (var i = 0; i < order; i++)
{ {
m[i, i] = 1.0f; m[i, i] = 1f;
} }
return m; return m;

Loading…
Cancel
Save