gko::batch::solver::Cg#

Batched conjugate gradient. Runs an independent CG iteration for each batch item on the same executor, sharing kernel launches across items. Each item terminates on its own once its residual_norm falls below the tolerance; the batch-wide solve completes when every item has either converged or hit the max_iterations cap.

template<typename ValueType = default_precision>
class Cg #

Inherits from

  • public gko::batch::solver::EnableBatchSolver<Cg<default_precision>, default_precision>

Cg or the Conjugate Gradient is a Krylov subspace solver. It is a short recurrence solver that is generally used to solve linear systems with SPD matrices.

This solver solves a batch of linear systems using the Cg algorithm. Each linear system in the batch can converge independently.

Unless otherwise specified via the preconditioner factory parameter, this implementation does not use any preconditioner by default. The type of tolerance (absolute or relative) and the maximum number of iterations to be used in the stopping criterion can be set via the factory parameters.

Note

The tolerance check is against the internal residual computed within the solver process. This implicit (internal) residual can diverge from the true residual (||b - Ax||). A posterori checks (by computing the true residual, ||b - Ax||) are recommended to ensure that the solution has converged to the desired tolerance.

Template Parameters:

ValueType – precision of matrix elements

struct parameters_type #

Inherits from

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