num::gmres¶
Defined in header <linear/solvers/gmres.hpp>
template <class Op, class V>
requires math::inner_product_space<V> && math::linear_operator<Op, V, V> &&
std::same_as<math::scalar_t<V>, real>
solver_result gmres(const Op &A, const V &b, V &x, gmres_options options = {}); // (1)
template <class Op, class M, class V>
requires math::inner_product_space<V> && math::linear_operator<Op, V, V> &&
math::linear_operator<M, V, V> && std::floating_point<math::scalar_t<V>>
solver_result gmres(const Op &A, const M &preconditioner, const V &b, V &x,
gmres_options options = {}); // (2)
solver_result gmres(const spmat &A, const vec<real> &b, vec<real> &x,
gmres_options options = {}); // (3)
solver_result gmres(const mat<real> &A, const vec<real> &b, vec<real> &x,
gmres_options options = {}); // (4)
(1) Solve general unsymmetric linear systems \(A x = b\) using restarted GMRES.
Constructs an orthogonal Arnoldi basis \(V_m\) and solves the projected least-squares problem \(\min \| \beta e_1 - \bar{H}_m y \|_2\) with Givens plane rotations.
(2) Right-preconditioned restarted GMRES: solves \(A M^{-1} u = b\), \(x = M^{-1} u\).
Right preconditioning keeps result.residual equal to \(\|b - Ax\|_2\), so the stopping test does not depend on the scaling of M. M need not be symmetric, as with ILU(0).
(3) Solve sparse linear systems \(A x = b\) using restarted GMRES.
(4) Solve dense linear systems \(A x = b\) using restarted GMRES with hardware backend dispatch.
Parameters¶
A: General square linear operator (dense, sparse, or matrix-free).b: Right-hand side vector.x: Solution vector (serves as initial guess on input, updated in place).options: Tolerance on \(\|b - A x\|_2\), iteration limit, and restart length.preconditioner: Approximate inverse applied on the right.
Return value¶
solver_result containing iteration count, final residual norm, and convergence boolean.
Exceptions¶
std::invalid_argument: If dimensions do not match.