# SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.nonstationary

## Class GeneralizedMinimalResidualSolver

• java.lang.Object
• com.numericalmethod.suanshu.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.

"Yousef Saad, "GMRES," in Iterative Methods for Sparse Linear Systems, 2nd ed. 2000, ch. 6, sec. 6.5, p. 157-172."

• ### Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.algebra.linear.matrix.doubles.matrixtype.sparse.solver.iterative.IterativeLinearSystemSolver

IterativeLinearSystemSolver.Solution
• ### Constructor Summary

Constructors
Constructor and 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
Modifier and Type Method and 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.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### 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 preconditioner
m - the solver restarts every m iterations; Practically, as m 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 iterations
tolerance - the convergence threshold
• #### GeneralizedMinimalResidualSolver

public GeneralizedMinimalResidualSolver(int m,
int maxIteration,
Tolerance tolerance)
Construct a GMRES solver with restarts.
Parameters:
m - the solver restarts every m iterations; Practically, as m 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 iterations
tolerance - the convergence threshold
• #### GeneralizedMinimalResidualSolver

public GeneralizedMinimalResidualSolver(int maxIteration,
Tolerance tolerance)
Construct a full GMRES solver.
Parameters:
maxIteration - the maximum number of iterations
tolerance - 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 iteratively
Ax = 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 interface IterativeLinearSystemSolver
Parameters:
problem - a system of linear equations
monitor - an iteration monitor
Returns:
an (approximate) solution to the linear problem
Throws:
ConvergenceFailure - if the algorithm fails to converge