From 68685906a423c574fa27994c2403ea9a7a9c0d26 Mon Sep 17 00:00:00 2001 From: Marcus Cuda Date: Mon, 8 Nov 2010 22:59:27 +0800 Subject: [PATCH] native: reorg'ed the native code matrix:made the internal data array public on the dense matrices tests:started using MSTest for the provider tests --- src/.gitignore | 2 + src/Local.testsettings | 27 ++ src/MSUnitTests/AssertHelpers.cs | 281 +++++++++++++ .../Double/LinearAlgebraProviderTests.cs | 381 ++++++++++++++++++ .../ManagedLinearAlgebraProviderTests.cs | 16 +- src/MSUnitTests/MSUnitTests.csproj | 68 ++++ src/MSUnitTests/Properties/AssemblyInfo.cs | 35 ++ src/MathNet.Numerics.5.1.ReSharper | 5 +- src/MathNet.Numerics.sln | 16 + src/MathNet.Numerics.vsmdi | 6 + src/NativeWrappers/Common/resource.rc | 16 +- .../Double/MklLinearAlgebraProviderTests.cs | 14 - .../{ => Windows}/ACML/ACMLWrapper.vcproj | 0 .../{ => Windows}/ATLAS/ATLASWrapper.vcproj | 0 .../Windows/ATLAS/ATLASWrapper.vcxproj | 107 +++++ .../ATLAS/ATLASWrapper.vcxproj.filters | 41 ++ .../ATLASWrapperTests.csproj | 42 +- .../Double/AtlasLinearAlgebraProviderTests.cs | 0 .../Properties/AssemblyInfo.cs | 0 .../{ => Windows}/MKL/MKLWrapper.vcproj | 0 .../Windows/MKL/MKLWrapper.vcxproj | 201 +++++++++ .../Windows/MKL/MKLWrapper.vcxproj.filters | 44 ++ .../Double/MklLinearAlgebraProviderTests.cs} | 24 +- .../MKLWrapper32Tests.csproj | 72 ++-- .../Properties/AssemblyInfo.cs | 0 .../MKLWrapper64Tests.csproj | 76 ++-- .../Properties/AssemblyInfo.cs | 0 .../{ => Windows}/NativeWrappers.sln | 44 +- .../LinearAlgebra/Complex/DenseMatrix.cs | 2 +- .../LinearAlgebra/Complex32/DenseMatrix.cs | 2 +- .../LinearAlgebra/Double/DenseMatrix.cs | 2 +- .../LinearAlgebra/Single/DenseMatrix.cs | 2 +- src/TraceAndTestImpact.testsettings | 21 + .../Double/LinearAlgebraProviderTests.cs | 367 ----------------- .../Single/LinearAlgebraProviderTests.cs | 367 ----------------- src/UnitTests/UnitTests.csproj | 4 - 36 files changed, 1406 insertions(+), 879 deletions(-) create mode 100644 src/Local.testsettings create mode 100644 src/MSUnitTests/AssertHelpers.cs create mode 100644 src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs rename src/{UnitTests/LinearAlgebraTests/Single => MSUnitTests/LinearAlgebraProviderTests/Double}/ManagedLinearAlgebraProviderTests.cs (75%) create mode 100644 src/MSUnitTests/MSUnitTests.csproj create mode 100644 src/MSUnitTests/Properties/AssemblyInfo.cs create mode 100644 src/MathNet.Numerics.vsmdi delete mode 100644 src/NativeWrappers/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs rename src/NativeWrappers/{ => Windows}/ACML/ACMLWrapper.vcproj (100%) rename src/NativeWrappers/{ => Windows}/ATLAS/ATLASWrapper.vcproj (100%) create mode 100644 src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj create mode 100644 src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj.filters rename src/NativeWrappers/{ => Windows}/ATLASWrapperTests/ATLASWrapperTests.csproj (70%) rename src/NativeWrappers/{ => Windows}/ATLASWrapperTests/LinearAlgebra/Double/AtlasLinearAlgebraProviderTests.cs (100%) rename src/NativeWrappers/{ => Windows}/ATLASWrapperTests/Properties/AssemblyInfo.cs (100%) rename src/NativeWrappers/{ => Windows}/MKL/MKLWrapper.vcproj (100%) create mode 100644 src/NativeWrappers/Windows/MKL/MKLWrapper.vcxproj create mode 100644 src/NativeWrappers/Windows/MKL/MKLWrapper.vcxproj.filters rename src/{UnitTests/LinearAlgebraTests/Double/ManagedLinearAlgebraProviderTests.cs => NativeWrappers/Windows/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs} (64%) rename src/NativeWrappers/{ => Windows}/MKLWrapper32Tests/MKLWrapper32Tests.csproj (53%) rename src/NativeWrappers/{ => Windows}/MKLWrapper32Tests/Properties/AssemblyInfo.cs (100%) rename src/NativeWrappers/{ => Windows}/MKLWrapper64Tests/MKLWrapper64Tests.csproj (54%) rename src/NativeWrappers/{ => Windows}/MKLWrapper64Tests/Properties/AssemblyInfo.cs (100%) rename src/NativeWrappers/{ => Windows}/NativeWrappers.sln (61%) create mode 100644 src/TraceAndTestImpact.testsettings delete mode 100644 src/UnitTests/LinearAlgebraTests/Double/LinearAlgebraProviderTests.cs delete mode 100644 src/UnitTests/LinearAlgebraTests/Single/LinearAlgebraProviderTests.cs diff --git a/src/.gitignore b/src/.gitignore index 939ed403..5acbe5d7 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -4,3 +4,5 @@ obj *.user *.suo *.vsdoc +TestResults +*.sdf diff --git a/src/Local.testsettings b/src/Local.testsettings new file mode 100644 index 00000000..6cb36d7c --- /dev/null +++ b/src/Local.testsettings @@ -0,0 +1,27 @@ + + + These are default test settings for a local test run. + + + + + + + + + + + + +
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/src/MSUnitTests/AssertHelpers.cs b/src/MSUnitTests/AssertHelpers.cs new file mode 100644 index 00000000..c8d4af62 --- /dev/null +++ b/src/MSUnitTests/AssertHelpers.cs @@ -0,0 +1,281 @@ +// +// 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-2010 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. +// + +namespace MathNet.Numerics.UnitTests +{ + using System.Collections.Generic; + using System.Numerics; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + /// + /// A class which includes some assertion helper methods particularly for numerical code. + /// + internal class AssertHelpers + { + /// + /// Asserts that the expected value and the actual value are equal. + /// + /// The expected value. + /// The actual value. + public static void AreEqual(Complex expected, Complex actual) + { + if (expected.IsNaN() && actual.IsNaN()) + { + return; + } + + if (expected.IsInfinity() && expected.IsInfinity()) + { + return; + } + + bool pass = expected.Real.AlmostEqual(actual.Real); + if (!pass) + { + Assert.Fail("Real components are not equal. Expected:{0}; Actual:{1}", expected.Real, actual.Real); + } + + pass = expected.Imaginary.AlmostEqual(actual.Imaginary); + if (!pass) + { + Assert.Fail("Imaginary components are not equal. Expected:{0}; Actual:{1}", expected.Imaginary, actual.Imaginary); + } + } + + /// + /// Asserts that the expected value and the actual value are equal. + /// + /// The expected value. + /// The actual value. + public static void AreEqual(Complex32 expected, Complex32 actual) + { + if (expected.IsNaN() && actual.IsNaN()) + { + return; + } + + if (expected.IsInfinity() && expected.IsInfinity()) + { + return; + } + + bool pass = expected.Real.AlmostEqual(actual.Real); + if (!pass) + { + Assert.Fail("Real components are not equal. Expected:{0}; Actual:{1}", expected.Real, actual.Real); + } + + pass = expected.Imaginary.AlmostEqual(actual.Imaginary); + if (!pass) + { + Assert.Fail("Imaginary components are not equal. Expected:{0}; Actual:{1}", expected.Imaginary, actual.Imaginary); + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain number of decimal places. If both + /// and are NaN then no assert is thrown. + /// + /// The expected value. + /// The actual value. + /// The number of decimal places to agree on. + public static void AlmostEqual(double expected, double actual, int decimalPlaces) + { + if (double.IsNaN(expected) && double.IsNaN(actual)) + { + return; + } + + bool pass = expected.AlmostEqualInDecimalPlaces(actual, decimalPlaces); + if (!pass) + { + // signals Gallio that the test failed. + Assert.Fail("Not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected, actual); + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain number of decimal places. If both + /// and are NaN then no assert is thrown. + /// + /// The expected value. + /// The actual value. + /// The number of decimal places to agree on. + public static void AlmostEqual(float expected, float actual, int decimalPlaces) + { + if (float.IsNaN(expected) && float.IsNaN(actual)) + { + return; + } + + bool pass = expected.AlmostEqualInDecimalPlaces(actual, decimalPlaces); + if (!pass) + { + // signals Gallio that the test failed. + Assert.Fail("Not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected, actual); + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain number of decimal places. + /// + /// The expected value. + /// The actual value. + /// The number of decimal places to agree on. + public static void AlmostEqual(Complex expected, Complex actual, int decimalPlaces) + { + bool pass = expected.Real.AlmostEqualInDecimalPlaces(actual.Real, decimalPlaces); + if (!pass) + { + Assert.Fail("Real components are not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected.Real, actual.Real); + } + + pass = expected.Imaginary.AlmostEqualInDecimalPlaces(actual.Imaginary, decimalPlaces); + if (!pass) + { + Assert.Fail("Imaginary components are not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected.Imaginary, actual.Imaginary); + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain number of decimal places. + /// + /// The expected value. + /// The actual value. + /// The number of decimal places to agree on. + public static void AlmostEqual(Complex32 expected, Complex32 actual, int decimalPlaces) + { + bool pass = expected.Real.AlmostEqualInDecimalPlaces(actual.Real, decimalPlaces); + if (!pass) + { + Assert.Fail("Real components are not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected.Real, actual.Real); + } + + pass = expected.Imaginary.AlmostEqualInDecimalPlaces(actual.Imaginary, decimalPlaces); + if (!pass) + { + Assert.Fail("Imaginary components are not equal within {0} places. Expected:{1}; Actual:{2}", decimalPlaces, expected.Imaginary, actual.Imaginary); + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain + /// maximum error. + /// + /// The type of the structures. Must implement + /// . + /// The expected value. + /// The actual value. + /// The accuracy required for being almost equal. + public static void AlmostEqual(T expected, T actual, double maximumError) + where T : IPrecisionSupport + { + if (!actual.AlmostEqualWithError(expected, maximumError)) + { + Assert.Fail("Not equal within a maximum error {0}. Expected:{1}; Actual:{2}", maximumError, expected, actual); + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain + /// maximum error. + /// + /// The expected value list. + /// The actual value list. + /// The accuracy required for being almost equal. + public static void AlmostEqualList(IList expected, IList actual, double maximumError) + { + for (int i = 0; i < expected.Count; i++) + { + if (!actual[i].AlmostEqualWithError(expected[i], maximumError)) + { + Assert.Fail("Not equal within a maximum error {0}. Expected:{1}; Actual:{2}", maximumError, expected[i], actual[i]); + } + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain + /// maximum error. + /// + /// The expected value list. + /// The actual value list. + /// The accuracy required for being almost equal. + public static void AlmostEqualList(IList expected, IList actual, double maximumError) + { + for (int i = 0; i < expected.Count; i++) + { + if (!actual[i].AlmostEqualWithError(expected[i], maximumError)) + { + Assert.Fail("Not equal within a maximum error {0}. Expected:{1}; Actual:{2}", maximumError, expected[i], actual[i]); + } + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain + /// maximum error. + /// + /// The type of the structures. Must implement + /// . + /// The expected value list. + /// The actual value list. + /// The accuracy required for being almost equal. + public static void AlmostEqualList(IList expected, IList actual, double maximumError) + where T : IPrecisionSupport + { + for (int i = 0; i < expected.Count; i++) + { + if (!actual[i].AlmostEqualWithError(expected[i], maximumError)) + { + Assert.Fail("Not equal within a maximum error {0}. Expected:{1}; Actual:{2}", maximumError, expected[i], actual[i]); + } + } + } + + /// + /// Asserts that the expected value and the actual value are equal up to a certain + /// maximum error. + /// + /// The expected value list. + /// The actual value list. + /// The accuracy required for being almost equal. + public static void AlmostEqualList(IList expected, IList actual, double maximumError) + { + for (int i = 0; i < expected.Count; i++) + { + if (!actual[i].AlmostEqualWithError(expected[i], maximumError)) + { + Assert.Fail("Not equal within a maximum error {0}. Expected:{1}; Actual:{2}", maximumError, expected[i], actual[i]); + } + } + } + } +} diff --git a/src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs b/src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs new file mode 100644 index 00000000..7cac2247 --- /dev/null +++ b/src/MSUnitTests/LinearAlgebraProviderTests/Double/LinearAlgebraProviderTests.cs @@ -0,0 +1,381 @@ +// +// 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-2010 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. +// +namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double +{ + using System; + using System.Collections.Generic; + using Algorithms.LinearAlgebra; + using LinearAlgebra.Double; + using Microsoft.VisualStudio.TestTools.UnitTesting; + + /// + /// Base class for linear algebra provider tests. + /// + [TestClass] + public abstract class LinearAlgebraProviderTests + { + /// + /// Gets or sets linear algebra provider to test. + /// + protected static ILinearAlgebraProvider Provider + { + get; + set; + } + + /// + /// The Y double test vector. + /// + private readonly double[] _y = new[] { 1.1, 2.2, 3.3, 4.4, 5.5 }; + + /// + /// The X double test vector. + /// + private readonly double[] _x = new[] { 6.6, 7.7, 8.8, 9.9, 10.1 }; + + /// + /// Test matrix to use. + /// + private readonly IDictionary _matrices = new Dictionary + { + { "Singular3x3", new DenseMatrix(new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } }) }, + { "Square3x3", new DenseMatrix(new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } }) }, + { "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 } }) }, + { "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 } }) } + }; + + /// + /// Can add a vector to scaled vector + /// + [TestMethod] + public void CanAddVectorToScaledVectorDouble() + { + var result = new double[_y.Length]; + Array.Copy(_y, result, _y.Length); + + Provider.AddVectorToScaledVector(result, 0, _x); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i], result[i]); + } + + Array.Copy(_y, result, _y.Length); + Provider.AddVectorToScaledVector(result, 1, _x); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i] + _x[i], result[i]); + } + + Array.Copy(_y, result, _y.Length); + Provider.AddVectorToScaledVector(result, Math.PI, _x); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i] + (Math.PI * _x[i]), result[i]); + } + } + + /// + /// Can scale an array. + /// + [TestMethod] + public void CanScaleArray() + { + var result = new double[_y.Length]; + + Array.Copy(_y, result, _y.Length); + Provider.ScaleArray(1, result); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i], result[i]); + } + + Array.Copy(_y, result, _y.Length); + Provider.ScaleArray(Math.PI, result); + for (var i = 0; i < _y.Length; i++) + { + Assert.AreEqual(_y[i] * Math.PI, result[i]); + } + } + + /// + /// Can compute the dot product. + /// + [TestMethod] + public void CanComputeDotProduct() + { + var result = Provider.DotProduct(_x, _y); + AssertHelpers.AlmostEqual(152.35, result, 15); + } + + /// + /// Can add two arrays. + /// + [TestMethod] + public void CanAddArrays() + { + var result = new double[_y.Length]; + Provider.AddArrays(_x, _y, result); + for (var i = 0; i < result.Length; i++) + { + Assert.AreEqual(_x[i] + _y[i], result[i]); + } + } + + /// + /// Can subtract two arrays. + /// + [TestMethod] + public void CanSubtractArrays() + { + var result = new double[_y.Length]; + Provider.SubtractArrays(_x, _y, result); + for (var i = 0; i < result.Length; i++) + { + Assert.AreEqual(_x[i] - _y[i], result[i]); + } + } + + /// + /// Can pointwise multiply two arrays. + /// + [TestMethod] + public void CanPointWiseMultiplyArrays() + { + var result = new double[_y.Length]; + Provider.PointWiseMultiplyArrays(_x, _y, result); + for (var i = 0; i < result.Length; i++) + { + Assert.AreEqual(_x[i] * _y[i], result[i]); + } + } + + /// + /// Can compute L1 norm. + /// + [TestMethod] + public void CanComputeMatrixL1Norm() + { + } + + /// + /// Can compute Frobenius norm. + /// + [TestMethod] + public void CanComputeMatrixFrobeniusNorm() + { + } + + /// + /// Can compute Infinity norm. + /// + [TestMethod] + public void CanComputeMatrixInfinityNorm() + { + } + + /// + /// Can compute L1 norm using a work array. + /// + [TestMethod] + public void CanComputeMatrixL1NormWithWorkArray() + { + } + + /// + /// Can compute Frobenius norm using a work array. + /// + [TestMethod] + public void CanComputeMatrixFrobeniusNormWithWorkArray() + { + } + + /// + /// Can compute Infinity norm using a work array. + /// + [TestMethod] + public void CanComputeMatrixInfinityNormWithWorkArray() + { + } + + /// + /// Can multiply two square matrices. + /// + [TestMethod] + public void CanMultiplySquareMatrices() + { + var x = _matrices["Singular3x3"]; + var y = _matrices["Square3x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a wide and tall matrix. + /// + [TestMethod] + public void CanMultiplyWideAndTallMatrices() + { + var x = _matrices["Wide2x3"]; + var y = _matrices["Tall3x2"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a tall and wide matrix. + /// + [TestMethod] + public void CanMultiplyTallAndWideMatrices() + { + var x = _matrices["Tall3x2"]; + var y = _matrices["Wide2x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiply(x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply two square matrices. + /// + [TestMethod] + public void CanMultiplySquareMatricesWithUpdate() + { + var x = _matrices["Singular3x3"]; + var y = _matrices["Square3x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(2.2 * x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a wide and tall matrix. + /// + [TestMethod] + public void CanMultiplyWideAndTallMatricesWithUpdate() + { + var x = _matrices["Wide2x3"]; + var y = _matrices["Tall3x2"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(2.2 * x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can multiply a tall and wide matrix. + /// + [TestMethod] + public void CanMultiplyTallAndWideMatricesWithUpdate() + { + var x = _matrices["Tall3x2"]; + var y = _matrices["Wide2x3"]; + var c = new DenseMatrix(x.RowCount, y.ColumnCount); + + Provider.MatrixMultiplyWithUpdate(Transpose.DontTranspose, Transpose.DontTranspose, 2.2, x.Data, x.RowCount, x.ColumnCount, y.Data, y.RowCount, y.ColumnCount, 1.0, c.Data); + + for (var i = 0; i < c.RowCount; i++) + { + for (var j = 0; j < c.ColumnCount; j++) + { + AssertHelpers.AlmostEqual(2.2 * x.Row(i) * y.Column(j), c[i, j], 15); + } + } + } + + /// + /// Can compute the Cholesky factorization. + /// + [TestMethod] + public void CanComputeCholeskyFactor() + { + var matrix = new double[] { 1, 1, 1, 1, 1, 5, 5, 5, 1, 5, 14, 14, 1, 5, 14, 15 }; + Provider.CholeskyFactor(matrix, 4); + Assert.AreEqual(matrix[0], 1); + Assert.AreEqual(matrix[1], 1); + Assert.AreEqual(matrix[2], 1); + Assert.AreEqual(matrix[3], 1); + Assert.AreEqual(matrix[4], 0); + Assert.AreEqual(matrix[5], 2); + Assert.AreEqual(matrix[6], 2); + Assert.AreEqual(matrix[7], 2); + Assert.AreEqual(matrix[8], 0); + Assert.AreEqual(matrix[9], 0); + Assert.AreEqual(matrix[10], 3); + Assert.AreEqual(matrix[11], 3); + Assert.AreEqual(matrix[12], 0); + Assert.AreEqual(matrix[13], 0); + Assert.AreEqual(matrix[14], 0); + Assert.AreEqual(matrix[15], 1); + } + } +} \ No newline at end of file diff --git a/src/UnitTests/LinearAlgebraTests/Single/ManagedLinearAlgebraProviderTests.cs b/src/MSUnitTests/LinearAlgebraProviderTests/Double/ManagedLinearAlgebraProviderTests.cs similarity index 75% rename from src/UnitTests/LinearAlgebraTests/Single/ManagedLinearAlgebraProviderTests.cs rename to src/MSUnitTests/LinearAlgebraProviderTests/Double/ManagedLinearAlgebraProviderTests.cs index f3b90720..ac1e5223 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/ManagedLinearAlgebraProviderTests.cs +++ b/src/MSUnitTests/LinearAlgebraProviderTests/Double/ManagedLinearAlgebraProviderTests.cs @@ -28,14 +28,22 @@ // OTHER DEALINGS IN THE SOFTWARE. // -namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single +namespace MathNet.Numerics.UnitTests.LinearAlgebraProviderTests.Double { - using MbUnit.Framework; + using Microsoft.VisualStudio.TestTools.UnitTesting; + /// + /// Unit test container for the managed linear algebra provider. + /// + [TestClass] public class ManagedLinearAlgebraProviderTests : LinearAlgebraProviderTests { - [FixtureSetUp] - public void SetProvider() + /// + /// Sets the linear algebra provider to the managed one. + /// + /// The test context to use. + [ClassInitialize] + public static void SetProvider(TestContext context) { Provider = new Algorithms.LinearAlgebra.ManagedLinearAlgebraProvider(); } diff --git a/src/MSUnitTests/MSUnitTests.csproj b/src/MSUnitTests/MSUnitTests.csproj new file mode 100644 index 00000000..4d2477df --- /dev/null +++ b/src/MSUnitTests/MSUnitTests.csproj @@ -0,0 +1,68 @@ + + + + Debug + AnyCPU + + + 2.0 + {624FB757-A724-4B0D-85EB-F0563CE43A33} + Library + Properties + MathNet.Numerics.UnitTests + MathNet.Numerics.MSUnitTests + v4.0 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + 3.5 + + + + + + False + + + + + + + + + + + {B7CAE5F4-A23F-4438-B5BE-41226618B695} + Numerics + + + + + \ No newline at end of file diff --git a/src/MSUnitTests/Properties/AssemblyInfo.cs b/src/MSUnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..6fbd5225 --- /dev/null +++ b/src/MSUnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MSUnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("MSUnitTests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("38b7aca0-5350-4ed4-9637-ae52b0107e48")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/MathNet.Numerics.5.1.ReSharper b/src/MathNet.Numerics.5.1.ReSharper index 06d7ae33..fc99438d 100644 --- a/src/MathNet.Numerics.5.1.ReSharper +++ b/src/MathNet.Numerics.5.1.ReSharper @@ -32,7 +32,10 @@ mxn nxn Nist NIST's -Excel's +Excel's +ipiv +blocksize +Dont diff --git a/src/MathNet.Numerics.sln b/src/MathNet.Numerics.sln index 42db81f8..87265ee2 100644 --- a/src/MathNet.Numerics.sln +++ b/src/MathNet.Numerics.sln @@ -15,7 +15,19 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpUnitTests", "FSharpUn EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Silverlight", "Silverlight\Silverlight.csproj", "{793E332F-E2B1-4D1D-9B2E-27E90B99BF93}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSUnitTests", "MSUnitTests\MSUnitTests.csproj", "{624FB757-A724-4B0D-85EB-F0563CE43A33}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5A0CD103-0739-4E4D-B9E9-6DD5EE137C3B}" + ProjectSection(SolutionItems) = preProject + Local.testsettings = Local.testsettings + MathNet.Numerics.vsmdi = MathNet.Numerics.vsmdi + TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings + EndProjectSection +EndProject Global + GlobalSection(TestCaseManagementSettings) = postSolution + CategoryFile = MathNet.Numerics.vsmdi + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -49,6 +61,10 @@ Global {793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Debug|Any CPU.Build.0 = Debug|Any CPU {793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Release|Any CPU.ActiveCfg = Release|Any CPU {793E332F-E2B1-4D1D-9B2E-27E90B99BF93}.Release|Any CPU.Build.0 = Release|Any CPU + {624FB757-A724-4B0D-85EB-F0563CE43A33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {624FB757-A724-4B0D-85EB-F0563CE43A33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {624FB757-A724-4B0D-85EB-F0563CE43A33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {624FB757-A724-4B0D-85EB-F0563CE43A33}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/MathNet.Numerics.vsmdi b/src/MathNet.Numerics.vsmdi new file mode 100644 index 00000000..292460e7 --- /dev/null +++ b/src/MathNet.Numerics.vsmdi @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/NativeWrappers/Common/resource.rc b/src/NativeWrappers/Common/resource.rc index 3f14db72..14020254 100644 --- a/src/NativeWrappers/Common/resource.rc +++ b/src/NativeWrappers/Common/resource.rc @@ -13,13 +13,11 @@ #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources +// English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) -#endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// @@ -53,8 +51,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,2009,12,0 - PRODUCTVERSION 0,2009,12,0 + FILEVERSION 0,2010,12,0 + PRODUCTVERSION 0,2010,12,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -72,12 +70,12 @@ BEGIN VALUE "Comments", "http://mathdotnet.com" VALUE "CompanyName", "Math.NET" VALUE "FileDescription", "MathNET Numerics Native Library" - VALUE "FileVersion", "0.2009.12" + VALUE "FileVersion", "0.2010.12.0" VALUE "InternalName", "Math.NET" - VALUE "LegalCopyright", "Copyright (C) Math.NET 2009" + VALUE "LegalCopyright", "Copyright (C) Math.NET 2009-2010" VALUE "OriginalFilename", "MathNET.Numerics" VALUE "ProductName", "Math.NET" - VALUE "ProductVersion", "2009.12" + VALUE "ProductVersion", "0.2010.12.0" END END BLOCK "VarFileInfo" @@ -86,7 +84,7 @@ BEGIN END END -#endif // English (U.S.) resources +#endif // English (United States) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/NativeWrappers/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs b/src/NativeWrappers/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs deleted file mode 100644 index 0392190e..00000000 --- a/src/NativeWrappers/MKLWrapper32Tests/LinearAlgebra/Double/MklLinearAlgebraProviderTests.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace MathNet.Numerics.MklWrapperTests.LinearAlgebra.Double -{ - using MbUnit.Framework; - using UnitTests.LinearAlgebraTests.Double; - - public class MklLinearAlgebraProviderTests : LinearAlgebraProviderTests - { - [FixtureSetUp] - public void SetUpProvider() - { - Provider = new Algorithms.LinearAlgebra.Mkl.MklLinearAlgebraProvider(); - } - } -} diff --git a/src/NativeWrappers/ACML/ACMLWrapper.vcproj b/src/NativeWrappers/Windows/ACML/ACMLWrapper.vcproj similarity index 100% rename from src/NativeWrappers/ACML/ACMLWrapper.vcproj rename to src/NativeWrappers/Windows/ACML/ACMLWrapper.vcproj diff --git a/src/NativeWrappers/ATLAS/ATLASWrapper.vcproj b/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcproj similarity index 100% rename from src/NativeWrappers/ATLAS/ATLASWrapper.vcproj rename to src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcproj diff --git a/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj b/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj new file mode 100644 index 00000000..11109832 --- /dev/null +++ b/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj @@ -0,0 +1,107 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + {A848B8C9-E72A-4716-A8F1-04104CC2422F} + ATLASWrapper + + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + C:\source\mathnet-marcus\src\NativeWrappers\Common;C:\source\mathnet-marcus\src\NativeWrappers\ATLAS;C:\cygwin\tmp\ATLAS\include;%(AdditionalIncludeDirectories) + _WINDOWS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + Level3 + EditAndContinue + Default + + + libcblas.a;libatlas.a;liblapack.a;%(AdditionalDependencies) + $(OutDir)MathNET.Numerics.ATLAS.dll + C:\cygwin\tmp\ATLAS\parallel\lib;%(AdditionalLibraryDirectories) + true + MachineX86 + + + + + MaxSpeed + true + C:\source\mathnet-marcus\src\NativeWrappers\Common;C:\source\mathnet-marcus\src\NativeWrappers\ATLAS;C:\source\mathnet-marcus\src\NativeWrappers\ATLAS\include;%(AdditionalIncludeDirectories) + _WINDOWS;%(PreprocessorDefinitions) + MultiThreaded + true + Level3 + ProgramDatabase + Default + + + libcblas.a;libatlas.a;liblapack.a;%(AdditionalDependencies) + $(OutDir)MathNET.Numerics.ATLAS.dll + C:\source\mathnet-marcus\src\NativeWrappers\ATLAS\lib;%(AdditionalLibraryDirectories) + true + true + true + MachineX86 + + + + + + \ No newline at end of file diff --git a/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj.filters b/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj.filters new file mode 100644 index 00000000..58436d58 --- /dev/null +++ b/src/NativeWrappers/Windows/ATLAS/ATLASWrapper.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav + + + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/src/NativeWrappers/ATLASWrapperTests/ATLASWrapperTests.csproj b/src/NativeWrappers/Windows/ATLASWrapperTests/ATLASWrapperTests.csproj similarity index 70% rename from src/NativeWrappers/ATLASWrapperTests/ATLASWrapperTests.csproj rename to src/NativeWrappers/Windows/ATLASWrapperTests/ATLASWrapperTests.csproj index b1b52fdb..f3118640 100644 --- a/src/NativeWrappers/ATLASWrapperTests/ATLASWrapperTests.csproj +++ b/src/NativeWrappers/Windows/ATLASWrapperTests/ATLASWrapperTests.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -12,6 +12,25 @@ MathNet.Numerics.ATLASWrapperTests v3.5 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true true @@ -21,6 +40,7 @@ DEBUG;TRACE prompt 4 + AllRules.ruleset pdbonly @@ -30,6 +50,7 @@ prompt 4 x86 + AllRules.ruleset @@ -70,10 +91,21 @@ - - MathNET.Numerics.ATLAS.dll - PreserveNewest - + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true +