From 69086748731b150822cb671ea159e439fb8f247f Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Sun, 7 Apr 2013 23:03:40 +0200 Subject: [PATCH] Cosmetics --- .../Storage/DenseColumnMajorMatrixStorage.cs | 1 - .../Complex/MatrixLoader.cs | 76 ++++++++-------- .../Complex32/MatrixLoader.cs | 88 +++++++++---------- .../LinearAlgebraTests/Double/MatrixLoader.cs | 76 ++++++++-------- .../LinearAlgebraTests/Single/MatrixLoader.cs | 88 +++++++++---------- 5 files changed, 156 insertions(+), 173 deletions(-) diff --git a/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs b/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs index 10ab5982..2293b671 100644 --- a/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs +++ b/src/Numerics/LinearAlgebra/Storage/DenseColumnMajorMatrixStorage.cs @@ -130,7 +130,6 @@ namespace MathNet.Numerics.LinearAlgebra.Storage { for (var i = 0; i < storage.RowCount; i++) { - storage.Data[index++] = init(i, j); } } diff --git a/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs index eb5b97be..5ba28190 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex/MatrixLoader.cs @@ -3,7 +3,9 @@ // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com -// Copyright (c) 2009-2010 Math.NET +// +// 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 @@ -12,8 +14,10 @@ // 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 @@ -42,20 +46,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex /// /// Gets or sets test matrices values to use. /// - protected Dictionary TestData2D - { - get; - set; - } + protected Dictionary TestData2D { get; set; } /// /// Gets or sets test matrices instances to use. /// - protected Dictionary TestMatrices - { - get; - set; - } + protected Dictionary TestMatrices { get; set; } /// /// Creates a matrix for the given number of rows and columns. @@ -94,15 +90,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex public virtual void SetupMatrices() { TestData2D = new Dictionary - { - { "Singular3x3", new[,] { { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) }, { new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1) } } }, - { "Square3x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1) } } }, - { "Square4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1), new Complex(3.3, 1) }, { new Complex(1.0, 1), new Complex(2.1, 1), new Complex(6.2, 1), new Complex(4.3, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1), new Complex(-7.7, 1) } } }, - { "Singular4x4", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) }, { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1) } } }, - { "Tall3x2", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1) }, { Complex.Zero, new Complex(1.1, 1) }, { new Complex(-4.4, 1), new Complex(5.5, 1) } } }, - { "Wide2x3", new[,] { { new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1) }, { Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1) } } }, - { "Symmetric3x3", new[,] { { Complex.One, 2.0, 3.0 }, { 2.0, 2.0, 0.0 }, { 3.0, 0.0, 3.0 } } } - }; + { + {"Singular3x3", new[,] {{new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1)}, {new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1)}, {new Complex(1.0, 1), new Complex(1.0, 1), new Complex(2.0, 1)}}}, + {"Square3x3", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1)}, {Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1)}, {new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1)}}}, + {"Square4x4", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1), new Complex(3.3, 1)}, {new Complex(1.0, 1), new Complex(2.1, 1), new Complex(6.2, 1), new Complex(4.3, 1)}, {new Complex(-4.4, 1), new Complex(5.5, 1), new Complex(6.6, 1), new Complex(-7.7, 1)}}}, + {"Singular4x4", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}, {new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1), new Complex(-4.4, 1)}}}, + {"Tall3x2", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1)}, {Complex.Zero, new Complex(1.1, 1)}, {new Complex(-4.4, 1), new Complex(5.5, 1)}}}, + {"Wide2x3", new[,] {{new Complex(-1.1, 1), new Complex(-2.2, 1), new Complex(-3.3, 1)}, {Complex.Zero, new Complex(1.1, 1), new Complex(2.2, 1)}}}, + {"Symmetric3x3", new[,] {{Complex.One, 2.0, 3.0}, {2.0, 2.0, 0.0}, {3.0, 0.0, 3.0}}} + }; TestMatrices = new Dictionary(); foreach (var name in TestData2D.Keys) @@ -121,9 +117,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(row, col); for (var i = 0; i < row; i++) { @@ -145,9 +141,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(order); for (var i = 0; i < order; i++) { @@ -158,7 +154,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } // Generate a Hermitian matrix which is positive definite. - return matrixA.ConjugateTranspose() * matrixA; + return matrixA.ConjugateTranspose()*matrixA; } /// @@ -170,9 +166,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new DenseVector(order); for (var i = 0; i < order; i++) { @@ -192,9 +188,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(row, col); for (var i = 0; i < row; i++) { @@ -216,9 +212,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(order); for (var i = 0; i < order; i++) { @@ -229,7 +225,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex } // Generate a Hermitian matrix which is positive definite. - return matrixA.ConjugateTranspose() * matrixA; + return matrixA.ConjugateTranspose()*matrixA; } /// @@ -241,9 +237,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new UserDefinedVector(order); for (var i = 0; i < order; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs index 26e2ea6d..f05952ba 100644 --- a/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Complex32/MatrixLoader.cs @@ -3,7 +3,9 @@ // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com -// Copyright (c) 2009-2010 Math.NET +// +// 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 @@ -12,8 +14,10 @@ // 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 @@ -42,20 +46,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 /// /// Gets or sets test matrices values to use. /// - protected Dictionary TestData2D - { - get; - set; - } + protected Dictionary TestData2D { get; set; } /// /// Gets or sets test matrices instances to use. /// - protected Dictionary TestMatrices - { - get; - set; - } + protected Dictionary TestMatrices { get; set; } /// /// Creates a matrix for the given number of rows and columns. @@ -94,15 +90,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 public virtual void SetupMatrices() { TestData2D = new Dictionary - { - { "Singular3x3", new[,] { { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) }, { new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1) } } }, - { "Square3x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1) } } }, - { "Square4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1) }, { new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1) } } }, - { "Singular4x4", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) }, { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1) } } }, - { "Tall3x2", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1) }, { new Complex32(-4.4f, 1), new Complex32(5.5f, 1) } } }, - { "Wide2x3", new[,] { { new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1) }, { Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1) } } }, - { "Symmetric3x3", new[,] { { Complex32.One, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } } - }; + { + {"Singular3x3", new[,] {{new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}, {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}, {new Complex32(1.0f, 1), new Complex32(1.0f, 1), new Complex32(2.0f, 1)}}}, + {"Square3x3", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1)}}}, + {"Square4x4", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1), new Complex32(3.3f, 1)}, {new Complex32(1.0f, 1), new Complex32(2.1f, 1), new Complex32(6.2f, 1), new Complex32(4.3f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1), new Complex32(6.6f, 1), new Complex32(-7.7f, 1)}}}, + {"Singular4x4", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}, {new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1), new Complex32(-4.4f, 1)}}}, + {"Tall3x2", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1)}, {new Complex32(-4.4f, 1), new Complex32(5.5f, 1)}}}, + {"Wide2x3", new[,] {{new Complex32(-1.1f, 1), new Complex32(-2.2f, 1), new Complex32(-3.3f, 1)}, {Complex32.Zero, new Complex32(1.1f, 1), new Complex32(2.2f, 1)}}}, + {"Symmetric3x3", new[,] {{Complex32.One, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}} + }; TestMatrices = new Dictionary(); foreach (var name in TestData2D.Keys) @@ -121,15 +117,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(row, col); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { - matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); + matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); } } @@ -145,20 +141,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(order); for (var i = 0; i < order; i++) { for (var j = 0; j < order; j++) { - matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); + matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); } } // Generate a Hermitian matrix which is positive definite. - return matrixA.ConjugateTranspose() * matrixA; + return matrixA.ConjugateTranspose()*matrixA; } /// @@ -170,13 +166,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new DenseVector(order); for (var i = 0; i < order; i++) { - v[i] = new Complex32((float)normal.Sample(), (float)normal.Sample()); + v[i] = new Complex32((float) normal.Sample(), (float) normal.Sample()); } return v; @@ -192,15 +188,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(row, col); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { - matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); + matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); } } @@ -216,20 +212,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(order); for (var i = 0; i < order; i++) { for (var j = 0; j < order; j++) { - matrixA[i, j] = new Complex32((float)normal.Sample(), (float)normal.Sample()); + matrixA[i, j] = new Complex32((float) normal.Sample(), (float) normal.Sample()); } } // Generate a Hermitian matrix which is positive definite. - return matrixA.ConjugateTranspose() * matrixA; + return matrixA.ConjugateTranspose()*matrixA; } /// @@ -241,13 +237,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Complex32 { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new UserDefinedVector(order); for (var i = 0; i < order; i++) { - v[i] = new Complex32((float)normal.Sample(), (float)normal.Sample()); + v[i] = new Complex32((float) normal.Sample(), (float) normal.Sample()); } // Generate a matrix which is positive definite. diff --git a/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs index 5d54d54b..882987dc 100644 --- a/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Double/MatrixLoader.cs @@ -3,7 +3,9 @@ // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com -// Copyright (c) 2009-2010 Math.NET +// +// 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 @@ -12,8 +14,10 @@ // 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 @@ -41,20 +45,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double /// /// Gets or sets test matrices values to use. /// - protected Dictionary TestData2D - { - get; - set; - } + protected Dictionary TestData2D { get; set; } /// /// Gets or sets test matrices instances to use. /// - protected Dictionary TestMatrices - { - get; - set; - } + protected Dictionary TestMatrices { get; set; } /// /// Creates a matrix for the given number of rows and columns. @@ -93,15 +89,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double public virtual void SetupMatrices() { TestData2D = new Dictionary - { - { "Singular3x3", new[,] { { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 }, { 1.0, 1.0, 2.0 } } }, - { "Square3x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 }, { -4.4, 5.5, 6.6 } } }, - { "Square4x4", 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[,] { { -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[,] { { -1.1, -2.2 }, { 0.0, 1.1 }, { -4.4, 5.5 } } }, - { "Wide2x3", new[,] { { -1.1, -2.2, -3.3 }, { 0.0, 1.1, 2.2 } } }, - { "Symmetric3x3", new[,] { { 1.0, 2.0, 3.0 }, { 2.0, 2.0, 0.0 }, { 3.0, 0.0, 3.0 } } } - }; + { + {"Singular3x3", new[,] {{1.0, 1.0, 2.0}, {1.0, 1.0, 2.0}, {1.0, 1.0, 2.0}}}, + {"Square3x3", new[,] {{-1.1, -2.2, -3.3}, {0.0, 1.1, 2.2}, {-4.4, 5.5, 6.6}}}, + {"Square4x4", 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[,] {{-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[,] {{-1.1, -2.2}, {0.0, 1.1}, {-4.4, 5.5}}}, + {"Wide2x3", new[,] {{-1.1, -2.2, -3.3}, {0.0, 1.1, 2.2}}}, + {"Symmetric3x3", new[,] {{1.0, 2.0, 3.0}, {2.0, 2.0, 0.0}, {3.0, 0.0, 3.0}}} + }; TestMatrices = new Dictionary(); foreach (var name in TestData2D.Keys) @@ -120,9 +116,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(row, col); for (var i = 0; i < row; i++) { @@ -144,9 +140,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(order); for (var i = 0; i < order; i++) { @@ -157,7 +153,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } // Generate a matrix which is positive definite. - return matrixA.Transpose() * matrixA; + return matrixA.Transpose()*matrixA; } /// @@ -169,9 +165,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new DenseVector(order); for (var i = 0; i < order; i++) { @@ -191,9 +187,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(row, col); for (var i = 0; i < row; i++) { @@ -215,9 +211,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(order); for (var i = 0; i < order; i++) { @@ -228,7 +224,7 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double } // Generate a matrix which is positive definite. - return matrixA.Transpose() * matrixA; + return matrixA.Transpose()*matrixA; } /// @@ -240,9 +236,9 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Double { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new UserDefinedVector(order); for (var i = 0; i < order; i++) { diff --git a/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs b/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs index 09dbe2f5..7aa1bd03 100644 --- a/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs +++ b/src/UnitTests/LinearAlgebraTests/Single/MatrixLoader.cs @@ -3,7 +3,9 @@ // http://numerics.mathdotnet.com // http://github.com/mathnet/mathnet-numerics // http://mathnetnumerics.codeplex.com -// Copyright (c) 2009-2010 Math.NET +// +// 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 @@ -12,8 +14,10 @@ // 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 @@ -41,20 +45,12 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single /// /// Gets or sets test matrices values to use. /// - protected Dictionary TestData2D - { - get; - set; - } + protected Dictionary TestData2D { get; set; } /// /// Gets or sets test matrices instances to use. /// - protected Dictionary TestMatrices - { - get; - set; - } + protected Dictionary TestMatrices { get; set; } /// /// Creates a matrix for the given number of rows and columns. @@ -93,15 +89,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single public virtual void SetupMatrices() { TestData2D = new Dictionary - { - { "Singular3x3", new[,] { { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f }, { 1.0f, 1.0f, 2.0f } } }, - { "Square3x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f }, { -4.4f, 5.5f, 6.6f } } }, - { "Square4x4", new[,] { { -1.1f, -2.2f, -3.3f, -4.4f }, { 0.0f, 1.1f, 2.2f, 3.3f }, { 1.0f, 2.1f, 6.2f, 4.3f }, { -4.4f, 5.5f, 6.6f, -7.7f } } }, - { "Singular4x4", 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 } } }, - { "Tall3x2", new[,] { { -1.1f, -2.2f }, { 0.0f, 1.1f }, { -4.4f, 5.5f } } }, - { "Wide2x3", new[,] { { -1.1f, -2.2f, -3.3f }, { 0.0f, 1.1f, 2.2f } } }, - { "Symmetric3x3", new[,] { { 1.0f, 2.0f, 3.0f }, { 2.0f, 2.0f, 0.0f }, { 3.0f, 0.0f, 3.0f } } } - }; + { + {"Singular3x3", new[,] {{1.0f, 1.0f, 2.0f}, {1.0f, 1.0f, 2.0f}, {1.0f, 1.0f, 2.0f}}}, + {"Square3x3", new[,] {{-1.1f, -2.2f, -3.3f}, {0.0f, 1.1f, 2.2f}, {-4.4f, 5.5f, 6.6f}}}, + {"Square4x4", new[,] {{-1.1f, -2.2f, -3.3f, -4.4f}, {0.0f, 1.1f, 2.2f, 3.3f}, {1.0f, 2.1f, 6.2f, 4.3f}, {-4.4f, 5.5f, 6.6f, -7.7f}}}, + {"Singular4x4", 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}}}, + {"Tall3x2", new[,] {{-1.1f, -2.2f}, {0.0f, 1.1f}, {-4.4f, 5.5f}}}, + {"Wide2x3", new[,] {{-1.1f, -2.2f, -3.3f}, {0.0f, 1.1f, 2.2f}}}, + {"Symmetric3x3", new[,] {{1.0f, 2.0f, 3.0f}, {2.0f, 2.0f, 0.0f}, {3.0f, 0.0f, 3.0f}}} + }; TestMatrices = new Dictionary(); foreach (var name in TestData2D.Keys) @@ -120,15 +116,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(row, col); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { - matrixA[i, j] = (float)normal.Sample(); + matrixA[i, j] = (float) normal.Sample(); } } @@ -144,20 +140,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new DenseMatrix(order); for (var i = 0; i < order; i++) { for (var j = 0; j < order; j++) { - matrixA[i, j] = (float)normal.Sample(); + matrixA[i, j] = (float) normal.Sample(); } } // Generate a matrix which is positive definite. - return matrixA.Transpose() * matrixA; + return matrixA.Transpose()*matrixA; } /// @@ -169,13 +165,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new DenseVector(order); for (var i = 0; i < order; i++) { - v[i] = (float)normal.Sample(); + v[i] = (float) normal.Sample(); } return v; @@ -191,15 +187,15 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(row, col); for (var i = 0; i < row; i++) { for (var j = 0; j < col; j++) { - matrixA[i, j] = (float)normal.Sample(); + matrixA[i, j] = (float) normal.Sample(); } } @@ -215,20 +211,20 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var matrixA = new UserDefinedMatrix(order); for (var i = 0; i < order; i++) { for (var j = 0; j < order; j++) { - matrixA[i, j] = (float)normal.Sample(); + matrixA[i, j] = (float) normal.Sample(); } } // Generate a matrix which is positive definite. - return matrixA.Transpose() * matrixA; + return matrixA.Transpose()*matrixA; } /// @@ -240,13 +236,13 @@ namespace MathNet.Numerics.UnitTests.LinearAlgebraTests.Single { // Fill a matrix with standard random numbers. var normal = new Normal - { - RandomSource = new MersenneTwister(1) - }; + { + RandomSource = new MersenneTwister(1) + }; var v = new UserDefinedVector(order); for (var i = 0; i < order; i++) { - v[i] = (float)normal.Sample(); + v[i] = (float) normal.Sample(); } // Generate a matrix which is positive definite.