From db29d03b9a6950e956e19ed6aede9907cdd01e02 Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Wed, 1 May 2013 19:38:51 +0200 Subject: [PATCH] Use the new NonConvergenceException in more places, where appropriate --- .../LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs | 3 ++- .../LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs | 3 ++- .../LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs | 3 ++- .../LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs | 3 ++- .../LinearAlgebra/Complex/Factorization/DenseEvd.cs | 3 ++- src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs | 3 ++- src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs | 4 ++-- .../LinearAlgebra/Complex32/Factorization/DenseEvd.cs | 3 ++- .../LinearAlgebra/Complex32/Factorization/UserEvd.cs | 3 ++- .../LinearAlgebra/Complex32/Factorization/UserSvd.cs | 4 ++-- src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs | 6 ++++-- src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs | 3 ++- src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs | 4 ++-- src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs | 6 ++++-- src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs | 3 ++- src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs | 4 ++-- 16 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs index ace87e43..f7a83813 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex.cs @@ -2174,6 +2174,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// right singular vectors. /// The work array. Length should be at least . /// This is equivalent to the GESVD LAPACK routine. + /// public virtual void SingularValueDecomposition(bool computeVectors, Complex[] a, int rowsA, int columnsA, Complex[] s, Complex[] u, Complex[] vt, Complex[] work) { if (a == null) @@ -2559,7 +2560,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra // If too many iterations have been performed throw exception. if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays, diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs index 038ce62d..5cff5024 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Complex32.cs @@ -2172,6 +2172,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// right singular vectors. /// The work array. Length should be at least . /// This is equivalent to the GESVD LAPACK routine. + /// public virtual void SingularValueDecomposition(bool computeVectors, Complex32[] a, int rowsA, int columnsA, Complex32[] s, Complex32[] u, Complex32[] vt, Complex32[] work) { if (a == null) @@ -2557,7 +2558,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra // If too many iterations have been performed throw exception. if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays, diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs index a6f28baa..423c51e3 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Double.cs @@ -2059,6 +2059,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// right singular vectors. /// The work array. Length should be at least . /// This is equivalent to the GESVD LAPACK routine. + /// public virtual void SingularValueDecomposition(bool computeVectors, double[] a, int rowsA, int columnsA, double[] s, double[] u, double[] vt, double[] work) { if (a == null) @@ -2446,7 +2447,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra // If too many iterations have been performed throw exception. if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays, diff --git a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs index dc32bdd4..dbdbfce7 100644 --- a/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs +++ b/src/Numerics/Algorithms/LinearAlgebra/ManagedLinearAlgebraProvider.Single.cs @@ -2060,6 +2060,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra /// If is true, on exit VT contains the transposed /// right singular vectors. /// The work array. Length should be at least . + /// public virtual void SingularValueDecomposition(bool computeVectors, float[] a, int rowsA, int columnsA, float[] s, float[] u, float[] vt, float[] work) { if (a == null) @@ -2449,7 +2450,7 @@ namespace MathNet.Numerics.Algorithms.LinearAlgebra // If too many iterations have been performed throw exception. if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays, diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs index 8a2c1b0f..9b68ab59 100644 --- a/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs +++ b/src/Numerics/LinearAlgebra/Complex/Factorization/DenseEvd.cs @@ -226,6 +226,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// internal static void SymmetricDiagonalize(System.Numerics.Complex[] dataEv, double[] d, double[] e, int order) { const int Maxiter = 1000; @@ -324,7 +325,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps*tst1); } diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs index b8d6bed5..94369877 100644 --- a/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs +++ b/src/Numerics/LinearAlgebra/Complex/Factorization/UserEvd.cs @@ -246,6 +246,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// private void SymmetricDiagonalize(double[] d, double[] e, int order) { const int Maxiter = 1000; @@ -344,7 +345,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps * tst1); diff --git a/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs index 0d5c1e1c..22ce6cd6 100644 --- a/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs +++ b/src/Numerics/LinearAlgebra/Complex/Factorization/UserSvd.cs @@ -57,7 +57,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization /// The matrix to factor. /// Compute the singular U and VT vectors or not. /// If is null. - /// If SVD algorithm failed to converge with matrix . + /// public UserSvd(Matrix matrix, bool computeVectors) { if (matrix == null) @@ -356,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays. On diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs index 880a326a..96dea823 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/DenseEvd.cs @@ -227,6 +227,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// internal static void SymmetricDiagonalize(Numerics.Complex32[] dataEv, float[] d, float[] e, int order) { const int Maxiter = 1000; @@ -325,7 +326,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps*tst1); } diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs index d91773ac..30ebf305 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserEvd.cs @@ -250,6 +250,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// private void SymmetricDiagonalize(float[] d, float[] e, int order) { const int Maxiter = 1000; @@ -348,7 +349,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps * tst1); diff --git a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs index 14b55a83..c9aa3ecd 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Factorization/UserSvd.cs @@ -57,7 +57,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization /// The matrix to factor. /// Compute the singular U and VT vectors or not. /// If is null. - /// If SVD algorithm failed to converge with matrix . + /// public UserSvd(Matrix matrix, bool computeVectors) { if (matrix == null) @@ -356,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays. On diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs index 100e4292..6ef6cae2 100644 --- a/src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs +++ b/src/Numerics/LinearAlgebra/Double/Factorization/DenseEvd.cs @@ -256,6 +256,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// internal static void SymmetricDiagonalize(double[] a, double[] d, double[] e, int order) { const int maxiter = 1000; @@ -354,7 +355,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization // throw exception that Convergence Failed if (iter >= maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps*tst1); } @@ -528,6 +529,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization /// by Martin and Wilkinson, Handbook for Auto. Comp., /// Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// internal static void NonsymmetricReduceHessenberToRealSchur(double[] a, double[] matrixH, double[] d, double[] e, int order) { // Initialize @@ -732,7 +734,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization iter = iter + 1; if (iter >= 30*order) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // Look for two consecutive small sub-diagonal elements diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs index 3f0a5315..a60af1ad 100644 --- a/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs +++ b/src/Numerics/LinearAlgebra/Double/Factorization/UserEvd.cs @@ -288,6 +288,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// private void SymmetricDiagonalize(double[] d, double[] e, int order) { const int Maxiter = 1000; @@ -386,7 +387,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps * tst1); diff --git a/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs index eb69bf8c..5f673d5f 100644 --- a/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs +++ b/src/Numerics/LinearAlgebra/Double/Factorization/UserSvd.cs @@ -56,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization /// The matrix to factor. /// Compute the singular U and VT vectors or not. /// If is null. - /// If SVD algorithm failed to converge with matrix . + /// public UserSvd(Matrix matrix, bool computeVectors) { if (matrix == null) @@ -341,7 +341,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays. On diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs b/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs index 3e86aa98..1ac111e9 100644 --- a/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs +++ b/src/Numerics/LinearAlgebra/Single/Factorization/DenseEvd.cs @@ -256,6 +256,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// internal static void SymmetricDiagonalize(float[] a, float[] d, float[] e, int order) { const int Maxiter = 1000; @@ -354,7 +355,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps*tst1); } @@ -528,6 +529,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization /// by Martin and Wilkinson, Handbook for Auto. Comp., /// Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// internal static void NonsymmetricReduceHessenberToRealSchur(float[] a, float[] matrixH, float[] d, float[] e, int order) { // Initialize @@ -732,7 +734,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization iter = iter + 1; if (iter >= 30*order) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // Look for two consecutive small sub-diagonal elements diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs b/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs index 3053bae0..9246b8a9 100644 --- a/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs +++ b/src/Numerics/LinearAlgebra/Single/Factorization/UserEvd.cs @@ -289,6 +289,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization /// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for /// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding /// Fortran subroutine in EISPACK. + /// private void SymmetricDiagonalize(float[] d, float[] e, int order) { const int Maxiter = 1000; @@ -387,7 +388,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } } while (Math.Abs(e[l]) > eps * tst1); diff --git a/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs b/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs index 7dc2a343..c7dfafa9 100644 --- a/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs +++ b/src/Numerics/LinearAlgebra/Single/Factorization/UserSvd.cs @@ -56,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization /// The matrix to factor. /// Compute the singular U and VT vectors or not. /// If is null. - /// If SVD algorithm failed to converge with matrix . + /// public UserSvd(Matrix matrix, bool computeVectors) { if (matrix == null) @@ -341,7 +341,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Factorization // throw exception that Convergence Failed if (iter >= Maxiter) { - throw new ArgumentException(Resources.ConvergenceFailed); + throw new NonConvergenceException(); } // This section of the program inspects for negligible elements in the s and e arrays. On