diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs index 14d34ea8..cb2017ca 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixStructureTheory.cs @@ -46,11 +46,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex [TestFixture] public class MatrixStructureTheory : MatrixStructureTheory { - public MatrixStructureTheory() - : base(Complex.Zero, typeof(DenseMatrix), typeof(SparseMatrix), typeof(DiagonalMatrix), typeof(DenseVector), typeof(SparseVector)) - { - } - [Datapoints] Matrix[] _matrices = new Matrix[] { diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs index 1a2eb3bb..7dcf249f 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixStructureTheory.cs @@ -42,11 +42,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 [TestFixture] public class MatrixStructureTheory : MatrixStructureTheory { - public MatrixStructureTheory() - : base(Complex32.Zero, typeof(DenseMatrix), typeof(SparseMatrix), typeof(DiagonalMatrix), typeof(DenseVector), typeof(SparseVector)) - { - } - [Datapoints] Matrix[] _matrices = new Matrix[] { diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs index 043ef7cc..7b083e37 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixStructureTheory.cs @@ -40,11 +40,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double [TestFixture] public class MatrixStructureTheory : MatrixStructureTheory { - public MatrixStructureTheory() - : base(0d, typeof (DenseMatrix), typeof (SparseMatrix), typeof (DiagonalMatrix), typeof (DenseVector), typeof (SparseVector)) - { - } - [Datapoints] Matrix[] _matrices = new Matrix[] { diff --git a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs index 158a31c5..76b69f33 100644 --- a/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs +++ b/src/UnitTests/LinearAlgebraTests/MatrixStructureTheory.cs @@ -45,20 +45,10 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests protected abstract Vector CreateVectorRandom(int size, int seed); protected readonly T Zero; - protected readonly dynamic Dense; - protected readonly dynamic Sparse; - protected readonly dynamic Diagonal; - protected readonly dynamic DenseVector; - protected readonly dynamic SparseVector; - protected MatrixStructureTheory(T zero, Type dense, Type sparse, Type diagonal, Type denseVector, Type sparseVector) + protected MatrixStructureTheory() { - Zero = zero; - Dense = new StaticDynamicWrapper(dense); - Sparse = new StaticDynamicWrapper(sparse); - Diagonal = new StaticDynamicWrapper(diagonal); - DenseVector = new StaticDynamicWrapper(denseVector); - SparseVector = new StaticDynamicWrapper(sparseVector); + Zero = Matrix.Build.Zero; } protected Matrix CreateDenseFor(Matrix m, int rows = -1, int columns = -1, int seed = 1) @@ -233,7 +223,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests public void CanCreateDenseFromMultiDimArray() { T[,] array = CreateDenseRandom(4, 3, 0).ToArray(); - var matrix = Dense.OfArray(array); + var matrix = Matrix.Build.DenseOfArray(array); Assert.That(matrix.GetType().Name, Is.EqualTo("DenseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(4)); Assert.That(matrix.ColumnCount, Is.EqualTo(3)); @@ -246,7 +236,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests public void CanCreateSparseFromMultiDimArray() { T[,] array = CreateDenseRandom(4, 3, 0).ToArray(); - var matrix = Sparse.OfArray(array); + var matrix = Matrix.Build.SparseOfArray(array); Assert.That(matrix.GetType().Name, Is.EqualTo("SparseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(4)); Assert.That(matrix.ColumnCount, Is.EqualTo(3)); @@ -264,7 +254,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests CreateVectorRandom(4, 1).ToArray(), CreateVectorRandom(4, 3).ToArray() }; - var matrix = Dense.OfRows(3, 4, array); + var matrix = Matrix.Build.DenseOfRows(3, 4, array); Assert.That(matrix.GetType().Name, Is.EqualTo("DenseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(3)); Assert.That(matrix.ColumnCount, Is.EqualTo(4)); @@ -282,7 +272,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests CreateVectorRandom(4, 1).ToArray(), CreateVectorRandom(4, 3).ToArray() }; - var matrix = Sparse.OfRows(3, 4, array); + var matrix = Matrix.Build.SparseOfRows(3, 4, array); Assert.That(matrix.GetType().Name, Is.EqualTo("SparseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(3)); Assert.That(matrix.ColumnCount, Is.EqualTo(4)); @@ -300,7 +290,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests CreateVectorRandom(4, 1), CreateVectorRandom(4, 3) }; - var matrix = Dense.OfColumns(4, 3, columns); + var matrix = Matrix.Build.DenseOfColumns(4, 3, columns); Assert.That(matrix.GetType().Name, Is.EqualTo("DenseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(4)); Assert.That(matrix.ColumnCount, Is.EqualTo(3)); @@ -318,7 +308,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests CreateVectorRandom(4, 1), CreateVectorRandom(4, 3) }; - var matrix = Sparse.OfColumns(4, 3, columns); + var matrix = Matrix.Build.SparseOfColumns(4, 3, columns); Assert.That(matrix.GetType().Name, Is.EqualTo("SparseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(4)); Assert.That(matrix.ColumnCount, Is.EqualTo(3)); @@ -336,7 +326,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests CreateVectorRandom(4, 1), CreateVectorRandom(4, 3) }; - var matrix = Dense.OfRows(3, 4, rows); + var matrix = Matrix.Build.DenseOfRows(3, 4, rows); Assert.That(matrix.GetType().Name, Is.EqualTo("DenseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(3)); Assert.That(matrix.ColumnCount, Is.EqualTo(4)); @@ -354,7 +344,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests CreateVectorRandom(4, 1), CreateVectorRandom(4, 3) }; - var matrix = Sparse.OfRows(3, 4, rows); + var matrix = Matrix.Build.SparseOfRows(3, 4, rows); Assert.That(matrix.GetType().Name, Is.EqualTo("SparseMatrix")); Assert.That(matrix.RowCount, Is.EqualTo(3)); Assert.That(matrix.ColumnCount, Is.EqualTo(4)); diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs index 6275ead2..3b617eeb 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixStructureTheory.cs @@ -40,11 +40,6 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single [TestFixture] public class MatrixStructureTheory : MatrixStructureTheory { - public MatrixStructureTheory() - : base(0f, typeof(DenseMatrix), typeof(SparseMatrix), typeof(DiagonalMatrix), typeof(DenseVector), typeof(SparseVector)) - { - } - [Datapoints] Matrix[] _matrices = new Matrix[] { diff --git a/src/UnitTests/LinearAlgebraTests/StaticDynamicWrapper.cs b/src/UnitTests/LinearAlgebraTests/StaticDynamicWrapper.cs deleted file mode 100644 index a26173d3..00000000 --- a/src/UnitTests/LinearAlgebraTests/StaticDynamicWrapper.cs +++ /dev/null @@ -1,79 +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-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 -// 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.Dynamic; -using System.Linq; -using System.Reflection; - -namespace MathNet.Numerics.UnitTests.LinearAlgebraTests -{ - /// - /// Helper to allow calling static members of dynamic types. - /// Usefull to test static methods of e.g. all dense matrix types. - /// - public class StaticDynamicWrapper : DynamicObject - { - readonly Type _type; - - public StaticDynamicWrapper(Type type) - { - _type = type; - } - - // Handle static properties - public override bool TryGetMember(GetMemberBinder binder, out object result) - { - PropertyInfo prop = _type.GetProperty(binder.Name, BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public); - if (prop == null) - { - result = null; - return false; - } - - result = prop.GetValue(null, null); - return true; - } - - // Handle static methods - public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) - { - MethodInfo method = _type.GetMethod(binder.Name, args.Select(a => a.GetType()).ToArray()); - if (method == null) - { - result = null; - return false; - } - - result = method.Invoke(null, args); - return true; - } - } -} \ No newline at end of file diff --git a/src/UnitTests/UnitTests.csproj b/src/UnitTests/UnitTests.csproj index fd6ba3bd..2d9372e2 100644 --- a/src/UnitTests/UnitTests.csproj +++ b/src/UnitTests/UnitTests.csproj @@ -352,7 +352,6 @@ -