diff --git a/src/Examples/LinearAlgebra/Factorization/QR.cs b/src/Examples/LinearAlgebra/Factorization/QR.cs index bc280b2b..5b46610e 100644 --- a/src/Examples/LinearAlgebra/Factorization/QR.cs +++ b/src/Examples/LinearAlgebra/Factorization/QR.cs @@ -29,7 +29,6 @@ namespace Examples.LinearAlgebra.Factorization using System; using System.Globalization; using MathNet.Numerics.LinearAlgebra.Double; - using MathNet.Numerics.LinearAlgebra.Generic.Factorization; /// /// QR factorization example. Any real square matrix A (m x n) may be decomposed as A = QR where Q is an orthogonal matrix (m x m) @@ -104,26 +103,26 @@ namespace Examples.LinearAlgebra.Factorization Console.WriteLine(); // Perform QR decomposition (Gram–Schmidt process) - qr = matrix.GramSchmidt(); + var gramSchmidt = matrix.GramSchmidt(); Console.WriteLine(@"QR decomposition (Gram–Schmidt process)"); // 5. Orthogonal Q matrix Console.WriteLine(@"5. Orthogonal Q matrix"); - Console.WriteLine(qr.Q.ToString("#0.00\t", formatProvider)); + Console.WriteLine(gramSchmidt.Q.ToString("#0.00\t", formatProvider)); Console.WriteLine(); // 6. Multiply Q matrix by its transpose gives identity matrix Console.WriteLine(@"6. Multiply Q matrix by its transpose gives identity matrix"); - Console.WriteLine((qr.Q.Transpose() * qr.Q).ToString("#0.00\t", formatProvider)); + Console.WriteLine((gramSchmidt.Q.Transpose() * gramSchmidt.Q).ToString("#0.00\t", formatProvider)); Console.WriteLine(); // 7. Upper triangular factor R Console.WriteLine(@"7. Upper triangular factor R"); - Console.WriteLine(qr.R.ToString("#0.00\t", formatProvider)); + Console.WriteLine(gramSchmidt.R.ToString("#0.00\t", formatProvider)); Console.WriteLine(); // 8. Reconstruct initial matrix: A = Q * R - reconstruct = qr.Q * qr.R; + reconstruct = gramSchmidt.Q * gramSchmidt.R; Console.WriteLine(@"8. Reconstruct initial matrix: A = Q*R"); Console.WriteLine(reconstruct.ToString("#0.00\t", formatProvider)); Console.WriteLine(); diff --git a/src/Numerics/LinearAlgebra/Generic/Factorization/ExtensionMethods.cs b/src/Numerics/LinearAlgebra/Complex/ExtensionMethods.cs similarity index 61% rename from src/Numerics/LinearAlgebra/Generic/Factorization/ExtensionMethods.cs rename to src/Numerics/LinearAlgebra/Complex/ExtensionMethods.cs index 520cf252..0b228593 100644 --- a/src/Numerics/LinearAlgebra/Generic/Factorization/ExtensionMethods.cs +++ b/src/Numerics/LinearAlgebra/Complex/ExtensionMethods.cs @@ -3,9 +3,7 @@ // 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 @@ -14,10 +12,8 @@ // 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 @@ -28,12 +24,12 @@ // OTHER DEALINGS IN THE SOFTWARE. // -namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization +namespace MathNet.Numerics.LinearAlgebra.Complex { - using System; using System.Numerics; + using Factorization; using Generic; - using Numerics; + using Generic.Factorization; /// /// Extension methods which return factorizations for the various matrix classes. @@ -45,10 +41,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization /// /// The matrix to factor. /// The Cholesky decomposition object. - /// Supported data types are double, single, , and . - public static Cholesky Cholesky(this Matrix matrix) where T : struct, IEquatable, IFormattable + public static Cholesky Cholesky(this Matrix matrix) { - return Factorization.Cholesky.Create(matrix); + return (Cholesky)Cholesky.Create(matrix); } /// @@ -56,10 +51,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization /// /// The matrix to factor. /// The LU decomposition object. - /// Supported data types are double, single, , and . - public static LU LU(this Matrix matrix) where T : struct, IEquatable, IFormattable + public static LU LU(this Matrix matrix) { - return Factorization.LU.Create(matrix); + return (LU)LU.Create(matrix); } /// @@ -67,10 +61,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization /// /// The matrix to factor. /// The QR decomposition object. - /// Supported data types are double, single, , and . - public static QR QR(this Matrix matrix) where T : struct, IEquatable, IFormattable + public static QR QR(this Matrix matrix) { - return Factorization.QR.Create(matrix); + return (QR)QR.Create(matrix); } /// @@ -78,10 +71,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization /// /// The matrix to factor. /// The QR decomposition object. - /// Supported data types are double, single, , and . - public static GramSchmidt GramSchmidt(this Matrix matrix) where T : struct, IEquatable, IFormattable + public static GramSchmidt GramSchmidt(this Matrix matrix) { - return Factorization.GramSchmidt.Create(matrix); + return (GramSchmidt)GramSchmidt.Create(matrix); } /// @@ -90,10 +82,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization /// The matrix to factor. /// Compute the singular U and VT vectors or not. /// The SVD decomposition object. - /// Supported data types are double, single, , and . - public static Svd Svd(this Matrix matrix, bool computeVectors) where T : struct, IEquatable, IFormattable + public static Svd Svd(this Matrix matrix, bool computeVectors) { - return Factorization.Svd.Create(matrix, computeVectors); + return (Svd)Svd.Create(matrix, computeVectors); } /// @@ -101,10 +92,9 @@ namespace MathNet.Numerics.LinearAlgebra.Generic.Factorization /// /// The matrix to factor. /// The EVD decomposition object. - /// Supported data types are double, single, , and . - public static Evd Evd(this Matrix matrix) where T : struct, IEquatable, IFormattable + public static Evd Evd(this Matrix matrix) { - return Factorization.Evd.Create(matrix); + return (Evd)Evd.Create(matrix); } } } diff --git a/src/Numerics/LinearAlgebra/Complex32/ExtensionMethods.cs b/src/Numerics/LinearAlgebra/Complex32/ExtensionMethods.cs new file mode 100644 index 00000000..8960dc5c --- /dev/null +++ b/src/Numerics/LinearAlgebra/Complex32/ExtensionMethods.cs @@ -0,0 +1,100 @@ +// +// 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.LinearAlgebra.Complex32 +{ + using Factorization; + using Generic; + using Generic.Factorization; + using Numerics; + + /// + /// Extension methods which return factorizations for the various matrix classes. + /// + public static class ExtensionMethods + { + /// + /// Computes the Cholesky decomposition for a matrix. + /// + /// The matrix to factor. + /// The Cholesky decomposition object. + public static Cholesky Cholesky(this Matrix matrix) + { + return (Cholesky)Cholesky.Create(matrix); + } + + /// + /// Computes the LU decomposition for a matrix. + /// + /// The matrix to factor. + /// The LU decomposition object. + public static LU LU(this Matrix matrix) + { + return (LU)LU.Create(matrix); + } + + /// + /// Computes the QR decomposition for a matrix. + /// + /// The matrix to factor. + /// The QR decomposition object. + public static QR QR(this Matrix matrix) + { + return (QR)QR.Create(matrix); + } + + /// + /// Computes the QR decomposition for a matrix using Modified Gram-Schmidt Orthogonalization. + /// + /// The matrix to factor. + /// The QR decomposition object. + public static GramSchmidt GramSchmidt(this Matrix matrix) + { + return (GramSchmidt)GramSchmidt.Create(matrix); + } + + /// + /// Computes the SVD decomposition for a matrix. + /// + /// The matrix to factor. + /// Compute the singular U and VT vectors or not. + /// The SVD decomposition object. + public static Svd Svd(this Matrix matrix, bool computeVectors) + { + return (Svd)Svd.Create(matrix, computeVectors); + } + + /// + /// Computes the EVD decomposition for a matrix. + /// + /// The matrix to factor. + /// The EVD decomposition object. + public static Evd Evd(this Matrix matrix) + { + return (Evd)Evd.Create(matrix); + } + } +} diff --git a/src/Numerics/LinearAlgebra/Double/ExtensionMethods.cs b/src/Numerics/LinearAlgebra/Double/ExtensionMethods.cs new file mode 100644 index 00000000..e46fb617 --- /dev/null +++ b/src/Numerics/LinearAlgebra/Double/ExtensionMethods.cs @@ -0,0 +1,99 @@ +// +// 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.LinearAlgebra.Double +{ + using Factorization; + using Generic; + using Generic.Factorization; + + /// + /// Extension methods which return factorizations for the various matrix classes. + /// + public static class ExtensionMethods + { + /// + /// Computes the Cholesky decomposition for a matrix. + /// + /// The matrix to factor. + /// The Cholesky decomposition object. + public static Cholesky Cholesky(this Matrix matrix) + { + return (Cholesky)Cholesky.Create(matrix); + } + + /// + /// Computes the LU decomposition for a matrix. + /// + /// The matrix to factor. + /// The LU decomposition object. + public static LU LU(this Matrix matrix) + { + return (LU)LU.Create(matrix); + } + + /// + /// Computes the QR decomposition for a matrix. + /// + /// The matrix to factor. + /// The QR decomposition object. + public static QR QR(this Matrix matrix) + { + return (QR)QR.Create(matrix); + } + + /// + /// Computes the QR decomposition for a matrix using Modified Gram-Schmidt Orthogonalization. + /// + /// The matrix to factor. + /// The QR decomposition object. + public static GramSchmidt GramSchmidt(this Matrix matrix) + { + return (GramSchmidt)GramSchmidt.Create(matrix); + } + + /// + /// Computes the SVD decomposition for a matrix. + /// + /// The matrix to factor. + /// Compute the singular U and VT vectors or not. + /// The SVD decomposition object. + public static Svd Svd(this Matrix matrix, bool computeVectors) + { + return (Svd)Svd.Create(matrix, computeVectors); + } + + /// + /// Computes the EVD decomposition for a matrix. + /// + /// The matrix to factor. + /// The EVD decomposition object. + public static Evd Evd(this Matrix matrix) + { + return (Evd)Evd.Create(matrix); + } + } +} diff --git a/src/Numerics/LinearAlgebra/Single/ExtensionMethods.cs b/src/Numerics/LinearAlgebra/Single/ExtensionMethods.cs new file mode 100644 index 00000000..b0855c7a --- /dev/null +++ b/src/Numerics/LinearAlgebra/Single/ExtensionMethods.cs @@ -0,0 +1,99 @@ +// +// 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.LinearAlgebra.Single +{ + using Factorization; + using Generic; + using Generic.Factorization; + + /// + /// Extension methods which return factorizations for the various matrix classes. + /// + public static class ExtensionMethods + { + /// + /// Computes the Cholesky decomposition for a matrix. + /// + /// The matrix to factor. + /// The Cholesky decomposition object. + public static Cholesky Cholesky(this Matrix matrix) + { + return (Cholesky)Cholesky.Create(matrix); + } + + /// + /// Computes the LU decomposition for a matrix. + /// + /// The matrix to factor. + /// The LU decomposition object. + public static LU LU(this Matrix matrix) + { + return (LU)LU.Create(matrix); + } + + /// + /// Computes the QR decomposition for a matrix. + /// + /// The matrix to factor. + /// The QR decomposition object. + public static QR QR(this Matrix matrix) + { + return (QR)QR.Create(matrix); + } + + /// + /// Computes the QR decomposition for a matrix using Modified Gram-Schmidt Orthogonalization. + /// + /// The matrix to factor. + /// The QR decomposition object. + public static GramSchmidt GramSchmidt(this Matrix matrix) + { + return (GramSchmidt)GramSchmidt.Create(matrix); + } + + /// + /// Computes the SVD decomposition for a matrix. + /// + /// The matrix to factor. + /// Compute the singular U and VT vectors or not. + /// The SVD decomposition object. + public static Svd Svd(this Matrix matrix, bool computeVectors) + { + return (Svd)Svd.Create(matrix, computeVectors); + } + + /// + /// Computes the EVD decomposition for a matrix. + /// + /// The matrix to factor. + /// The EVD decomposition object. + public static Evd Evd(this Matrix matrix) + { + return (Evd)Evd.Create(matrix); + } + } +} diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index 9fe250a4..2828f2cc 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -124,6 +124,7 @@ + @@ -146,6 +147,7 @@ Code + @@ -161,6 +163,7 @@ + @@ -256,6 +259,7 @@ + @@ -305,7 +309,6 @@ - diff --git a/src/Silverlight/Properties/AssemblyInfo.cs b/src/Silverlight/Properties/AssemblyInfo.cs index e01c184a..b87082ed 100644 --- a/src/Silverlight/Properties/AssemblyInfo.cs +++ b/src/Silverlight/Properties/AssemblyInfo.cs @@ -29,7 +29,6 @@ using System; using System.Reflection; using System.Resources; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Math.NET Numerics for Silverlight")] @@ -44,4 +43,5 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] [assembly: Guid("7b66646f-f0ee-425d-9065-910d1937a2df")] [assembly: NeutralResourcesLanguage("en")] -//[assembly: InternalsVisibleTo("MathNet.Numerics.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ed2314a577643d859571b8b9307c6ff2670525c4598fbb307e57ea65ebf5d4417284cb3da9181636480b623f4db8cc3c1947244ba069df0df86e2431621f51a488f9929519a1c5d0ae595f6e2d0e4094685f0c1229ff658360acbb9f63f1a0258e984dda00dc7ad4fd16dbb550ec1ef8a11df138402b7c1998ee224e652c839b")] +[assembly: AssemblyVersion("2011.04.17.0")] +[assembly: AssemblyFileVersion("2011.04.17")] \ No newline at end of file diff --git a/src/Silverlight/Silverlight.csproj b/src/Silverlight/Silverlight.csproj index 9a85a9d9..40188081 100644 --- a/src/Silverlight/Silverlight.csproj +++ b/src/Silverlight/Silverlight.csproj @@ -17,6 +17,21 @@ false true true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true