25 template <
class Matrix,
class Vector,
class Preconditioner,
class Real >
28 Preconditioner &M, int64_t &max_iter, Real &
tol)
31 Vector rho_1(1), rho_2(1), alpha(1), beta(1);
32 Vector z, ztilde, p, ptilde, q, qtilde;
47 for (int64_t i = 1; i <= max_iter; i++) {
49 M.Solve(rtilde,ztilde);
50 rho_1(0) =
Dot(z, rtilde);
60 beta(0) = rho_1(0) / rho_2(0);
61 p.TimesBetaPlusZ(beta(0),z);
62 ptilde.TimesBetaPlusZ(beta(0),ztilde);
65 A.Multiply(ptilde,qtilde,1);
66 alpha(0) = rho_1(0) /
Dot(ptilde, q);
69 rtilde -= alpha(0) * qtilde;
TVar Dot(const TPZFMatrix< TVar > &A, const TPZFMatrix< TVar > &B)
Implement dot product for matrices.
int BiCG(Matrix &A, Vector &x, const Vector &b, Preconditioner &M, int64_t &max_iter, Real &tol)
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.