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 symmetric positive definite system by preconditioned conjugate gradients: \(A x = b\), \(M \approx A^{-1}\). A and M must both be tagged SPD.

(2) Solve by preconditioned conjugate gradients on an invariant subspace \(S\): \(A x = b\), \(x, b \in S\).

Exceptions

  • std::invalid_argument: If dimensions mismatch.