Browse Source

Alter parallelisation of matrix multiplication II - Unit Tests

v2
Christoph Ruegg 14 years ago
parent
commit
9fced67266
  1. 25
      src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs
  2. 26
      src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs
  3. 26
      src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs
  4. 26
      src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs

25
src/UnitTests/LinearAlgebraProviderTests/Complex/LinearAlgebraProviderTests.cs

@ -26,14 +26,15 @@
namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
{ {
using System;
using System.Collections.Generic;
using System.Numerics;
using Algorithms.LinearAlgebra; using Algorithms.LinearAlgebra;
using Distributions;
using LinearAlgebra.Complex; using LinearAlgebra.Complex;
using LinearAlgebra.Generic; using LinearAlgebra.Generic;
using LinearAlgebra.Generic.Factorization; using LinearAlgebra.Generic.Factorization;
using NUnit.Framework; using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Numerics;
/// <summary> /// <summary>
/// Base class for linear algebra provider tests. /// Base class for linear algebra provider tests.
@ -51,6 +52,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
/// </summary> /// </summary>
private readonly Complex[] _x = new[] { new Complex(6.6, 0), 7.7, 8.8, 9.9, 10.1 }; private readonly Complex[] _x = new[] { new Complex(6.6, 0), 7.7, 8.8, 9.9, 10.1 };
private static readonly IContinuousDistribution Dist = new Normal();
/// <summary> /// <summary>
/// Test matrix to use. /// Test matrix to use.
/// </summary> /// </summary>
@ -61,7 +64,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
{ "Square4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -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 } }) }, { "Square4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -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 DenseMatrix(new[,] { { new Complex(-1.1, 0), -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 } }) }, { "Singular4x4", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -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 DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, { "Tall3x2", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) },
{ "Wide2x3", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) } { "Wide2x3", new DenseMatrix(new[,] { { new Complex(-1.1, 0), -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) },
{ "Tall50000x10", DenseMatrix.CreateRandom(50000, 10, Dist) },
{ "Wide10x50000", DenseMatrix.CreateRandom(10, 50000, Dist) },
{ "Square1000x1000", DenseMatrix.CreateRandom(1000, 1000, Dist) }
}; };
/// <summary> /// <summary>
@ -1682,6 +1688,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex
AssertHelpers.AlmostEqual(test[1, 1], x[3], 14); AssertHelpers.AlmostEqual(test[1, 1], x[3], 14);
} }
[TestCase("Wide10x50000", "Tall50000x10")]
[TestCase("Square1000x1000", "Square1000x1000")]
[Timeout(1000 * 10)]
public void IsMatrixMultiplicationPerformant(string leftMatrixKey, string rightMatrixKey)
{
var leftMatrix = _matrices[leftMatrixKey];
var rightMatrix = _matrices[rightMatrixKey];
var result = leftMatrix * rightMatrix;
Assert.That(result, Is.Not.Null);
}
/// <summary> /// <summary>
/// Checks to see if a matrix and array contain the same values. /// Checks to see if a matrix and array contain the same values.
/// </summary> /// </summary>

26
src/UnitTests/LinearAlgebraProviderTests/Complex32/LinearAlgebraProviderTests.cs

@ -24,17 +24,17 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Generic.Factorization;
namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32 namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
{ {
using System;
using System.Collections.Generic;
using Algorithms.LinearAlgebra; using Algorithms.LinearAlgebra;
using Distributions;
using LinearAlgebra.Complex32; using LinearAlgebra.Complex32;
using LinearAlgebra.Generic; using LinearAlgebra.Generic;
using LinearAlgebra.Generic.Factorization;
using Numerics; using Numerics;
using NUnit.Framework; using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary> /// <summary>
/// Base class for linear algebra provider tests. /// Base class for linear algebra provider tests.
@ -52,6 +52,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
/// </summary> /// </summary>
private readonly Complex32[] _x = new[] { new Complex32(6.6f, 0f), 7.7f, 8.8f, 9.9f, 10.1f }; private readonly Complex32[] _x = new[] { new Complex32(6.6f, 0f), 7.7f, 8.8f, 9.9f, 10.1f };
private static readonly IContinuousDistribution Dist = new Normal();
/// <summary> /// <summary>
/// Test matrix to use. /// Test matrix to use.
/// </summary> /// </summary>
@ -62,7 +64,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
{ "Square4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -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 } }) }, { "Square4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -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 DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -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 } }) }, { "Singular4x4", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -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 DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) }, { "Tall3x2", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) },
{ "Wide2x3", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } }) } { "Wide2x3", new DenseMatrix(new[,] { { new Complex32(-1.1f, 0.0f), -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } }) },
{ "Tall50000x10", DenseMatrix.CreateRandom(50000, 10, Dist) },
{ "Wide10x50000", DenseMatrix.CreateRandom(10, 50000, Dist) },
{ "Square1000x1000", DenseMatrix.CreateRandom(1000, 1000, Dist) }
}; };
/// <summary> /// <summary>
@ -1692,6 +1697,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Complex32
AssertHelpers.AlmostEqual(test[1, 1], x[3], 5); AssertHelpers.AlmostEqual(test[1, 1], x[3], 5);
} }
[TestCase("Wide10x50000", "Tall50000x10")]
[TestCase("Square1000x1000", "Square1000x1000")]
[Timeout(1000 * 10)]
public void IsMatrixMultiplicationPerformant(string leftMatrixKey, string rightMatrixKey)
{
var leftMatrix = _matrices[leftMatrixKey];
var rightMatrix = _matrices[rightMatrixKey];
var result = leftMatrix * rightMatrix;
Assert.That(result, Is.Not.Null);
}
/// <summary> /// <summary>
/// Checks to see if a matrix and array contain the same values. /// Checks to see if a matrix and array contain the same values.
/// </summary> /// </summary>

