gko::solver::Gmres#

Generalised minimal residual. Builds an orthonormal Krylov basis and minimises the residual over it; the most robust general-purpose non-symmetric Krylov method. Memory grows linearly with iteration count, so it is typically run with restart (the krylov_dim factory parameter). A positive restart_ratio additionally ends a cycle as soon as the residual has dropped to that fraction of its value at the start of the cycle (useful values are around 1e-3 to 1e-1, or about 0.9 for slowly converging cycles); krylov_dim then acts as the cap on the basis size.

template<typename ValueType = default_precision>
class Gmres #

Inherits from

  • public gko::LinOp

  • public gko::solver::EnablePreconditionedIterativeSolver<default_precision, Gmres<default_precision>>

  • public gko::solver::EnableApplyWithInitialGuess<Gmres<default_precision>>

  • public gko::Transposable

GMRES or the generalized minimal residual method is an iterative type Krylov subspace method which is suitable for nonsymmetric linear systems.

The Arnoldi process builds an orthonormal basis \( V_m \) of the Krylov subspace

\[ \mathcal{K}_m(A, r_0) = \mathrm{span}\{r_0, A r_0, A^2 r_0, \ldots, A^{m-1} r_0\}, \]
and produces an upper Hessenberg matrix \( \bar H_m \) satisfying the Arnoldi relation \( A V_m = V_{m+1} \bar H_m \). GMRES then chooses the approximate solution \( x_m = x_0 + V_m y_m \) with \( y_m \) minimizing the residual norm over the subspace,
\[ y_m = \arg\min_{y \in \mathbb{R}^m} \| \beta e_1 - \bar H_m y \|_2, \qquad \beta = \| r_0 \|_2. \]

The implementation in Ginkgo makes use of the merged kernel to make the best use of data locality. The inner operations in one iteration of GMRES are merged into 2 separate steps. Modified Gram-Schmidt is used.

Template Parameters:

ValueType – precision of matrix elements

Public Functions

virtual std::unique_ptr<LinOp> transpose() const override#

Returns a LinOp representing the transpose of the Transposable object.

Returns:

a pointer to the new transposed object

virtual std::unique_ptr<LinOp> conj_transpose() const override#

Returns a LinOp representing the conjugate transpose of the Transposable object.

Returns:

a pointer to the new conjugate transposed object

inline bool apply_uses_initial_guess() const override#

Return true if the solver will use the initial guess provided by the user.

Returns:

true if the solver was build with initial_guess_mode::provided.

inline size_type get_krylov_dim() const#

Gets the Krylov dimension of the solver

Returns:

the Krylov dimension

inline void set_krylov_dim(size_type other)#

Sets the Krylov dimension

Parameters:

other – the new Krylov dimension

inline remove_complex<ValueType> get_restart_ratio() const#

Returns the restart ratio.

Returns:

the restart ratio

inline void set_restart_ratio(remove_complex<ValueType> other)#

Sets the restart ratio.

Parameters:

other – the new restart ratio

Public Static Functions

static parameters_type parse(
const config::pnode &config,
const config::registry &context,
const config::type_descriptor &td_for_child = config::make_type_descriptor<ValueType>(),
)#

Create the parameters from the property_tree. Because this is directly tied to the specific type, the value/index type settings within config are ignored and type_descriptor is only used for children configs.

Parameters:
  • config – the property tree for setting

  • context – the registry

  • td_for_child – the type descriptor for children configs. The default uses the value type of this class.

Returns:

parameters

struct parameters_type #

Inherits from

  • public gko::solver::enable_preconditioned_iterative_solver_factory_parameters<parameters_type, Factory>

Public Members

size_type krylov_dim#

Krylov subspace dimension/restart value.

With restart_ratio positive this caps the basis size rather than setting the restart length, and a cycle ends at whichever criterion is met first. It remains the memory bound.

remove_complex<ValueType> restart_ratio#

Restart ratio.

A cycle ends once the residual has fallen to this fraction of its value at the start of the cycle, that is, once \( \|r_i - A d_i\| \leq \text{restart\_ratio} \cdot \|r_i\| \) holds for every right-hand side still running, with \(r_i\) the residual at the start of the cycle and \(d_i\) the correction built so far. This bounds the normwise backward error of the correction, which is what makes the restarted method analyzable as iterative refinement. A cycle cut short by krylov_dim carries no such bound.

It is a per-cycle reduction, not a convergence tolerance, so useful values are far larger than a stopping criterion’s. It must lie in [0, 1) and must exceed the reduction a krylov_dim-step cycle achieves, or it never fires: use 1e-3 to 1e-1 when a cycle gains orders of magnitude, and around 0.9 when it gains only a few percent.

Zero, the default, disables the criterion.

For the criterion and its analysis, see sec. 4.2 of A Modular Framework for the Backward Error Analysis of GMRES.

bool flexible#

Flexible GMRES

gmres::ortho_method ortho_method#

Orthogonalization method

initial_guess_mode default_initial_guess#

Default initial guess mode. The available options are under initial_guess_mode.