gko::solver::Gcr#
Generalised conjugate residual. Minimises the residual over the Krylov subspace using a long recurrence over the search directions; converges monotonically in residual norm for non-symmetric systems. Like GMRES, typically run with restart.
-
template<typename ValueType = default_precision>
class Gcr # Inherits from
public gko::EnableLinOp<Gcr<default_precision>>
public gko::solver::EnablePreconditionedIterativeSolver<default_precision, Gcr<default_precision>>
public gko::Transposable
GCR or the generalized conjugate residual method is an iterative type Krylov subspace method similar to GMRES which is suitable for nonsymmetric linear systems.
GCR maintains a sequence of search directions \( p_0, p_1, \ldots \) chosen so that the vectors \( A p_k \) are mutually orthogonal, \( \langle A p_i, A p_j \rangle = 0 \) for \( i \ne j \). At each iteration the residual is updated by orthogonal projection along \( A p_k \),
\[ \alpha_k = \frac{\langle r_k,\, A p_k \rangle} {\langle A p_k,\, A p_k \rangle}, \qquad r_{k+1} = r_k - \alpha_k\, A p_k, \]so the iterate \( x_k = x_0 + \sum_{j<k} \alpha_j\, p_j \) minimises \( \| r \|_2 \) over \( x_0 + \mathcal{K}_k(A, r_0) \) — the same minimisation property as GMRES, but with a long recurrence over the search directions instead of an Arnoldi basis and Hessenberg solve. The memory cost grows linearly with the iteration count, so GCR is typically run with a restart parameter (krylov_dim).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 GCR are merged into one step. 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 as iterative solvers use the data in x as an initial guess.
- Returns:
true as iterative solvers use the data in x as an initial guess.
-
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
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.