forked from tsai/mathnet-numerics
27 changed files with 764 additions and 203 deletions
@ -0,0 +1,87 @@ |
|||||
|
// <copyright file="TestData.cs" company="Math.NET">
|
||||
|
// 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-2015 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.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
using System; |
||||
|
using MathNet.Numerics.LinearAlgebra; |
||||
|
|
||||
|
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex |
||||
|
{ |
||||
|
#if NOSYSNUMERICS
|
||||
|
using Complex = Numerics.Complex; |
||||
|
#else
|
||||
|
using Complex = System.Numerics.Complex; |
||||
|
#endif
|
||||
|
|
||||
|
public static class TestData |
||||
|
{ |
||||
|
static readonly MatrixBuilder<Complex> M = Matrix<Complex>.Build; |
||||
|
static readonly VectorBuilder<Complex> V = Vector<Complex>.Build; |
||||
|
|
||||
|
public static Matrix<Complex> GetMatrix(TestMatrix matrix) |
||||
|
{ |
||||
|
switch (matrix) |
||||
|
{ |
||||
|
case TestMatrix.DenseSquare3x3: return M.DenseOfArray(new[,] { { 1d, new Complex(1.1d, -4d), 2d }, { 1d, 1d, 2d }, { 1d, new Complex(1d, 2d), 2d } }); |
||||
|
case TestMatrix.DenseSquare3x3b: return M.DenseOfArray(new[,] { { -1.1d, -2.2d, -3.3d }, { 0d, 1.1d, new Complex(2.2d, -1.2d) }, { -4.4d, 5.5d, 6.6d } }); |
||||
|
case TestMatrix.DenseSquare3x3c: return M.DenseOfArray(new[,] { { 1d, 2d, 3d }, { 2d, new Complex(2d, 2d), 0d }, { 3d, Complex.Zero, 3d } }); |
||||
|
case TestMatrix.DenseSquare4x4: return M.DenseOfArray(new[,] { { new Complex(-1.1d, -2d), -2.2d, -3.3d, -4.4d }, { 0d, 1.1d, 2.2d, 3.3d }, { 1d, 2.1d, 6.2d, 4.3d }, { -4.4d, 5.5d, 6.6d, -7.7d } }); |
||||
|
case TestMatrix.DenseSquare4x4b: return M.DenseOfArray(new[,] { { -1.1d, new Complex(-2.2d, 3.4d), -3.3d, -4.4d }, { -1.1d, -2.2d, -3.3d, -4.4d }, { -1.1d, -2.2d, -3.3d, -4.4d }, { -1.1d, -2.2d, -3.3d, -4.4d } }); |
||||
|
case TestMatrix.DenseTall3x2: return M.DenseOfArray(new[,] { { -1.1d, -2.2d }, { Complex.Zero, 1.1d }, { -4.4d, 5.5d } }); |
||||
|
case TestMatrix.DenseWide2x3: return M.DenseOfArray(new[,] { { -1.1d, -2.2d, -3.3d }, { 0d, new Complex(1.1d, 0.1d), 2.2d } }); |
||||
|
|
||||
|
case TestMatrix.SparseSquare3x3: return M.SparseOfArray(new[,] { { 7d, 1d, 2d }, { 1d, 1d, 2d }, { 1d, 1d + Complex.ImaginaryOne, 2d } }); |
||||
|
case TestMatrix.SparseSquare3x3b: return M.SparseOfArray(new[,] { { 7d, 1d, 2d }, { new Complex(1d, 2d), 0d, Complex.Zero }, { -2d, 0d, 0d } }); |
||||
|
case TestMatrix.SparseWide2x3: return M.SparseOfArray(new[,] { { -1.1d, 0d, 0d }, { 0d, new Complex(1.1d, 2d), 2.2d } }); |
||||
|
|
||||
|
case TestMatrix.DiagonalSquare3x3: return M.Diagonal(3, 3, new[] { new Complex(1d, 1d), -2d, 1.5d }); |
||||
|
case TestMatrix.DiagonalSquare3x3b: return M.Diagonal(3, 3, new[] { new Complex(1d, 2d), 0d, -1.5d }); |
||||
|
|
||||
|
case TestMatrix.UserSquare3x3: return new UserDefinedMatrix(new[,] { { 0d, 1d, 2d }, { -1d, 7.7d, 0d }, { -2d, Complex.Zero, 0d } }); |
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static Vector<Complex> GetVector(TestVector vector) |
||||
|
{ |
||||
|
switch (vector) |
||||
|
{ |
||||
|
case TestVector.Dense5: return V.Dense(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1), new Complex(4, 1), new Complex(5, 1) }); |
||||
|
case TestVector.Dense5WithZeros: return V.Dense(new[] { new Complex(2, -1), new Complex(0, 0), new Complex(0, 2), new Complex(-5, 1), new Complex(0, 0) }); |
||||
|
|
||||
|
case TestVector.Sparse5: return V.SparseOfEnumerable(new[] { new Complex(1, 1), new Complex(2, 1), new Complex(3, 1), new Complex(4, 1), new Complex(5, 1) }); |
||||
|
case TestVector.Sparse5WithZeros: return V.SparseOfEnumerable(new[] { new Complex(2, -1), new Complex(0, 0), new Complex(0, 2), new Complex(-5, 1), new Complex(0, 0) }); |
||||
|
case TestVector.Sparse5AllZeros: return V.Sparse(5); |
||||
|
case TestVector.SparseMaxLengthAllZeros: return V.Sparse(int.MaxValue); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,84 @@ |
|||||
|
// <copyright file="TestData.cs" company="Math.NET">
|
||||
|
// 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-2015 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.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
using System; |
||||
|
using MathNet.Numerics.LinearAlgebra; |
||||
|
|
||||
|
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 |
||||
|
{ |
||||
|
using Numerics; |
||||
|
|
||||
|
public static class TestData |
||||
|
{ |
||||
|
static readonly MatrixBuilder<Complex32> M = Matrix<Complex32>.Build; |
||||
|
static readonly VectorBuilder<Complex32> V = Vector<Complex32>.Build; |
||||
|
|
||||
|
public static Matrix<Complex32> GetMatrix(TestMatrix matrix) |
||||
|
{ |
||||
|
switch (matrix) |
||||
|
{ |
||||
|
case TestMatrix.DenseSquare3x3: return M.DenseOfArray(new[,] { { 1f, new Complex32(1.1f, -4f), 2f }, { 1f, 1f, 2f }, { 1f, new Complex32(1f, 2f), 2f } }); |
||||
|
case TestMatrix.DenseSquare3x3b: return M.DenseOfArray(new[,] { { -1.1f, -2.2f, -3.3f }, { 0f, 1.1f, new Complex32(2.2f, -1.2f) }, { -4.4f, 5.5f, 6.6f } }); |
||||
|
case TestMatrix.DenseSquare3x3c: return M.DenseOfArray(new[,] { { 1f, 2f, 3f }, { 2f, new Complex32(2f, 2f), 0f }, { 3f, Complex32.Zero, 3f } }); |
||||
|
case TestMatrix.DenseSquare4x4: return M.DenseOfArray(new[,] { { new Complex32(-1.1f, -2f), -2.2f, -3.3f, -4.4f }, { 0f, 1.1f, 2.2f, 3.3f }, { 1f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } }); |
||||
|
case TestMatrix.DenseSquare4x4b: return M.DenseOfArray(new[,] { { -1.1f, new Complex32(-2.2f, 3.4f), -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 } }); |
||||
|
case TestMatrix.DenseTall3x2: return M.DenseOfArray(new[,] { { -1.1f, -2.2f }, { Complex32.Zero, 1.1f }, { -4.4f, 5.5f } }); |
||||
|
case TestMatrix.DenseWide2x3: return M.DenseOfArray(new[,] { { -1.1f, -2.2f, -3.3f }, { 0f, new Complex32(1.1f, 0.1f), 2.2f } }); |
||||
|
|
||||
|
case TestMatrix.SparseSquare3x3: return M.SparseOfArray(new[,] { { 7f, 1f, 2f }, { 1f, 1f, 2f }, { 1f, 1f + Complex32.ImaginaryOne, 2f } }); |
||||
|
case TestMatrix.SparseSquare3x3b: return M.SparseOfArray(new[,] { { 7f, 1f, 2f }, { new Complex32(1f, 2f), 0f, Complex32.Zero }, { -2f, 0f, 0f } }); |
||||
|
case TestMatrix.SparseWide2x3: return M.SparseOfArray(new[,] { { -1.1f, 0f, 0f }, { 0f, new Complex32(1.1f, 2f), 2.2f } }); |
||||
|
|
||||
|
case TestMatrix.DiagonalSquare3x3: return M.Diagonal(3, 3, new[] { new Complex32(1f, 1f), -2f, 1.5f }); |
||||
|
case TestMatrix.DiagonalSquare3x3b: return M.Diagonal(3, 3, new[] { new Complex32(1f, 2f), 0f, -1.5f }); |
||||
|
|
||||
|
case TestMatrix.UserSquare3x3: return new UserDefinedMatrix(new[,] { { 0f, 1f, 2f }, { -1f, 7.7f, 0f }, { -2f, Complex32.Zero, 0f } }); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static Vector<Complex32> GetVector(TestVector vector) |
||||
|
{ |
||||
|
switch (vector) |
||||
|
{ |
||||
|
case TestVector.Dense5: return V.Dense(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1), new Complex32(4, 1), new Complex32(5, 1) }); |
||||
|
case TestVector.Dense5WithZeros: return V.Dense(new[] { new Complex32(2, -1), new Complex32(0, 0), new Complex32(0, 2), new Complex32(-5, 1), new Complex32(0, 0) }); |
||||
|
|
||||
|
case TestVector.Sparse5: return V.SparseOfEnumerable(new[] { new Complex32(1, 1), new Complex32(2, 1), new Complex32(3, 1), new Complex32(4, 1), new Complex32(5, 1) }); |
||||
|
case TestVector.Sparse5WithZeros: return V.SparseOfEnumerable(new[] { new Complex32(2, -1), new Complex32(0, 0), new Complex32(0, 2), new Complex32(-5, 1), new Complex32(0, 0) }); |
||||
|
case TestVector.Sparse5AllZeros: return V.Sparse(5); |
||||
|
case TestVector.SparseMaxLengthAllZeros: return V.Sparse(int.MaxValue); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
// <copyright file="TestData.cs" company="Math.NET">
|
||||
|
// 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-2015 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.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
using System; |
||||
|
using MathNet.Numerics.LinearAlgebra; |
||||
|
|
||||
|
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double |
||||
|
{ |
||||
|
public static class TestData |
||||
|
{ |
||||
|
static readonly MatrixBuilder<double> M = Matrix<double>.Build; |
||||
|
static readonly VectorBuilder<double> V = Vector<double>.Build; |
||||
|
|
||||
|
public static Matrix<double> GetMatrix(TestMatrix matrix) |
||||
|
{ |
||||
|
switch (matrix) |
||||
|
{ |
||||
|
case TestMatrix.DenseSquare3x3: return M.DenseOfArray(new[,] { { 1d, 1d, 2d }, { 1d, 1d, 2d }, { 1d, 1d, 2d } }); |
||||
|
case TestMatrix.DenseSquare3x3b: return M.DenseOfArray(new[,] { { -1.1d, -2.2d, -3.3d }, { 0d, 1.1d, 2.2d }, { -4.4d, 5.5d, 6.6d } }); |
||||
|
case TestMatrix.DenseSquare3x3c: return M.DenseOfArray(new[,] { { 1d, 2d, 3d }, { 2d, 2d, 0d }, { 3d, 0d, 3d } }); |
||||
|
case TestMatrix.DenseSquare4x4: return M.DenseOfArray(new[,] { { -1.1d, -2.2d, -3.3d, -4.4d }, { 0d, 1.1d, 2.2d, 3.3d }, { 1d, 2.1d, 6.2d, 4.3d }, { -4.4d, 5.5d, 6.6d, -7.7d } }); |
||||
|
case TestMatrix.DenseSquare4x4b: return M.DenseOfArray(new[,] { { -1.1d, -2.2d, -3.3d, -4.4d }, { -1.1d, -2.2d, -3.3d, -4.4d }, { -1.1d, -2.2d, -3.3d, -4.4d }, { -1.1d, -2.2d, -3.3d, -4.4d } }); |
||||
|
case TestMatrix.DenseTall3x2: return M.DenseOfArray(new[,] { { -1.1d, -2.2d }, { 0d, 1.1d }, { -4.4d, 5.5d } }); |
||||
|
case TestMatrix.DenseWide2x3: return M.DenseOfArray(new[,] { { -1.1d, -2.2d, -3.3d }, { 0d, 1.1d, 2.2d } }); |
||||
|
|
||||
|
case TestMatrix.SparseSquare3x3: return M.SparseOfArray(new[,] { { 7d, 1d, 2d }, { 1d, 1d, 2d }, { 1d, 1d, 2d } }); |
||||
|
case TestMatrix.SparseSquare3x3b: return M.SparseOfArray(new[,] { { 7d, 1d, 2d }, { 1d, 0d, 0d }, { -2d, 0d, 0d } }); |
||||
|
case TestMatrix.SparseWide2x3: return M.SparseOfArray(new[,] { { -1.1d, 0d, 0d }, { 0d, 1.1d, 2.2d } }); |
||||
|
|
||||
|
case TestMatrix.DiagonalSquare3x3: return M.Diagonal(3, 3, new[] { 1d, -2d, 1.5d }); |
||||
|
case TestMatrix.DiagonalSquare3x3b: return M.Diagonal(3, 3, new[] { 1d, 0d, -1.5d }); |
||||
|
|
||||
|
case TestMatrix.UserSquare3x3: return new UserDefinedMatrix(new[,] { { 0d, 1d, 2d }, { -1d, 7.7d, 0d }, { -2d, 0d, 0d } }); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static Vector<double> GetVector(TestVector vector) |
||||
|
{ |
||||
|
switch (vector) |
||||
|
{ |
||||
|
case TestVector.Dense5: return V.Dense(new double[] { 1, 2, 3, 4, 5 }); |
||||
|
case TestVector.Dense5WithZeros: return V.Dense(new double[] { 2, 0, 0, -5, 0 }); |
||||
|
|
||||
|
case TestVector.Sparse5: return V.SparseOfEnumerable(new double[] { 1, 2, 3, 4, 5 }); |
||||
|
case TestVector.Sparse5WithZeros: return V.SparseOfEnumerable(new double[] { 2, 0, 0, -5, 0 }); |
||||
|
case TestVector.Sparse5AllZeros: return V.Sparse(5); |
||||
|
case TestVector.SparseMaxLengthAllZeros: return V.Sparse(int.MaxValue); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
// <copyright file="TestData.cs" company="Math.NET">
|
||||
|
// 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-2015 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.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
using System; |
||||
|
using MathNet.Numerics.LinearAlgebra; |
||||
|
|
||||
|
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single |
||||
|
{ |
||||
|
public static class TestData |
||||
|
{ |
||||
|
static readonly MatrixBuilder<float> M = Matrix<float>.Build; |
||||
|
static readonly VectorBuilder<float> V = Vector<float>.Build; |
||||
|
|
||||
|
public static Matrix<float> GetMatrix(TestMatrix matrix) |
||||
|
{ |
||||
|
switch (matrix) |
||||
|
{ |
||||
|
case TestMatrix.DenseSquare3x3: return M.DenseOfArray(new[,] { { 1f, 1f, 2f }, { 1f, 1f, 2f }, { 1f, 1f, 2f } }); |
||||
|
case TestMatrix.DenseSquare3x3b: return M.DenseOfArray(new[,] { { -1.1f, -2.2f, -3.3f }, { 0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } }); |
||||
|
case TestMatrix.DenseSquare3x3c: return M.DenseOfArray(new[,] { { 1f, 2f, 3f }, { 2f, 2f, 0f }, { 3f, 0f, 3f } }); |
||||
|
case TestMatrix.DenseSquare4x4: return M.DenseOfArray(new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0f, 1.1f, 2.2f, 3.3f }, { 1f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } }); |
||||
|
case TestMatrix.DenseSquare4x4b: return M.DenseOfArray(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 } }); |
||||
|
case TestMatrix.DenseTall3x2: return M.DenseOfArray(new[,] { { -1.1f, -2.2f }, { 0f, 1.1f }, { -4.4f, 5.5f } }); |
||||
|
case TestMatrix.DenseWide2x3: return M.DenseOfArray(new[,] { { -1.1f, -2.2f, -3.3f }, { 0f, 1.1f, 2.2f } }); |
||||
|
|
||||
|
case TestMatrix.SparseSquare3x3: return M.SparseOfArray(new[,] { { 7f, 1f, 2f }, { 1f, 1f, 2f }, { 1f, 1f, 2f } }); |
||||
|
case TestMatrix.SparseSquare3x3b: return M.SparseOfArray(new[,] { { 7f, 1f, 2f }, { 1f, 0f, 0f }, { -2f, 0f, 0f } }); |
||||
|
case TestMatrix.SparseWide2x3: return M.SparseOfArray(new[,] { { -1.1f, 0f, 0f }, { 0f, 1.1f, 2.2f } }); |
||||
|
|
||||
|
case TestMatrix.DiagonalSquare3x3: return M.Diagonal(3, 3, new[] { 1f, -2f, 1.5f }); |
||||
|
case TestMatrix.DiagonalSquare3x3b: return M.Diagonal(3, 3, new[] { 1f, 0f, -1.5f }); |
||||
|
|
||||
|
case TestMatrix.UserSquare3x3: return new UserDefinedMatrix(new[,] { { 0f, 1f, 2f }, { -1f, 7.7f, 0f }, { -2f, 0f, 0f } }); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public static Vector<float> GetVector(TestVector vector) |
||||
|
{ |
||||
|
switch (vector) |
||||
|
{ |
||||
|
case TestVector.Dense5: return V.Dense(new float[] { 1, 2, 3, 4, 5 }); |
||||
|
case TestVector.Dense5WithZeros: return V.Dense(new float[] { 2, 0, 0, -5, 0 }); |
||||
|
|
||||
|
case TestVector.Sparse5: return V.SparseOfEnumerable(new float[] { 1, 2, 3, 4, 5 }); |
||||
|
case TestVector.Sparse5WithZeros: return V.SparseOfEnumerable(new float[] { 2, 0, 0, -5, 0 }); |
||||
|
case TestVector.Sparse5AllZeros: return V.Sparse(5); |
||||
|
case TestVector.SparseMaxLengthAllZeros: return V.Sparse(int.MaxValue); |
||||
|
|
||||
|
default: throw new NotSupportedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,63 @@ |
|||||
|
// <copyright file="TestData.cs" company="Math.NET">
|
||||
|
// 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-2015 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.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace MathNet.Numerics.UnitTests.LinearAlgebraTests |
||||
|
{ |
||||
|
public enum TestMatrix |
||||
|
{ |
||||
|
DenseSquare3x3, |
||||
|
DenseSquare3x3b, |
||||
|
DenseSquare4x4, |
||||
|
DenseSquare4x4b, |
||||
|
DenseTall3x2, |
||||
|
DenseWide2x3, |
||||
|
DenseSquare3x3c, |
||||
|
|
||||
|
SparseSquare3x3, |
||||
|
SparseSquare3x3b, |
||||
|
SparseWide2x3, |
||||
|
|
||||
|
DiagonalSquare3x3, |
||||
|
DiagonalSquare3x3b, |
||||
|
|
||||
|
UserSquare3x3 |
||||
|
} |
||||
|
|
||||
|
public enum TestVector |
||||
|
{ |
||||
|
Dense5, |
||||
|
Dense5WithZeros, |
||||
|
|
||||
|
Sparse5, |
||||
|
Sparse5WithZeros, |
||||
|
Sparse5AllZeros, |
||||
|
SparseMaxLengthAllZeros |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue