Skip to content

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 a general system by restarted GMRES: \(A x = b\).

(2) Solve a general system by GMRES with a preconditioner on the right: \(A M^{-1} u = b\), \(x = M^{-1} u\).

(3) Solve a sparse system by restarted GMRES: \(A x = b\).

(4) Solve a dense system by restarted GMRES: \(A x = b\).

Exceptions

  • std::invalid_argument: If dimensions mismatch.

Notes

result.residual is the true residual \(\|b - A x\|_2\), whatever the scale of M.