Class GeneralizedConjugateResidualSolver
- java.lang.Object
-
- dev.nm.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.nonstationary.GeneralizedConjugateResidualSolver
-
- All Implemented Interfaces:
IterativeLinearSystemSolver
public class GeneralizedConjugateResidualSolver extends Object implements IterativeLinearSystemSolver
The Generalized Conjugate Residual method (GCR) is useful for solving a non-symmetric n-by-n linear system. GCR computes the next Krylov basis vector as a linear combination of the current residual and all previous basis vectors. This implementation is a restarted version of GCR. 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 GeneralizedConjugateResidualSolver(int m, int maxIteration, Tolerance tolerance)
Construct a GCR solver with restarts.GeneralizedConjugateResidualSolver(int maxIteration, Tolerance tolerance)
Construct a full GCR solver.GeneralizedConjugateResidualSolver(PreconditionerFactory leftPreconditionerFactory, int m, int maxIteration, Tolerance tolerance)
Construct a GCR 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
-
GeneralizedConjugateResidualSolver
public GeneralizedConjugateResidualSolver(PreconditionerFactory leftPreconditionerFactory, int m, int maxIteration, Tolerance tolerance)
Construct a GCR solver with restarts.- Parameters:
leftPreconditionerFactory
- constructs a new left preconditionerm
- the solver restarts everym
iterationsmaxIteration
- the maximum number of iterationstolerance
- the convergence threshold
-
GeneralizedConjugateResidualSolver
public GeneralizedConjugateResidualSolver(int m, int maxIteration, Tolerance tolerance)
Construct a GCR solver with restarts.- Parameters:
m
- the solver restarts everym
iterationsmaxIteration
- the maximum number of iterationstolerance
- the convergence threshold
-
GeneralizedConjugateResidualSolver
public GeneralizedConjugateResidualSolver(int maxIteration, Tolerance tolerance)
Construct a full GCR 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
-
-