Skip to content

num::unsafe::cg

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

solver_result cg(const mat<real> &A, const vec<real> &b, vec<real> &x,
                 cg_options options = {});

Conjugate gradients on a stored matrix, without requiring the SPD invariant.

On an indefinite or non-symmetric matrix the iteration breaks down silently. Runs through num::accel; num::unsafe::cuda::cg works on device buffers.

Return value

solver_result: .iterations, .residual (final residual norm), .converged.