25 template <
class Matrix,
class Vector,
class Preconditioner,
class Real >
28 Preconditioner &M, int64_t &max_iter, Real &
tol,
Vector *residual,
const int FromCurrent)
31 Vector rho_1(1), rho_2(1), alpha(1), beta(1), omega(1);
32 Vector p, phat, s, shat, t, v;
36 if(!res) res = &resbackup;
40 if(FromCurrent) A.MultAdd(x,b,r,-1.,1.);
57 for (int64_t i = 1; i <= max_iter; i++) {
58 rho_1(0) =
Dot(rtilde, r);
66 beta(0) = (rho_1(0)/rho_2(0)) * (alpha(0)/omega(0));
67 p = r + beta(0) * (p - omega(0) * v);
72 alpha(0) = rho_1(0) /
Dot(rtilde, v);
81 omega =
Dot(t,s) /
Dot(t,t);
82 x += alpha(0) * phat + omega(0) * shat;
TVar Dot(const TPZFMatrix< TVar > &A, const TPZFMatrix< TVar > &B)
Implement dot product for matrices.
int BiCGSTAB(const Matrix &A, Vector &x, const Vector &b, Preconditioner &M, int64_t &max_iter, Real &tol, Vector *residual, const int FromCurrent)
BiCGSTAB solves the unsymmetric linear system using the Preconditioned BiConjugate Gradient Stabiliz...
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.