Skip to content

num::pcg

Defined in header <linear/solvers/pcg.hpp>

template <class Op, class M, class V>
requires math::inner_product_space<V> && math::spd_operator<Op, V> &&
         math::spd_operator<M, V> && std::floating_point<math::scalar_t<V>>
solver_result pcg(const Op &A, const M &preconditioner, const V &b, V &x,
                  pcg_options options = {});  // (1)

template <class Subspace, class Op, class M, class V>
requires math::inner_product_space<V> && math::linear_subspace_of<Subspace, V> &&
         math::linear_operator<Op, V, V> && math::linear_operator<M, V, V> &&
         claims<Op, law::spd_on<Subspace>> && claims<M, law::spd_on<Subspace>> &&
         std::floating_point<math::scalar_t<V>>
solver_result pcg(const Op &A, const M &preconditioner, const V &b, V &x,
                  const Subspace &subspace, pcg_options options = {});  // (2)

(1) Solve \(A x = b\) using Preconditioned Conjugate Gradient (PCG).

Accelerates CG convergence using a symmetric positive-definite preconditioner \(M \approx A^{-1}\). Both the system operator A and the preconditioner M must claim law::spd.

(2) PCG on a named invariant subspace.

Evidence for A and M is tied to the exact same Subspace type, and membership is checked throughout the recurrence.

Parameters

  • A: Symmetric positive-definite linear operator or matrix wrapper.
  • preconditioner: preconditioner operator approximating \(A^{-1}\) (e.g. Jacobi, Incomplete Cholesky).
  • b: Right-hand side vector.
  • x: Solution vector (serves as initial guess on input, updated in place).
  • options: Tolerance on the residual norm and iteration limit.

Return value

solver_result containing iteration count, final residual norm, and convergence boolean.

Exceptions

  • std::invalid_argument: If dimensions of A, preconditioner, b, and x do not match.

See also

cg, minres, gmres, approx_chol_preconditioner