Browse Source

Cosmetics

pull/112/head
Christoph Ruegg 13 years ago
parent
commit
6908674873
  1. 1
      src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs
  2. 76
      src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs
  3. 88
      src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs
  4. 76
      src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs
  5. 88
      src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs

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

@ -130,7 +130,6 @@ namespace MathNet.Numerics.LinearAlgebra.Storage
{
for (var i = 0; i < storage.RowCount; i++)
{
storage.Data[index++] = init(i, j);
}
}

76
src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs

@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
// Copyright (c) 2009-2010 Math.NET
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -42,20 +46,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
/// <summary>
/// Gets or sets test matrices values to use.
/// </summary>
protected Dictionary<string, Complex[,]> TestData2D
{
get;
set;
}
protected Dictionary<string, Complex[,]> TestData2D { get; set; }
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices
{
get;
set;
}
protected Dictionary<string, Matrix> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -94,15 +90,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
public virtual void SetupMatrices()
{
TestData2D = new Dictionary<string, Complex[,]>
{
{ "Singular3x3", new[,] { { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) } } },
{ "Square3x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1) } } },
{ "Square4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1), new Complex(3.3, 1) }, { new Complex(1.0, 1), new Complex(2.1, 1), new Complex(6.2, 1), new Complex(4.3, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1), new Complex(-7.7, 1) } } },
{ "Singular4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) } } },
{ "Tall3x2", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1) }, { Complex.Zero, new Complex(1.1, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1) } } },
{ "Wide2x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) } } },
{ "Symmetric3x3", new[,] { { Complex.One, 2.0, 3.0 }, { 2.0, 2.0, 0.0 }, { 3.0, 0.0, 3.0 } } }
};
{
{"Singular3x3", new[,] {{new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1)}, {new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1)}, {new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1)}}},
{"Square3x3", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1)}, {Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1)}, {new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1)}}},
{"Square4x4", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1), new Complex(3.3, 1)}, {new Complex(1.0, 1), new Complex(2.1, 1), new Complex(6.2, 1), new Complex(4.3, 1)}, {new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1), new Complex(-7.7, 1)}}},
{"Singular4x4", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}}},
{"Tall3x2", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1)}, {Complex.Zero, new Complex(1.1, 1)}, {new Complex(-4.4, 1), new Complex(5.5, 1)}}},
{"Wide2x3", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1)}, {Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1)}}},
{"Symmetric3x3", new[,] {{Complex.One, 2.0, 3.0}, {2.0, 2.0, 0.0}, {3.0, 0.0, 3.0}}}
};
TestMatrices = new Dictionary<string, Matrix>();
foreach (var name in TestData2D.Keys)
@ -121,9 +117,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++)
{
@ -145,9 +141,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++)
{
@ -158,7 +154,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
// Generate a Hermitian matrix which is positive definite.
return matrixA.ConjugateTranspose() * matrixA;
return matrixA.ConjugateTranspose()*matrixA;
}
/// <summary>
@ -170,9 +166,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order);
for (var i = 0; i < order; i++)
{
@ -192,9 +188,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++)
{
@ -216,9 +212,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++)
{
@ -229,7 +225,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
// Generate a Hermitian matrix which is positive definite.
return matrixA.ConjugateTranspose() * matrixA;
return matrixA.ConjugateTranspose()*matrixA;
}
/// <summary>
@ -241,9 +237,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++)
{

88
src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs

@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
// Copyright (c) 2009-2010 Math.NET
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -42,20 +46,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
/// <summary>
/// Gets or sets test matrices values to use.
/// </summary>
protected Dictionary<string, Complex32[,]> TestData2D
{
get;
set;
}
protected Dictionary<string, Complex32[,]> TestData2D { get; set; }
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices
{
get;
set;
}
protected Dictionary<string, Matrix> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -94,15 +90,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
public virtual void SetupMatrices()
{
TestData2D = new Dictionary<string, Complex32[,]>
{
{ "Singular3x3", new[,] { { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) } } },
{ "Square3x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1) } } },
{ "Square4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1) }, { new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1) } } },
{ "Singular4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) } } },
{ "Tall3x2", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1) } } },
{ "Wide2x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) } } },
{ "Symmetric3x3", new[,] { { Complex32.One, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } }
};
{
{"Singular3x3", new[,] {{new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}, {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}, {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}}},
{"Square3x3", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1)}}},
{"Square4x4", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1)}, {new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1)}}},
{"Singular4x4", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}}},
{"Tall3x2", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1)}}},
{"Wide2x3", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1)}}},
{"Symmetric3x3", new[,] {{Complex32.One, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}}
};
TestMatrices = new Dictionary<string, Matrix>();
foreach (var name in TestData2D.Keys)
@ -121,15 +117,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++)
{
for (var j = 0; j < col; j++)
{
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample());
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample());
}
}
@ -145,20 +141,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++)
{
for (var j = 0; j < order; j++)
{
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample());
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample());
}
}
// Generate a Hermitian matrix which is positive definite.
return matrixA.ConjugateTranspose() * matrixA;
return matrixA.ConjugateTranspose()*matrixA;
}
/// <summary>
@ -170,13 +166,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order);
for (var i = 0; i < order; i++)
{
v[i] = new Complex32((float)normal.Sample(), (float)normal.Sample());
v[i] = new Complex32((float) normal.Sample(), (float) normal.Sample());
}
return v;
@ -192,15 +188,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++)
{
for (var j = 0; j < col; j++)
{
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample());
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample());
}
}
@ -216,20 +212,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++)
{
for (var j = 0; j < order; j++)
{
matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample());
matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample());
}
}
// Generate a Hermitian matrix which is positive definite.
return matrixA.ConjugateTranspose() * matrixA;
return matrixA.ConjugateTranspose()*matrixA;
}
/// <summary>
@ -241,13 +237,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++)
{
v[i] = new Complex32((float)normal.Sample(), (float)normal.Sample());
v[i] = new Complex32((float) normal.Sample(), (float) normal.Sample());
}
// Generate a matrix which is positive definite.

