diff --git a/MathNet.Numerics.sln.DotSettings b/MathNet.Numerics.sln.DotSettings
index 6cec424b..d4811bc7 100644
--- a/MathNet.Numerics.sln.DotSettings
+++ b/MathNet.Numerics.sln.DotSettings
@@ -102,6 +102,7 @@ OTHER DEALINGS IN THE SOFTWARE.
SVD
TFQMR
WH
+ True
True
True
<data />
diff --git a/src/UnitTests/LinearAlgebraTests/Build.cs b/src/UnitTests/LinearAlgebraTests/Build.cs
deleted file mode 100644
index ce254596..00000000
--- a/src/UnitTests/LinearAlgebraTests/Build.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// Math.NET Numerics, part of the Math.NET Project
-// http://numerics.mathdotnet.com
-// http://github.com/mathnet/mathnet-numerics
-// http://mathnetnumerics.codeplex.com
-//
-// Copyright (c) 2009-2014 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
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// 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
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections.Generic;
-using MathNet.Numerics.LinearAlgebra.Storage;
-
-namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
-{
- public enum VectorStorageType
- {
- DenseVector = 1,
- SparseVector = 2
- }
-
- public static class Build
- {
- public static VectorStorage VectorStorage(VectorStorageType type, IEnumerable data)
- where T : struct, IEquatable, IFormattable
- {
- switch (type)
- {
- case VectorStorageType.DenseVector:
- return DenseVectorStorage.OfEnumerable(data);
- case VectorStorageType.SparseVector:
- return SparseVectorStorage.OfEnumerable(data);
- default:
- throw new NotSupportedException();
- }
- }
-
- public static VectorStorage VectorStorage(VectorStorageType type, int length)
- where T : struct, IEquatable, IFormattable
- {
- switch (type)
- {
- case VectorStorageType.DenseVector:
- return new DenseVectorStorage(length);
- case VectorStorageType.SparseVector:
- return new SparseVectorStorage(length);
- default:
- throw new NotSupportedException();
- }
- }
- }
-}
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs
index 1019d529..8b3c6622 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs
@@ -42,9 +42,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[TestFixture, Category("LA")]
public class MatrixStructureTheory : MatrixStructureTheory
{
- protected override Matrix GetMatrix(TestMatrix matrix)
+ protected override Matrix Get(TestMatrix matrix)
{
- return TestData.GetMatrix(matrix);
+ return TestData.Matrix(matrix);
}
[Datapoints]
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/TestData.cs b/src/UnitTests/LinearAlgebraTests/Complex/TestData.cs
index fe2e826a..b93a7e89 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/TestData.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/TestData.cs
@@ -44,7 +44,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
static readonly MatrixBuilder M = Matrix.Build;
static readonly VectorBuilder V = Vector.Build;
- public static Matrix GetMatrix(TestMatrix matrix)
+ public static Matrix Matrix(TestMatrix matrix)
{
switch (matrix)
{
@@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
}
}
- public static Vector GetVector(TestVector vector)
+ public static Vector Vector(TestVector vector)
{
switch (vector)
{
diff --git a/src/UnitTests/LinearAlgebraTests/Complex/VectorArithmeticTheory.cs b/src/UnitTests/LinearAlgebraTests/Complex/VectorArithmeticTheory.cs
index 5f39a0fa..ebbef2ef 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex/VectorArithmeticTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex/VectorArithmeticTheory.cs
@@ -42,14 +42,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex
[TestFixture, Category("LA")]
public class VectorArithmeticTheory : VectorArithmeticTheory
{
- protected override Vector GetVector(TestVector vector)
+ protected override Vector Get(TestVector vector)
{
- return TestData.GetVector(vector);
+ return TestData.Vector(vector);
}
- protected override Complex Minus(Complex value) { return -value; }
- protected override Complex Add(Complex first, Complex second) { return first + second; }
-
[Datapoints]
TestVector[] _vectors =
{
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs
index 9778f5d8..c1353487 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs
@@ -38,9 +38,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[TestFixture, Category("LA")]
public class MatrixStructureTheory : MatrixStructureTheory
{
- protected override Matrix GetMatrix(TestMatrix matrix)
+ protected override Matrix Get(TestMatrix matrix)
{
- return TestData.GetMatrix(matrix);
+ return TestData.Matrix(matrix);
}
[Datapoints]
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/TestData.cs b/src/UnitTests/LinearAlgebraTests/Complex32/TestData.cs
index ef4ca885..c778d042 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/TestData.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/TestData.cs
@@ -40,7 +40,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
static readonly MatrixBuilder M = Matrix.Build;
static readonly VectorBuilder V = Vector.Build;
- public static Matrix GetMatrix(TestMatrix matrix)
+ public static Matrix Matrix(TestMatrix matrix)
{
switch (matrix)
{
@@ -65,7 +65,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
}
}
- public static Vector GetVector(TestVector vector)
+ public static Vector Vector(TestVector vector)
{
switch (vector)
{
diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/VectorArithmeticTheory.cs b/src/UnitTests/LinearAlgebraTests/Complex32/VectorArithmeticTheory.cs
index d5a4010d..3dee3244 100644
--- a/src/UnitTests/LinearAlgebraTests/Complex32/VectorArithmeticTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Complex32/VectorArithmeticTheory.cs
@@ -38,14 +38,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32
[TestFixture, Category("LA")]
public class VectorArithmeticTheory : VectorArithmeticTheory
{
- protected override Vector GetVector(TestVector vector)
+ protected override Vector Get(TestVector vector)
{
- return TestData.GetVector(vector);
+ return TestData.Vector(vector);
}
- protected override Complex32 Minus(Complex32 value) { return -value; }
- protected override Complex32 Add(Complex32 first, Complex32 second) { return first + second; }
-
[Datapoints]
TestVector[] _vectors =
{
diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs
index 3dde825a..83e59d4e 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs
@@ -36,9 +36,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[TestFixture, Category("LA")]
public class MatrixStructureTheory : MatrixStructureTheory
{
- protected override Matrix GetMatrix(TestMatrix matrix)
+ protected override Matrix Get(TestMatrix matrix)
{
- return TestData.GetMatrix(matrix);
+ return TestData.Matrix(matrix);
}
[Datapoints]
diff --git a/src/UnitTests/LinearAlgebraTests/Double/TestData.cs b/src/UnitTests/LinearAlgebraTests/Double/TestData.cs
index 4a406451..012d22c0 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/TestData.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/TestData.cs
@@ -38,7 +38,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
static readonly MatrixBuilder M = Matrix.Build;
static readonly VectorBuilder V = Vector.Build;
- public static Matrix GetMatrix(TestMatrix matrix)
+ public static Matrix Matrix(TestMatrix matrix)
{
switch (matrix)
{
@@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
}
}
- public static Vector GetVector(TestVector vector)
+ public static Vector Vector(TestVector vector)
{
switch (vector)
{
diff --git a/src/UnitTests/LinearAlgebraTests/Double/VectorArithmeticTheory.cs b/src/UnitTests/LinearAlgebraTests/Double/VectorArithmeticTheory.cs
index 756b4780..e4ca083f 100644
--- a/src/UnitTests/LinearAlgebraTests/Double/VectorArithmeticTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Double/VectorArithmeticTheory.cs
@@ -36,14 +36,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double
[TestFixture, Category("LA")]
public class VectorArithmeticTheory : VectorArithmeticTheory
{
- protected override Vector GetVector(TestVector vector)
+ protected override Vector Get(TestVector vector)
{
- return TestData.GetVector(vector);
+ return TestData.Vector(vector);
}
- protected override double Minus(double value) { return -value; }
- protected override double Add(double first, double second) { return first + second; }
-
[Datapoints]
TestVector[] _vectors =
{
diff --git a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Access.cs b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Access.cs
index 63af3fe5..af96d042 100644
--- a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Access.cs
+++ b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Access.cs
@@ -39,7 +39,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetFieldsByIndex(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assert.That(() => matrix[0, 0], Throws.Nothing);
Assert.That(() => matrix[0, matrix.ColumnCount - 1], Throws.Nothing);
@@ -53,7 +53,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetRow(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Row
var firstrow = matrix.Row(0);
@@ -79,7 +79,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetRowIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var row = Vector.Build.Dense(matrix.ColumnCount);
matrix.Row(0, row);
@@ -97,7 +97,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetRowWithRange(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Row, Columns 0..1
var firstrow = matrix.Row(0, 0, 2);
@@ -134,7 +134,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetRowWithRangeIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var row = Vector.Build.Dense(matrix.ColumnCount - 1);
matrix.Row(0, 1, matrix.ColumnCount - 1, row);
@@ -153,7 +153,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetColumn(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Column
var firstcol = matrix.Column(0);
@@ -179,7 +179,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetColumnIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var col = Vector.Build.Dense(matrix.RowCount);
matrix.Column(0, col);
@@ -197,7 +197,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetColumnWithRange(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Column, Rows 0..1
var firstcol = matrix.Column(0, 0, 2);
@@ -234,7 +234,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetColumnWithRangeIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var col = Vector.Build.Dense(matrix.RowCount - 1);
matrix.Column(0, 1, matrix.RowCount - 1, col);
@@ -253,7 +253,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetRow(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Row
var m = matrix.Clone();
@@ -290,7 +290,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetRowArray(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Row
var m = matrix.Clone();
@@ -325,7 +325,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetColumn(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Column
var m = matrix.Clone();
@@ -362,7 +362,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetColumnArray(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// First Column
var m = matrix.Clone();
@@ -397,7 +397,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetUpperTriangle(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var upper = matrix.UpperTriangle();
for (var i = 0; i < matrix.RowCount; i++)
@@ -412,7 +412,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetUpperTriangleIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var dense = Matrix.Build.Dense(matrix.RowCount, matrix.ColumnCount);
matrix.UpperTriangle(dense);
@@ -442,7 +442,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetLowerTriangle(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var upper = matrix.LowerTriangle();
for (var i = 0; i < matrix.RowCount; i++)
@@ -457,7 +457,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetLowerTriangleIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var dense = Matrix.Build.Dense(matrix.RowCount, matrix.ColumnCount);
matrix.LowerTriangle(dense);
@@ -487,7 +487,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetStrictlyUpperTriangle(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var upper = matrix.StrictlyUpperTriangle();
for (var i = 0; i < matrix.RowCount; i++)
@@ -502,7 +502,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetStrictlyUpperTriangleIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var dense = Matrix.Build.Dense(matrix.RowCount, matrix.ColumnCount);
matrix.StrictlyUpperTriangle(dense);
@@ -532,7 +532,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetStrictlyLowerTriangle(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var upper = matrix.StrictlyLowerTriangle();
for (var i = 0; i < matrix.RowCount; i++)
@@ -547,7 +547,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetStrictlyLowerTriangleIntoResult(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var dense = Matrix.Build.Dense(matrix.RowCount, matrix.ColumnCount);
matrix.StrictlyLowerTriangle(dense);
@@ -577,7 +577,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetDiagonal(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var diag = matrix.Diagonal();
Assert.That(diag.Count, Is.EqualTo(Math.Min(matrix.RowCount, matrix.ColumnCount)));
@@ -590,7 +590,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetDiagonal(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var m = matrix.Clone();
var v = CreateVectorFor(m, Math.Min(matrix.RowCount, matrix.ColumnCount));
@@ -612,7 +612,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetDiagonalArray(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var m = matrix.Clone();
m.SetDiagonal(new T[Math.Min(matrix.RowCount, matrix.ColumnCount)]);
@@ -633,7 +633,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetSubmatrix(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// Top Left Corner 2x2
var topleft = matrix.SubMatrix(0, 2, 0, 2);
@@ -677,7 +677,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanSetSubmatrix(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// Top Left Corner 2x2
var topleft = CreateDenseFor(matrix, 2, 2);
diff --git a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs
index bd1b133e..72211716 100644
--- a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs
+++ b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Functional.cs
@@ -39,7 +39,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMap(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Matrix a = matrix.Map(x => x, Zeros.AllowSkip);
Assert.That(a, Is.EqualTo(matrix));
Assert.That(a.Storage.IsDense, Is.EqualTo(matrix.Storage.IsDense));
@@ -68,7 +68,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMapIndexed(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Matrix a = matrix.MapIndexed((i, j, x) =>
{
if (i != 0 || j != 1) Assert.That(matrix.At(i, j), Is.EqualTo(x));
@@ -105,7 +105,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMapInplace(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var a = matrix.Clone();
a.MapInplace(x => x, Zeros.AllowSkip);
Assert.That(a, Is.EqualTo(matrix));
@@ -124,7 +124,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMapIndexedInplace(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var a = matrix.Clone();
a.MapIndexedInplace((i, j, x) =>
{
@@ -152,7 +152,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMapSubMatrixToSame(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
T one = Matrix.Build.One;
// Full Range - not forced
@@ -176,7 +176,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMapSubMatrixToDense(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
T one = Matrix.Build.One;
// Full Range - not forced
@@ -217,7 +217,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanMapSubMatrixToSparse(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
T one = Matrix.Build.One;
// Full Range - filled, not forced
@@ -267,7 +267,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanFoldRows(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// not forced
T[] rowSum = matrix.FoldByRow((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.AllowSkip);
@@ -290,7 +290,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanFoldColumns(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
// not forced
T[] colSum = matrix.FoldByColumn((s, x) => Operator.Add(s, x), Operator.Zero, Zeros.AllowSkip);
@@ -313,7 +313,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanFold2(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var other = -matrix;
other.Multiply(Operator.Convert(2), other);
diff --git a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Reform.cs b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Reform.cs
index d68d6801..52f5e1e6 100644
--- a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Reform.cs
+++ b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.Reform.cs
@@ -40,19 +40,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanPermuteRows(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
+ Assume.That(matrix.Storage.IsFullyMutable);
+
var m = matrix.Clone();
var rnd = new System.Random(0);
var permutation = new Permutation(Enumerable.Range(0, matrix.RowCount).OrderBy(i => rnd.Next()).ToArray());
- try
- {
- m.PermuteRows(permutation);
- }
- catch (InvalidOperationException)
- {
- Assert.Ignore("Matrix type {0} does not support permutations", matrix.GetType().FullName);
- }
+ m.PermuteRows(permutation);
Assert.That(m, Is.Not.SameAs(matrix));
Assert.That(m.RowCount, Is.EqualTo(matrix.RowCount));
@@ -70,19 +65,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanPermuteColumns(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
+ Assume.That(matrix.Storage.IsFullyMutable);
+
var m = matrix.Clone();
var rnd = new System.Random(0);
var permutation = new Permutation(Enumerable.Range(0, matrix.ColumnCount).OrderBy(i => rnd.Next()).ToArray());
- try
- {
- m.PermuteColumns(permutation);
- }
- catch (InvalidOperationException)
- {
- Assert.Ignore("Matrix type {0} does not support permutations", matrix.GetType().FullName);
- }
+ m.PermuteColumns(permutation);
Assert.That(m, Is.Not.SameAs(matrix));
Assert.That(m.RowCount, Is.EqualTo(matrix.RowCount));
@@ -100,7 +90,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanInsertRow(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var row = Vector.Build.Random(matrix.ColumnCount, 0);
for (var position = 0; position < matrix.RowCount + 1; position++)
{
@@ -137,7 +127,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanRemoveRow(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
for (var position = 0; position < matrix.RowCount; position++)
{
var result = matrix.RemoveRow(position);
@@ -162,7 +152,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanInsertColumn(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var column = Vector.Build.Random(matrix.RowCount, 0);
for (var position = 0; position < matrix.ColumnCount + 1; position++)
{
@@ -199,7 +189,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanRemoveColumn(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
for (var position = 0; position < matrix.ColumnCount; position++)
{
var result = matrix.RemoveColumn(position);
@@ -225,10 +215,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanAppend(TestMatrix leftTestMatrix, TestMatrix rightTestMatrix)
{
- Matrix left = GetMatrix(leftTestMatrix);
- Matrix right = GetMatrix(rightTestMatrix);
-
- // IF
+ Matrix left = Get(leftTestMatrix);
+ Matrix right = Get(rightTestMatrix);
Assume.That(left.RowCount, Is.EqualTo(right.RowCount));
// THEN
@@ -250,10 +238,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanAppendIntoResult(TestMatrix leftTestMatrix, TestMatrix rightTestMatrix)
{
- Matrix left = GetMatrix(leftTestMatrix);
- Matrix right = GetMatrix(rightTestMatrix);
-
- // IF
+ Matrix left = Get(leftTestMatrix);
+ Matrix right = Get(rightTestMatrix);
Assume.That(left.RowCount, Is.EqualTo(right.RowCount));
// THEN
@@ -280,8 +266,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanStack(TestMatrix topTestMatrix, TestMatrix bottomTestMatrix)
{
- Matrix top = GetMatrix(topTestMatrix);
- Matrix bottom = GetMatrix(bottomTestMatrix);
+ Matrix top = Get(topTestMatrix);
+ Matrix bottom = Get(bottomTestMatrix);
// IF
Assume.That(top.ColumnCount, Is.EqualTo(bottom.ColumnCount));
@@ -305,10 +291,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanStackIntoResult(TestMatrix topTestMatrix, TestMatrix bottomTestMatrix)
{
- Matrix top = GetMatrix(topTestMatrix);
- Matrix bottom = GetMatrix(bottomTestMatrix);
-
- // IF
+ Matrix top = Get(topTestMatrix);
+ Matrix bottom = Get(bottomTestMatrix);
Assume.That(top.ColumnCount, Is.EqualTo(bottom.ColumnCount));
// THEN
@@ -335,8 +319,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanDiagonalStack(TestMatrix leftTestMatrix, TestMatrix rightTestMatrix)
{
- Matrix left = GetMatrix(leftTestMatrix);
- Matrix right = GetMatrix(rightTestMatrix);
+ Matrix left = Get(leftTestMatrix);
+ Matrix right = Get(rightTestMatrix);
var result = left.DiagonalStack(right);
@@ -364,8 +348,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanDiagonalStackIntoResult(TestMatrix leftTestMatrix, TestMatrix rightTestMatrix)
{
- Matrix left = GetMatrix(leftTestMatrix);
- Matrix right = GetMatrix(rightTestMatrix);
+ Matrix left = Get(leftTestMatrix);
+ Matrix right = Get(rightTestMatrix);
var result = Matrix.Build.Dense(left.RowCount + right.RowCount, left.ColumnCount + right.ColumnCount);
left.DiagonalStack(right, result);
diff --git a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs
index 20a8bf80..44e5348a 100644
--- a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs
@@ -39,7 +39,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
public abstract partial class MatrixStructureTheory
where T : struct, IEquatable, IFormattable
{
- protected abstract Matrix GetMatrix(TestMatrix matrix);
+ protected abstract Matrix Get(TestMatrix matrix);
protected readonly T Zero = Matrix.Build.Zero;
@@ -60,7 +60,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void IsEqualToItself(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assert.That(matrix, Is.EqualTo(matrix));
Assert.IsTrue(matrix.Equals(matrix));
Assert.IsTrue(matrix.Equals((object)matrix));
@@ -72,10 +72,8 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void IsNotEqualToOthers(TestMatrix leftTestMatrix, TestMatrix rightTestmatrix)
{
- Matrix left = GetMatrix(leftTestMatrix);
- Matrix right = GetMatrix(rightTestmatrix);
-
- // IF (assuming we don't have duplicate data points)
+ Matrix left = Get(leftTestMatrix);
+ Matrix right = Get(rightTestmatrix);
Assume.That(leftTestMatrix, Is.Not.EqualTo(rightTestmatrix));
// THEN
@@ -90,7 +88,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void IsNotEqualToPermutation(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
if (!matrix.Storage.IsFullyMutable)
{
return;
@@ -123,7 +121,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void IsNotEqualToNonMatrixType(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assert.That(matrix, Is.Not.EqualTo(2));
Assert.IsFalse(matrix.Equals(2));
Assert.IsFalse(matrix.Equals((object)2));
@@ -134,7 +132,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanClone(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var clone = matrix.Clone();
Assert.That(clone, Is.Not.SameAs(matrix));
Assert.That(clone, Is.EqualTo(matrix));
@@ -146,7 +144,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanCloneUsingICloneable(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var clone = (Matrix)((ICloneable)matrix).Clone();
Assert.That(clone, Is.Not.SameAs(matrix));
Assert.That(clone, Is.EqualTo(matrix));
@@ -158,7 +156,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanCopyTo(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var dense = Matrix.Build.Dense(matrix.RowCount, matrix.ColumnCount);
matrix.CopyTo(dense);
Assert.That(dense, Is.EqualTo(matrix));
@@ -178,14 +176,14 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanGetHashCode(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assert.That(matrix.GetHashCode(), Is.Not.EqualTo(Matrix.Build.SameAs(matrix).GetHashCode()));
}
[Theory]
public void CanClear(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var cleared = matrix.Clone();
cleared.Clear();
Assert.That(cleared, Is.EqualTo(Matrix.Build.SameAs(matrix)));
@@ -194,7 +192,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanClearSubMatrix(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assume.That(matrix.RowCount, Is.GreaterThanOrEqualTo(2));
Assume.That(matrix.ColumnCount, Is.GreaterThanOrEqualTo(2));
@@ -209,7 +207,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanClearRows(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assume.That(matrix.RowCount, Is.GreaterThanOrEqualTo(2));
var cleared = matrix.Clone();
@@ -221,7 +219,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanClearColumns(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
Assume.That(matrix.ColumnCount, Is.GreaterThanOrEqualTo(2));
var cleared = matrix.Clone();
@@ -233,7 +231,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanToArray(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var array = matrix.ToArray();
Assert.That(array.GetLength(0), Is.EqualTo(matrix.RowCount));
Assert.That(array.GetLength(1), Is.EqualTo(matrix.ColumnCount));
@@ -249,7 +247,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanToColumnArrays(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var columnArrays = matrix.ToColumnArrays();
Assert.That(columnArrays.Length, Is.EqualTo(matrix.ColumnCount));
Assert.That(columnArrays[0].Length, Is.EqualTo(matrix.RowCount));
@@ -265,7 +263,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanToRowArrays(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var rowArrays = matrix.ToRowArrays();
Assert.That(rowArrays.Length, Is.EqualTo(matrix.RowCount));
Assert.That(rowArrays[0].Length, Is.EqualTo(matrix.ColumnCount));
@@ -281,7 +279,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanToColumnWiseArray(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var array = matrix.ToColumnWiseArray();
Assert.That(array.Length, Is.EqualTo(matrix.RowCount*matrix.ColumnCount));
for (int i = 0; i < array.Length; i++)
@@ -293,7 +291,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanToRowWiseArray(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var array = matrix.ToRowWiseArray();
Assert.That(array.Length, Is.EqualTo(matrix.RowCount*matrix.ColumnCount));
for (int i = 0; i < array.Length; i++)
@@ -305,7 +303,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
[Theory]
public void CanCreateSameKind(TestMatrix testMatrix)
{
- Matrix matrix = GetMatrix(testMatrix);
+ Matrix matrix = Get(testMatrix);
var empty = Matrix.Build.SameAs(matrix, 5, 6);
Assert.That(empty, Is.EqualTo(Matrix.Build.Dense(5, 6)));
Assert.That(empty.Storage.IsDense, Is.EqualTo(matrix.Storage.IsDense));
diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs
index 6328cc61..26c515a2 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs
@@ -36,9 +36,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
[TestFixture, Category("LA")]
public class MatrixStructureTheory : MatrixStructureTheory
{
- protected override Matrix GetMatrix(TestMatrix matrix)
+ protected override Matrix Get(TestMatrix matrix)
{
- return TestData.GetMatrix(matrix);
+ return TestData.Matrix(matrix);
}
[Datapoints]
diff --git a/src/UnitTests/LinearAlgebraTests/Single/TestData.cs b/src/UnitTests/LinearAlgebraTests/Single/TestData.cs
index 112fd3a2..bec07a26 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/TestData.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/TestData.cs
@@ -38,7 +38,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
static readonly MatrixBuilder M = Matrix.Build;
static readonly VectorBuilder V = Vector.Build;
- public static Matrix GetMatrix(TestMatrix matrix)
+ public static Matrix Matrix(TestMatrix matrix)
{
switch (matrix)
{
@@ -63,7 +63,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
}
}
- public static Vector GetVector(TestVector vector)
+ public static Vector Vector(TestVector vector)
{
switch (vector)
{
diff --git a/src/UnitTests/LinearAlgebraTests/Single/VectorArithmeticTheory.cs b/src/UnitTests/LinearAlgebraTests/Single/VectorArithmeticTheory.cs
index c550a92f..d7b4096d 100644
--- a/src/UnitTests/LinearAlgebraTests/Single/VectorArithmeticTheory.cs
+++ b/src/UnitTests/LinearAlgebraTests/Single/VectorArithmeticTheory.cs
@@ -36,14 +36,11 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single
[TestFixture, Category("LA")]
public class VectorArithmeticTheory : VectorArithmeticTheory
{
- protected override Vector GetVector(TestVector vector)
+ protected override Vector Get(TestVector vector)
{
- return TestData.GetVector(vector);
+ return TestData.Vector(vector);
}
- protected override float Minus(float value) { return -value; }
- protected override float Add(float first, float second) { return first + second; }
-
[Datapoints]
TestVector[] _vectors =
{
diff --git a/src/UnitTests/LinearAlgebraTests/TestData.cs b/src/UnitTests/LinearAlgebraTests/TestData.cs
index d9c23a46..a9f65b8c 100644
--- a/src/UnitTests/LinearAlgebraTests/TestData.cs
+++ b/src/UnitTests/LinearAlgebraTests/TestData.cs
@@ -28,6 +28,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+using System;
+using System.Collections.Generic;
+using MathNet.Numerics.LinearAlgebra.Storage;
+
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
{
public enum TestMatrix
@@ -50,6 +54,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
UserSquare3x3
}
+ public enum TestMatrixStorage
+ {
+ DenseMatrix = 1,
+ SparseMatrix = 2,
+ DiagonalMatrix = 3
+ }
+
public enum TestVector
{
Dense5,
@@ -60,4 +71,41 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests
Sparse5AllZeros,
SparseMaxLengthAllZeros
}
+
+ public enum TestVectorStorage
+ {
+ DenseVector = 1,
+ SparseVector = 2
+ }
+
+ public static class TestData
+ {
+ public static VectorStorage VectorStorage(TestVectorStorage type, IEnumerable data)
+ where T : struct, IEquatable, IFormattable
+ {
+ switch (type)
+ {
+ case TestVectorStorage.DenseVector:
+ return DenseVectorStorage.OfEnumerable(data);
+ case TestVectorStorage.SparseVector:
+ return SparseVectorStorage.OfEnumerable(data);
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
+ public static VectorStorage VectorStorage(TestVectorStorage type, int length)
+ where T : struct, IEquatable, IFormattable
+ {
+ switch (type)
+ {
+ case TestVectorStorage.DenseVector:
+ return new DenseVectorStorage