Class GeneralizedMinimalResidualSolver
- java.lang.Object
-
- dev.nm.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.nonstationary.GeneralizedMinimalResidualSolver
-
- All Implemented Interfaces:
IterativeLinearSystemSolver
public class GeneralizedMinimalResidualSolver extends Object implements IterativeLinearSystemSolver
The Generalized Minimal Residual method (GMRES) is useful for solving a non-symmetric n-by-n linear system. It computes a sequence of orthogonal vectors (like MINRES), and combines these through a least-squares solve and update. However, unlike MINRES (and CG) it requires storing the whole sequence, so that a large amount of storage is needed. For this reason, a restarted version of this method is often used. In a restarted version, computation and storage costs are limited by specifying a fixed number of vectors to be generated. This implementation is a restarted version. In addition, it uses a Givens rotation to transform the intermediate Hessenberg matrix into an upper triangular matrix, such that convergence can be determined as soon as the residual norm at each sub-step is small enough. Only left preconditioning is supported.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dev.nm.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.IterativeLinearSystemSolver
IterativeLinearSystemSolver.Solution
-
-
Constructor Summary
Constructors Constructor Description GeneralizedMinimalResidualSolver(int m, int maxIteration, Tolerance tolerance)
Construct a GMRES solver with restarts.GeneralizedMinimalResidualSolver(int maxIteration, Tolerance tolerance)
Construct a full GMRES solver.GeneralizedMinimalResidualSolver(PreconditionerFactory leftPreconditionerFactory, int m, int maxIteration, Tolerance tolerance)
Construct a GMRES solver with restarts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IterativeLinearSystemSolver.Solution
solve(LSProblem problem)
IterativeLinearSystemSolver.Solution
solve(LSProblem problem, IterationMonitor<Vector> monitor)
Solves iteratively Ax = b until the solution converges, i.e., the norm of residual (b - Ax) is less than or equal to the threshold.
-
-
-
Constructor Detail
-
GeneralizedMinimalResidualSolver
public GeneralizedMinimalResidualSolver(PreconditionerFactory leftPreconditionerFactory, int m, int maxIteration, Tolerance tolerance)
Construct a GMRES solver with restarts.- Parameters:
leftPreconditionerFactory
- constructs a new left preconditionerm
- the solver restarts everym
iterations; Practically, asm
increases, the computational cost increases at least by O(m2)n because of the Gram-Schmidt orthogonalization. The memory cost increases by O(mn).maxIteration
- the maximum number of iterationstolerance
- the convergence threshold
-
GeneralizedMinimalResidualSolver
public GeneralizedMinimalResidualSolver(int m, int maxIteration, Tolerance tolerance)
Construct a GMRES solver with restarts.- Parameters:
m
- the solver restarts everym
iterations; Practically, asm
increases, the computational cost increases at least by O(m2)n because of the Gram-Schmidt orthogonalization. The memory cost increases by O(mn).maxIteration
- the maximum number of iterationstolerance
- the convergence threshold
-
GeneralizedMinimalResidualSolver
public GeneralizedMinimalResidualSolver(int maxIteration, Tolerance tolerance)
Construct a full GMRES solver.- Parameters:
maxIteration
- the maximum number of iterationstolerance
- the convergence threshold
-
-
Method Detail
-
solve
public IterativeLinearSystemSolver.Solution solve(LSProblem problem) throws ConvergenceFailure
- Throws:
ConvergenceFailure
-
solve
public IterativeLinearSystemSolver.Solution solve(LSProblem problem, IterationMonitor<Vector> monitor) throws ConvergenceFailure
Description copied from interface:IterativeLinearSystemSolver
Solves iterativelyAx = b
until the solution converges, i.e., the norm of residual (b - Ax) is less than or equal to the threshold.- Specified by:
solve
in interfaceIterativeLinearSystemSolver
- Parameters:
problem
- a system of linear equationsmonitor
- an iteration monitor- Returns:
- an (approximate) solution to the linear problem
- Throws:
ConvergenceFailure
- if the algorithm fails to converge
-
-