76
src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs

@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
// Copyright (c) 2009-2010 Math.NET
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -41,20 +45,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
/// <summary>
/// Gets or sets test matrices values to use.
/// </summary>
protected Dictionary<string, double[,]> TestData2D
{
get;
set;
}
protected Dictionary<string, double[,]> TestData2D { get; set; }
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices
{
get;
set;
}
protected Dictionary<string, Matrix> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -93,15 +89,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
public virtual void SetupMatrices()
{
TestData2D = new Dictionary<string, double[,]>
{
{ "Singular3x3", new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } } },
{ "Square3x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } } },
{ "Square4x4", new[,] { { -1.1, -2.2, -3.3, -4.4 }, { 0.0, 1.1, 2.2, 3.3 }, { 1.0, 2.1, 6.2, 4.3 }, { -4.4, 5.5, 6.6, -7.7 } } },
{ "Singular4x4", new[,] { { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 }, { -1.1, -2.2, -3.3, -4.4 } } },
{ "Tall3x2", new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } } },
{ "Wide2x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } } },
{ "Symmetric3x3", new[,] { { 1.0, 2.0, 3.0 }, { 2.0, 2.0, 0.0 }, { 3.0, 0.0, 3.0 } } }
};
{
{"Singular3x3", new[,] {{1.0, 1.0, 2.0}, {1.0, 1.0, 2.0}, {1.0, 1.0, 2.0}}},
{"Square3x3", new[,] {{-1.1, -2.2, -3.3}, {0.0, 1.1, 2.2}, {-4.4, 5.5, 6.6}}},
{"Square4x4", new[,] {{-1.1, -2.2, -3.3, -4.4}, {0.0, 1.1, 2.2, 3.3}, {1.0, 2.1, 6.2, 4.3}, {-4.4, 5.5, 6.6, -7.7}}},
{"Singular4x4", new[,] {{-1.1, -2.2, -3.3, -4.4}, {-1.1, -2.2, -3.3, -4.4}, {-1.1, -2.2, -3.3, -4.4}, {-1.1, -2.2, -3.3, -4.4}}},
{"Tall3x2", new[,] {{-1.1, -2.2}, {0.0, 1.1}, {-4.4, 5.5}}},
{"Wide2x3", new[,] {{-1.1, -2.2, -3.3}, {0.0, 1.1, 2.2}}},
{"Symmetric3x3", new[,] {{1.0, 2.0, 3.0}, {2.0, 2.0, 0.0}, {3.0, 0.0, 3.0}}}
};
TestMatrices = new Dictionary<string, Matrix>();
foreach (var name in TestData2D.Keys)
@ -120,9 +116,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++)
{
@ -144,9 +140,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++)
{
@ -157,7 +153,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
// Generate a matrix which is positive definite.
return matrixA.Transpose() * matrixA;
return matrixA.Transpose()*matrixA;
}
/// <summary>
@ -169,9 +165,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order);
for (var i = 0; i < order; i++)
{
@ -191,9 +187,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++)
{
@ -215,9 +211,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++)
{
@ -228,7 +224,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
// Generate a matrix which is positive definite.
return matrixA.Transpose() * matrixA;
return matrixA.Transpose()*matrixA;
}
/// <summary>
@ -240,9 +236,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++)
{

88
src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs

@ -3,7 +3,9 @@
// http://numerics.mathdotnet.com
// http://github.com/mathnet/mathnet-numerics
// http://mathnetnumerics.codeplex.com
// Copyright (c) 2009-2010 Math.NET
//
// Copyright (c) 2009-2013 Math.NET
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
@ -12,8 +14,10 @@
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@ -41,20 +45,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
/// <summary>
/// Gets or sets test matrices values to use.
/// </summary>
protected Dictionary<string, float[,]> TestData2D
{
get;
set;
}
protected Dictionary<string, float[,]> TestData2D { get; set; }
/// <summary>
/// Gets or sets test matrices instances to use.
/// </summary>
protected Dictionary<string, Matrix> TestMatrices
{
get;
set;
}
protected Dictionary<string, Matrix> TestMatrices { get; set; }
/// <summary>
/// Creates a matrix for the given number of rows and columns.
@ -93,15 +89,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
public virtual void SetupMatrices()
{
TestData2D = new Dictionary<string, float[,]>
{
{ "Singular3x3", new[,] { { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } } },
{ "Square3x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } } },
{ "Square4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } } },
{ "Singular4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f }, { -1.1f, -2.2f, -3.3f, -4.4f } } },
{ "Tall3x2", new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } } },
{ "Wide2x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } } },
{ "Symmetric3x3", new[,] { { 1.0f, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } }
};
{
{"Singular3x3", new[,] {{1.0f, 1.0f, 2.0f}, {1.0f, 1.0f, 2.0f}, {1.0f, 1.0f, 2.0f}}},
{"Square3x3", new[,] {{-1.1f, -2.2f, -3.3f}, {0.0f, 1.1f, 2.2f}, {-4.4f, 5.5f, 6.6f}}},
{"Square4x4", new[,] {{-1.1f, -2.2f, -3.3f, -4.4f}, {0.0f, 1.1f, 2.2f, 3.3f}, {1.0f, 2.1f, 6.2f, 4.3f}, {-4.4f, 5.5f, 6.6f, -7.7f}}},
{"Singular4x4", new[,] {{-1.1f, -2.2f, -3.3f, -4.4f}, {-1.1f, -2.2f, -3.3f, -4.4f}, {-1.1f, -2.2f, -3.3f, -4.4f}, {-1.1f, -2.2f, -3.3f, -4.4f}}},
{"Tall3x2", new[,] {{-1.1f, -2.2f}, {0.0f, 1.1f}, {-4.4f, 5.5f}}},
{"Wide2x3", new[,] {{-1.1f, -2.2f, -3.3f}, {0.0f, 1.1f, 2.2f}}},
{"Symmetric3x3", new[,] {{1.0f, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}}
};
TestMatrices = new Dictionary<string, Matrix>();
foreach (var name in TestData2D.Keys)
@ -120,15 +116,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(row, col);
for (var i = 0; i < row; i++)
{
for (var j = 0; j < col; j++)
{
matrixA[i, j] = (float)normal.Sample();
matrixA[i, j] = (float) normal.Sample();
}
}
@ -144,20 +140,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new DenseMatrix(order);
for (var i = 0; i < order; i++)
{
for (var j = 0; j < order; j++)
{
matrixA[i, j] = (float)normal.Sample();
matrixA[i, j] = (float) normal.Sample();
}
}
// Generate a matrix which is positive definite.
return matrixA.Transpose() * matrixA;
return matrixA.Transpose()*matrixA;
}
/// <summary>
@ -169,13 +165,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new DenseVector(order);
for (var i = 0; i < order; i++)
{
v[i] = (float)normal.Sample();
v[i] = (float) normal.Sample();
}
return v;
@ -191,15 +187,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(row, col);
for (var i = 0; i < row; i++)
{
for (var j = 0; j < col; j++)
{
matrixA[i, j] = (float)normal.Sample();
matrixA[i, j] = (float) normal.Sample();
}
}
@ -215,20 +211,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var matrixA = new UserDefinedMatrix(order);
for (var i = 0; i < order; i++)
{
for (var j = 0; j < order; j++)
{
matrixA[i, j] = (float)normal.Sample();
matrixA[i, j] = (float) normal.Sample();
}
}
// Generate a matrix which is positive definite.
return matrixA.Transpose() * matrixA;
return matrixA.Transpose()*matrixA;
}
/// <summary>
@ -240,13 +236,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
{
// Fill a matrix with standard random numbers.
var normal = new Normal
{
RandomSource = new MersenneTwister(1)
};
{
RandomSource = new MersenneTwister(1)
};
var v = new UserDefinedVector(order);
for (var i = 0; i < order; i++)
{
v[i] = (float)normal.Sample();
v[i] = (float) normal.Sample();
}
// Generate a matrix which is positive definite.

Loading…
Cancel
Save