From d130913232ed24b2c2e1bd9225bdd89f8127cd4e Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Wed, 4 Sep 2013 20:19:50 +0200 Subject: [PATCH] LA: make IIterativeSolver generic & shared --- .../CompositeSolverExample.cs | 3 +- .../Complex/Solvers/IIterativeSolver.cs | 104 ------------------ .../Complex/Solvers/IIterativeSolverSetup.cs | 12 +- .../Complex/Solvers/Iterative/BiCgStab.cs | 2 +- .../Solvers/Iterative/CompositeSolver.cs | 6 +- .../Complex/Solvers/Iterative/GpBiCg.cs | 2 +- .../Complex/Solvers/Iterative/MlkBiCgStab.cs | 2 +- .../Complex/Solvers/Iterative/TFQMR.cs | 2 +- .../Complex32/Solvers/IIterativeSolver.cs | 99 ----------------- .../Solvers/IIterativeSolverSetup.cs | 9 +- .../Complex32/Solvers/Iterative/BiCgStab.cs | 2 +- .../Solvers/Iterative/CompositeSolver.cs | 6 +- .../Complex32/Solvers/Iterative/GpBiCg.cs | 2 +- .../Solvers/Iterative/MlkBiCgStab.cs | 2 +- .../Complex32/Solvers/Iterative/TFQMR.cs | 2 +- .../Double/Solvers/IIterativeSolver.cs | 97 ---------------- .../Double/Solvers/IIterativeSolverSetup.cs | 4 +- .../Double/Solvers/Iterative/BiCgStab.cs | 2 +- .../Solvers/Iterative/CompositeSolver.cs | 6 +- .../Double/Solvers/Iterative/GpBiCg.cs | 2 +- .../Double/Solvers/Iterative/MlkBiCgStab.cs | 2 +- .../Double/Solvers/Iterative/TFQMR.cs | 2 +- .../Single/Solvers/IIterativeSolverSetup.cs | 4 +- .../Single/Solvers/Iterative/BiCgStab.cs | 2 +- .../Solvers/Iterative/CompositeSolver.cs | 6 +- .../Single/Solvers/Iterative/GpBiCg.cs | 2 +- .../Single/Solvers/Iterative/MlkBiCgStab.cs | 2 +- .../Single/Solvers/Iterative/TFQMR.cs | 2 +- .../{Single => }/Solvers/IIterativeSolver.cs | 20 ++-- src/Numerics/Numerics.csproj | 5 +- 30 files changed, 63 insertions(+), 350 deletions(-) delete mode 100644 src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolver.cs delete mode 100644 src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolver.cs delete mode 100644 src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolver.cs rename src/Numerics/LinearAlgebra/{Single => }/Solvers/IIterativeSolver.cs (83%) diff --git a/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs b/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs index 9b192957..d51bf898 100644 --- a/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs +++ b/src/Examples/LinearAlgebra/IterativeSolvers/CompositeSolverExample.cs @@ -31,6 +31,7 @@ using MathNet.Numerics.LinearAlgebra.Double; using MathNet.Numerics.LinearAlgebra.Double.Solvers; using MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative; using MathNet.Numerics.LinearAlgebra.Double.Solvers.StopCriterium; +using MathNet.Numerics.LinearAlgebra.Solvers; using MathNet.Numerics.LinearAlgebra.Solvers.StopCriterium; namespace Examples.LinearAlgebra.IterativeSolversExamples @@ -175,7 +176,7 @@ namespace Examples.LinearAlgebra.IterativeSolversExamples /// given by this setup. /// /// A new . - public IIterativeSolver CreateNew() + public IIterativeSolver CreateNew() { return new BiCgStab(); } diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolver.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolver.cs deleted file mode 100644 index cbe09f7e..00000000 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolver.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// 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. -// - -using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.Status; - -namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers -{ - -#if NOSYSNUMERICS - using Complex = Numerics.Complex; -#else - using Complex = System.Numerics.Complex; -#endif - - /// - /// Defines the interface for classes that solve the matrix equation Ax = b in - /// an iterative manner. - /// - public interface IIterativeSolver - { - /// - /// Stops the solve process. - /// - /// - /// Note that it may take an indetermined amount of time for the solver to actually stop the process. - /// - void StopSolve(); - - /// - /// Sets the that will be used to track the iterative process. - /// - /// The iterator. - void SetIterator(IIterator iterator); - - /// - /// Gets the status of the iteration once the calculation is finished. - /// - ICalculationStatus IterationResult { get; } - - /// - /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the - /// solution vector and x is the unknown vector. - /// - /// The coefficient matrix, A. - /// The solution vector, b. - /// The result vector, x. - Vector Solve(Matrix matrix, Vector vector); - - /// - /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the - /// solution vector and x is the unknown vector. - /// - /// The coefficient matrix, A. - /// The solution vector, b - /// The result vector, x - void Solve(Matrix matrix, Vector input, Vector result); - - /// - /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the - /// solution matrix and X is the unknown matrix. - /// - /// The coefficient matrix, A. - /// The solution matrix, B. - /// The result matrix, X. - Matrix Solve(Matrix matrix, Matrix input); - - /// - /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the - /// solution matrix and X is the unknown matrix. - /// - /// The coefficient matrix, A. - /// The solution matrix, B. - /// The result matrix, X - void Solve(Matrix matrix, Matrix input, Matrix result); - } -} diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolverSetup.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolverSetup.cs index 50bf1783..ad4363f8 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolverSetup.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/IIterativeSolverSetup.cs @@ -28,9 +28,17 @@ // OTHER DEALINGS IN THE SOFTWARE. // +using System; +using MathNet.Numerics.LinearAlgebra.Solvers; + namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers { - using System; + +#if NOSYSNUMERICS + using Complex = Numerics.Complex; +#else + using Complex = System.Numerics.Complex; +#endif /// /// Defines the interface for objects that can create an iterative solver with @@ -54,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers /// given by this setup. /// /// A new . - IIterativeSolver CreateNew(); + IIterativeSolver CreateNew(); /// /// Gets the relative speed of the solver. diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs index 89c0c9e7..39898d4f 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/BiCgStab.cs @@ -73,7 +73,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// solver. /// /// - public sealed class BiCgStab : IIterativeSolver + public sealed class BiCgStab : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs index 1aed113d..79fc9c9e 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/CompositeSolver.cs @@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// Note that if an iterator is passed to this solver it will be used for all the sub-solvers. /// /// - public sealed class CompositeSolver : IIterativeSolver + public sealed class CompositeSolver : IIterativeSolver { #region Internal class - DoubleComparer /// @@ -340,7 +340,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// /// The collection of solvers that will be used to /// - private readonly List _solvers = new List(); + private readonly List> _solvers = new List>(); /// /// The status of the calculation. @@ -361,7 +361,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// The solver that is currently running. Reference is used to be able to stop the /// solver if the user cancels the solve process. /// - private IIterativeSolver _currentSolver; + private IIterativeSolver _currentSolver; /// /// Initializes a new instance of the class with the default iterator. diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs index d3be8fe1..bf65fa2f 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/GpBiCg.cs @@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// solver. /// /// - public sealed class GpBiCg : IIterativeSolver + public sealed class GpBiCg : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs index 0da5d2b1..d9daf43b 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/MlkBiCgStab.cs @@ -71,7 +71,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// solver. /// /// - public sealed class MlkBiCgStab : IIterativeSolver + public sealed class MlkBiCgStab : IIterativeSolver { /// /// The default number of starting vectors. diff --git a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs index 6d83d4d2..88c6c4ee 100644 --- a/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs +++ b/src/Numerics/LinearAlgebra/Complex/Solvers/Iterative/TFQMR.cs @@ -61,7 +61,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex.Solvers.Iterative /// solver. /// /// - public sealed class TFQMR : IIterativeSolver + public sealed class TFQMR : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolver.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolver.cs deleted file mode 100644 index 53431dd0..00000000 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolver.cs +++ /dev/null @@ -1,99 +0,0 @@ -// -// 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. -// - -using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.Status; - -namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers -{ - using Numerics; - - /// - /// Defines the interface for classes that solve the matrix equation Ax = b in - /// an iterative manner. - /// - public interface IIterativeSolver - { - /// - /// Stops the solve process. - /// - /// - /// Note that it may take an indetermined amount of time for the solver to actually stop the process. - /// - void StopSolve(); - - /// - /// Sets the that will be used to track the iterative process. - /// - /// The iterator. - void SetIterator(IIterator iterator); - - /// - /// Gets the status of the iteration once the calculation is finished. - /// - ICalculationStatus IterationResult { get; } - - /// - /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the - /// solution vector and x is the unknown vector. - /// - /// The coefficient matrix, A. - /// The solution vector, b. - /// The result vector, x. - Vector Solve(Matrix matrix, Vector vector); - - /// - /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the - /// solution vector and x is the unknown vector. - /// - /// The coefficient matrix, A. - /// The solution vector, b - /// The result vector, x - void Solve(Matrix matrix, Vector input, Vector result); - - /// - /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the - /// solution matrix and X is the unknown matrix. - /// - /// The coefficient matrix, A. - /// The solution matrix, B. - /// The result matrix, X. - Matrix Solve(Matrix matrix, Matrix input); - - /// - /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the - /// solution matrix and X is the unknown matrix. - /// - /// The coefficient matrix, A. - /// The solution matrix, B. - /// The result matrix, X - void Solve(Matrix matrix, Matrix input, Matrix result); - } -} diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolverSetup.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolverSetup.cs index f98f5de3..fb055c98 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolverSetup.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/IIterativeSolverSetup.cs @@ -28,9 +28,12 @@ // OTHER DEALINGS IN THE SOFTWARE. // +using System; +using MathNet.Numerics.LinearAlgebra.Solvers; + namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers { - using System; + using Numerics; /// /// Defines the interface for objects that can create an iterative solver with @@ -53,8 +56,8 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers /// Creates a fully functional iterative solver with the default settings /// given by this setup. /// - /// A new . - IIterativeSolver CreateNew(); + /// A new . + IIterativeSolver CreateNew(); /// /// Gets the relative speed of the solver. diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs index a80d2eb0..4cca5644 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/BiCgStab.cs @@ -67,7 +67,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// solver. /// /// - public sealed class BiCgStab : IIterativeSolver + public sealed class BiCgStab : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs index e131a836..d53ddd74 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/CompositeSolver.cs @@ -56,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// Note that if an iterator is passed to this solver it will be used for all the sub-solvers. /// /// - public sealed class CompositeSolver : IIterativeSolver + public sealed class CompositeSolver : IIterativeSolver { #region Internal class - DoubleComparer /// @@ -335,7 +335,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// /// The collection of solvers that will be used to /// - private readonly List _solvers = new List(); + private readonly List> _solvers = new List>(); /// /// The status of the calculation. @@ -356,7 +356,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// The solver that is currently running. Reference is used to be able to stop the /// solver if the user cancels the solve process. /// - private IIterativeSolver _currentSolver; + private IIterativeSolver _currentSolver; /// /// Initializes a new instance of the class with the default iterator. diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs index 7799cb11..1e9c63fc 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/GpBiCg.cs @@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// solver. /// /// - public sealed class GpBiCg : IIterativeSolver + public sealed class GpBiCg : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs index 1b6a631e..fdc286ad 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/MlkBiCgStab.cs @@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// solver. /// /// - public sealed class MlkBiCgStab : IIterativeSolver + public sealed class MlkBiCgStab : IIterativeSolver { /// /// The default number of starting vectors. diff --git a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs index 402bf1cc..8ad883f9 100644 --- a/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs +++ b/src/Numerics/LinearAlgebra/Complex32/Solvers/Iterative/TFQMR.cs @@ -55,7 +55,7 @@ namespace MathNet.Numerics.LinearAlgebra.Complex32.Solvers.Iterative /// solver. /// /// - public sealed class TFQMR : IIterativeSolver + public sealed class TFQMR : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolver.cs b/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolver.cs deleted file mode 100644 index 6f2c2fe3..00000000 --- a/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolver.cs +++ /dev/null @@ -1,97 +0,0 @@ -// -// 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. -// - -using MathNet.Numerics.LinearAlgebra.Solvers; -using MathNet.Numerics.LinearAlgebra.Solvers.Status; - -namespace MathNet.Numerics.LinearAlgebra.Double.Solvers -{ - /// - /// Defines the interface for classes that solve the matrix equation Ax = b in - /// an iterative manner. - /// - public interface IIterativeSolver - { - /// - /// Stops the solve process. - /// - /// - /// Note that it may take an indetermined amount of time for the solver to actually stop the process. - /// - void StopSolve(); - - /// - /// Sets the that will be used to track the iterative process. - /// - /// The iterator. - void SetIterator(IIterator iterator); - - /// - /// Gets the status of the iteration once the calculation is finished. - /// - ICalculationStatus IterationResult { get; } - - /// - /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the - /// solution vector and x is the unknown vector. - /// - /// The coefficient matrix, A. - /// The solution vector, b. - /// The result vector, x. - Vector Solve(Matrix matrix, Vector vector); - - /// - /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the - /// solution vector and x is the unknown vector. - /// - /// The coefficient matrix, A. - /// The solution vector, b - /// The result vector, x - void Solve(Matrix matrix, Vector input, Vector result); - - /// - /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the - /// solution matrix and X is the unknown matrix. - /// - /// The coefficient matrix, A. - /// The solution matrix, B. - /// The result matrix, X. - Matrix Solve(Matrix matrix, Matrix input); - - /// - /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the - /// solution matrix and X is the unknown matrix. - /// - /// The coefficient matrix, A. - /// The solution matrix, B. - /// The result matrix, X - void Solve(Matrix matrix, Matrix input, Matrix result); - } -} diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolverSetup.cs b/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolverSetup.cs index 86ec59f4..75aff271 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolverSetup.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/IIterativeSolverSetup.cs @@ -28,6 +28,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // +using MathNet.Numerics.LinearAlgebra.Solvers; + namespace MathNet.Numerics.LinearAlgebra.Double.Solvers { using System; @@ -54,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers /// given by this setup. /// /// A new . - IIterativeSolver CreateNew(); + IIterativeSolver CreateNew(); /// /// Gets the relative speed of the solver. diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs index ed65645c..601f1517 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/BiCgStab.cs @@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// solver. /// /// - public sealed class BiCgStab : IIterativeSolver + public sealed class BiCgStab : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs index 76b815bf..1dd1e7d4 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/CompositeSolver.cs @@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// Note that if an iterator is passed to this solver it will be used for all the sub-solvers. /// /// - public sealed class CompositeSolver : IIterativeSolver + public sealed class CompositeSolver : IIterativeSolver { #region Internal class - DoubleComparer /// @@ -330,7 +330,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// /// The collection of solvers that will be used to /// - private readonly List _solvers = new List(); + private readonly List> _solvers = new List>(); /// /// The status of the calculation. @@ -351,7 +351,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// The solver that is currently running. Reference is used to be able to stop the /// solver if the user cancels the solve process. /// - private IIterativeSolver _currentSolver; + private IIterativeSolver _currentSolver; /// /// Initializes a new instance of the class with the default iterator. diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs index 222724de..fb1f2d0e 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/GpBiCg.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// solver. /// /// - public sealed class GpBiCg : IIterativeSolver + public sealed class GpBiCg : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs index 8f2c89ad..527861ae 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/MlkBiCgStab.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// solver. /// /// - public sealed class MlkBiCgStab : IIterativeSolver + public sealed class MlkBiCgStab : IIterativeSolver { /// /// The default number of starting vectors. diff --git a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs index 34cc2a58..21c165ad 100644 --- a/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs +++ b/src/Numerics/LinearAlgebra/Double/Solvers/Iterative/TFQMR.cs @@ -53,7 +53,7 @@ namespace MathNet.Numerics.LinearAlgebra.Double.Solvers.Iterative /// solver. /// /// - public sealed class TFQMR : IIterativeSolver + public sealed class TFQMR : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolverSetup.cs b/src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolverSetup.cs index 5a77d291..9be6a3ba 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolverSetup.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolverSetup.cs @@ -28,6 +28,8 @@ // OTHER DEALINGS IN THE SOFTWARE. // +using MathNet.Numerics.LinearAlgebra.Solvers; + namespace MathNet.Numerics.LinearAlgebra.Single.Solvers { using System; @@ -54,7 +56,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// given by this setup. /// /// A new . - IIterativeSolver CreateNew(); + IIterativeSolver CreateNew(); /// /// Gets the relative speed of the solver. diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs index 3a2c996d..1666c393 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/BiCgStab.cs @@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// solver. /// /// - public sealed class BiCgStab : IIterativeSolver + public sealed class BiCgStab : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs index 8a6868b7..73e8f095 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/CompositeSolver.cs @@ -54,7 +54,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// Note that if an iterator is passed to this solver it will be used for all the sub-solvers. /// /// - public sealed class CompositeSolver : IIterativeSolver + public sealed class CompositeSolver : IIterativeSolver { #region Internal class - DoubleComparer /// @@ -333,7 +333,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// /// The collection of solvers that will be used to /// - private readonly List _solvers = new List(); + private readonly List> _solvers = new List>(); /// /// The status of the calculation. @@ -354,7 +354,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// The solver that is currently running. Reference is used to be able to stop the /// solver if the user cancels the solve process. /// - private IIterativeSolver _currentSolver; + private IIterativeSolver _currentSolver; /// /// Initializes a new instance of the class with the default iterator. diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs index e3718bfe..cba0ae66 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/GpBiCg.cs @@ -63,7 +63,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// solver. /// /// - public sealed class GpBiCg : IIterativeSolver + public sealed class GpBiCg : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs index a7f6517e..3b8dfa4f 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/MlkBiCgStab.cs @@ -62,7 +62,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// solver. /// /// - public sealed class MlkBiCgStab : IIterativeSolver + public sealed class MlkBiCgStab : IIterativeSolver { /// /// The default number of starting vectors. diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs index 5a3917fe..102fa027 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs +++ b/src/Numerics/LinearAlgebra/Single/Solvers/Iterative/TFQMR.cs @@ -53,7 +53,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers.Iterative /// solver. /// /// - public sealed class TFQMR : IIterativeSolver + public sealed class TFQMR : IIterativeSolver { /// /// The status used if there is no status, i.e. the solver hasn't run yet and there is no diff --git a/src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolver.cs b/src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs similarity index 83% rename from src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolver.cs rename to src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs index efce1c3d..f6240297 100644 --- a/src/Numerics/LinearAlgebra/Single/Solvers/IIterativeSolver.cs +++ b/src/Numerics/LinearAlgebra/Solvers/IIterativeSolver.cs @@ -28,16 +28,16 @@ // OTHER DEALINGS IN THE SOFTWARE. // -using MathNet.Numerics.LinearAlgebra.Solvers; +using System; using MathNet.Numerics.LinearAlgebra.Solvers.Status; -namespace MathNet.Numerics.LinearAlgebra.Single.Solvers +namespace MathNet.Numerics.LinearAlgebra.Solvers { /// - /// Defines the interface for classes that solve the matrix equation Ax = b in + /// Defines the interface for classes that solve the matrix equation Ax = b in /// an iterative manner. /// - public interface IIterativeSolver + public interface IIterativeSolver where T : struct, IEquatable, IFormattable { /// /// Stops the solve process. @@ -48,10 +48,10 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers void StopSolve(); /// - /// Sets the that will be used to track the iterative process. + /// Sets the that will be used to track the iterative process. /// /// The iterator. - void SetIterator(IIterator iterator); + void SetIterator(IIterator iterator); /// /// Gets the status of the iteration once the calculation is finished. @@ -65,7 +65,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// The coefficient matrix, A. /// The solution vector, b. /// The result vector, x. - Vector Solve(Matrix matrix, Vector vector); + Vector Solve(Matrix matrix, Vector vector); /// /// Solves the matrix equation Ax = b, where A is the coefficient matrix, b is the @@ -74,7 +74,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// The coefficient matrix, A. /// The solution vector, b /// The result vector, x - void Solve(Matrix matrix, Vector input, Vector result); + void Solve(Matrix matrix, Vector input, Vector result); /// /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the @@ -83,7 +83,7 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// The coefficient matrix, A. /// The solution matrix, B. /// The result matrix, X. - Matrix Solve(Matrix matrix, Matrix input); + Matrix Solve(Matrix matrix, Matrix input); /// /// Solves the matrix equation AX = B, where A is the coefficient matrix, B is the @@ -92,6 +92,6 @@ namespace MathNet.Numerics.LinearAlgebra.Single.Solvers /// The coefficient matrix, A. /// The solution matrix, B. /// The result matrix, X - void Solve(Matrix matrix, Matrix input, Matrix result); + void Solve(Matrix matrix, Matrix input, Matrix result); } } diff --git a/src/Numerics/Numerics.csproj b/src/Numerics/Numerics.csproj index 5750b17e..83f39185 100644 --- a/src/Numerics/Numerics.csproj +++ b/src/Numerics/Numerics.csproj @@ -190,7 +190,6 @@ - @@ -208,7 +207,6 @@ - @@ -223,7 +221,7 @@ - + @@ -314,7 +312,6 @@ -