27 template <
class Matrix,
class Vector,
class Preconditioner,
class Real >
29 BiCGSTAB(
const Matrix &A, Vector &x,
const Vector &b,
30 const Preconditioner &M,
int &max_iter, Real &tol)
33 Vector rho_1(1), rho_2(1), alpha(1), beta(1), omega(1);
34 Vector p, phat, s, shat, t, v;
43 if ((resid =
norm(r) / normb) <= tol) {
49 for (
int i = 1; i <= max_iter; i++) {
50 rho_1(0) =
dot(rtilde, r);
52 tol =
norm(r) / normb;
58 beta(0) = (rho_1(0)/rho_2(0)) * (alpha(0)/omega(0));
59 p = r + beta(0) * (p - omega(0) * v);
65 alpha(0) = rho_1(0) /
dot(rtilde, v);
67 if ((resid =
norm(s)/normb) < tol) {
76 omega =
dot(t,s) /
dot(t,t);
77 x += alpha(0) * phat + omega(0) * shat;
81 if ((resid =
norm(r) / normb) < tol) {
87 tol =
norm(r) / normb;
int BiCGSTAB(const Matrix &A, Vector &x, const Vector &b, const Preconditioner &M, int &max_iter, Real &tol)
Iterative template routine – BiCGSTAB.
Iterative template routines.
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.