24 template <
class Matrix,
class Vector,
class Preconditioner,
class Real >
27 const Preconditioner &M, int64_t &max_iter, Real &
tol)
31 Vector alpha(1), beta(1), rho(1), rho_1(1);
39 if ((resid = norm(r) / normb) <= tol) {
45 for (int64_t i = 1; i <= max_iter; i++) {
52 beta(0) = rho(0) / rho_1(0);
57 alpha(0) = rho(0) / dot(p, q);
62 if ((resid = norm(r) / normb) <= tol) {
int CG(const Matrix &A, Vector &x, const Vector &b, const Preconditioner &M, int64_t &max_iter, Real &tol)
CG solves the symmetric positive definite linear system using the Conjugate Gradient method...