Browse Source

Unit Tests: extended vector arithmetic theories, confirming gh-20

la-knuth
Christoph Ruegg 15 years ago
parent
commit
69487d2775
  1. 44
      src/UnitTests/LinearAlgebraTests/Complex/VectorArithmeticTheory.cs
  2. 44
      src/UnitTests/LinearAlgebraTests/Complex32/VectorArithmeticTheory.cs
  3. 48
      src/UnitTests/LinearAlgebraTests/Double/VectorArithmeticTheory.cs
  4. 44
      src/UnitTests/LinearAlgebraTests/Single/VectorArithmeticTheory.cs

44
src/UnitTests/LinearAlgebraTests/Complex/VectorArithmeticTheory.cs

@ -88,6 +88,28 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
[Theory, Timeout(100)]
public void CanAddTwoVectorsInplace(Vector<Complex> a, Vector<Complex> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Add(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] + b[i]));
}
}
[Theory, Pairwise, Timeout(100)]
public void CanSubtractTwoVectorsUsingOperator(Vector<Complex> a, Vector<Complex> b)
{
@ -108,5 +130,27 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
[Theory, Timeout(100)]
public void CanSubtractTwoVectorsInplace(Vector<Complex> a, Vector<Complex> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Subtract(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
}
}

44
src/UnitTests/LinearAlgebraTests/Complex32/VectorArithmeticTheory.cs

@ -88,6 +88,28 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
[Theory, Timeout(100)]
public void CanAddTwoVectorsInplace(Vector<Complex32> a, Vector<Complex32> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Add(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] + b[i]));
}
}
[Theory, Pairwise, Timeout(100)]
public void CanSubtractTwoVectorsUsingOperator(Vector<Complex32> a, Vector<Complex32> b)
{
@ -108,5 +130,27 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
[Theory, Timeout(100)]
public void CanSubtractTwoVectorsInplace(Vector<Complex32> a, Vector<Complex32> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Subtract(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
}
}

48
src/UnitTests/LinearAlgebraTests/Double/VectorArithmeticTheory.cs

@ -66,7 +66,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
[Theory, Pairwise, Timeout(100)]
[Theory, Timeout(100)]
public void CanAddTwoVectorsUsingOperator(Vector<double> a, Vector<double> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
@ -87,7 +87,29 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
[Theory, Pairwise, Timeout(100)]
[Theory, Timeout(100)]
public void CanAddTwoVectorsInplace(Vector<double> a, Vector<double> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Add(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] + b[i]));
}
}
[Theory, Timeout(100)]
public void CanSubtractTwoVectorsUsingOperator(Vector<double> a, Vector<double> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
@ -107,5 +129,27 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
[Theory, Timeout(100)]
public void CanSubtractTwoVectorsInplace(Vector<double> a, Vector<double> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Subtract(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
}
}

44
src/UnitTests/LinearAlgebraTests/Single/VectorArithmeticTheory.cs

@ -87,6 +87,28 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
[Theory, Timeout(100)]
public void CanAddTwoVectorsInplace(Vector<float> a, Vector<float> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Add(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] + b[i]));
}
}
[Theory, Pairwise, Timeout(100)]
public void CanSubtractTwoVectorsUsingOperator(Vector<float> a, Vector<float> b)
{
@ -107,5 +129,27 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
[Theory, Timeout(100)]
public void CanSubtractTwoVectorsInplace(Vector<float> a, Vector<float> b)
{
Assume.That(a.Count, Is.EqualTo(b.Count));
var hasha = a.GetHashCode();
var hashb = b.GetHashCode();
var result = a.Clone();
result.Subtract(b, result);
Assert.That(a.GetHashCode(), Is.EqualTo(hasha));
Assert.That(b.GetHashCode(), Is.EqualTo(hashb));
Assert.That(result, Is.Not.SameAs(a));
Assert.That(result, Is.Not.SameAs(b));
for (var i = 0; i < Math.Min(a.Count, 20); i++)
{
Assert.That(result[i], Is.EqualTo(a[i] - b[i]));
}
}
}
}

Loading…
Cancel
Save