22 template <
class Matrix,
class Vector,
class Preconditioner,
class Real >
24 CG(
const Matrix &A, Vector &x,
const Vector &b,
25 const Preconditioner &M,
int &max_iter, Real &tol)
29 Vector alpha(1), beta(1), rho(1), rho_1(1);
37 if ((resid =
norm(r) / normb) <= tol) {
43 for (
int i = 1; i <= max_iter; i++) {
50 beta(0) = rho(0) / rho_1(0);
55 alpha(0) = rho(0) /
dot(p, q);
60 if ((resid =
norm(r) / normb) <= tol) {
int CG(const Matrix &A, Vector &x, const Vector &b, const Preconditioner &M, int &max_iter, Real &tol)
A::value_type dot(const A &a, const B &b)
Dot product of array or expression.
A::value_type norm(const A &a)
Euklidean norm of array or expression.