26
src/UnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs

@ -24,16 +24,16 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Generic.Factorization;
namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{ {
using System;
using System.Collections.Generic;
using Algorithms.LinearAlgebra; using Algorithms.LinearAlgebra;
using Distributions;
using LinearAlgebra.Double; using LinearAlgebra.Double;
using LinearAlgebra.Generic; using LinearAlgebra.Generic;
using LinearAlgebra.Generic.Factorization;
using NUnit.Framework; using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary> /// <summary>
/// Base class for linear algebra provider tests. /// Base class for linear algebra provider tests.
@ -51,6 +51,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
/// </summary> /// </summary>
private readonly double[] _x = new[] { 6.6, 7.7, 8.8, 9.9, 10.1 }; private readonly double[] _x = new[] { 6.6, 7.7, 8.8, 9.9, 10.1 };
private static readonly IContinuousDistribution Dist = new Normal();
/// <summary> /// <summary>
/// Test matrix to use. /// Test matrix to use.
/// </summary> /// </summary>
@ -61,7 +63,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
{ "Square4x4", new DenseMatrix(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 } }) }, { "Square4x4", new DenseMatrix(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 DenseMatrix(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 } }) }, { "Singular4x4", new DenseMatrix(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 DenseMatrix(new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) }, { "Tall3x2", new DenseMatrix(new[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } }) },
{ "Wide2x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) } { "Wide2x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } }) },
{ "Tall50000x10", DenseMatrix.CreateRandom(50000, 10, Dist) },
{ "Wide10x50000", DenseMatrix.CreateRandom(10, 50000, Dist) },
{ "Square1000x1000", DenseMatrix.CreateRandom(1000, 1000, Dist) }
}; };
/// <summary> /// <summary>
@ -1684,6 +1689,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double
AssertHelpers.AlmostEqual(test[1, 1], x[3], 14); AssertHelpers.AlmostEqual(test[1, 1], x[3], 14);
} }
[TestCase("Wide10x50000", "Tall50000x10")]
[TestCase("Square1000x1000", "Square1000x1000")]
[Timeout(1000 * 10)]
public void IsMatrixMultiplicationPerformant(string leftMatrixKey, string rightMatrixKey)
{
var leftMatrix = _matrices[leftMatrixKey];
var rightMatrix = _matrices[rightMatrixKey];
var result = leftMatrix*rightMatrix;
Assert.That(result, Is.Not.Null);
}
/// <summary> /// <summary>
/// Checks to see if a matrix and array contain the same values. /// Checks to see if a matrix and array contain the same values.
/// </summary> /// </summary>

26
src/UnitTests/LinearAlgebraProviderTests/Single/LinearAlgebraProviderTests.cs

@ -24,16 +24,16 @@
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
// </copyright> // </copyright>
using MathNet.Numerics.LinearAlgebra.Generic.Factorization;
namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single
{ {
using System;
using System.Collections.Generic;
using Algorithms.LinearAlgebra; using Algorithms.LinearAlgebra;
using Distributions;
using LinearAlgebra.Generic; using LinearAlgebra.Generic;
using LinearAlgebra.Generic.Factorization;
using LinearAlgebra.Single; using LinearAlgebra.Single;
using NUnit.Framework; using NUnit.Framework;
using System;
using System.Collections.Generic;
/// <summary> /// <summary>
/// Base class for linear algebra provider tests. /// Base class for linear algebra provider tests.
@ -51,6 +51,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single
/// </summary> /// </summary>
private readonly float[] _x = new[] { 6.6f, 7.7f, 8.8f, 9.9f, 10.1f }; private readonly float[] _x = new[] { 6.6f, 7.7f, 8.8f, 9.9f, 10.1f };
private static readonly IContinuousDistribution Dist = new Normal();
/// <summary> /// <summary>
/// Test matrix to use. /// Test matrix to use.
/// </summary> /// </summary>
@ -61,7 +63,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single
{ "Square4x4", new DenseMatrix(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 } }) }, { "Square4x4", new DenseMatrix(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 DenseMatrix(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 } }) }, { "Singular4x4", new DenseMatrix(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 DenseMatrix(new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) }, { "Tall3x2", new DenseMatrix(new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } }) },
{ "Wide2x3", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } }) } { "Wide2x3", new DenseMatrix(new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } }) },
{ "Tall50000x10", DenseMatrix.CreateRandom(50000, 10, Dist) },
{ "Wide10x50000", DenseMatrix.CreateRandom(10, 50000, Dist) },
{ "Square1000x1000", DenseMatrix.CreateRandom(1000, 1000, Dist) }
}; };
/// <summary> /// <summary>
@ -1691,6 +1696,17 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Single
AssertHelpers.AlmostEqual(test[1, 1], x[3], 6); AssertHelpers.AlmostEqual(test[1, 1], x[3], 6);
} }
[TestCase("Wide10x50000", "Tall50000x10")]
[TestCase("Square1000x1000", "Square1000x1000")]
[Timeout(1000 * 10)]
public void IsMatrixMultiplicationPerformant(string leftMatrixKey, string rightMatrixKey)
{
var leftMatrix = _matrices[leftMatrixKey];
var rightMatrix = _matrices[rightMatrixKey];
var result = leftMatrix * rightMatrix;
Assert.That(result, Is.Not.Null);
}
/// <summary> /// <summary>
/// Checks to see if a matrix and array contain the same values. /// Checks to see if a matrix and array contain the same values.
/// </summary> /// </summary>

Loading…
Cancel
Save