21 #ifndef SELDON_FILE_ITERATIVE_BICG_CXX
46 #ifdef SELDON_WITH_VIRTUAL
47 template<
class T,
class Vector1>
48 int BiCg(
const VirtualMatrix<T>& A, Vector1& x,
const Vector1& b,
49 Preconditioner_Base<T>& M,
50 Iteration<
typename ClassComplexType<T>::Treal>& iter)
52 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
53 int BiCg(
const Matrix1& A, Vector1& x,
const Vector1& b,
61 typedef typename Vector1::value_type Complexe;
62 Complexe rho_1, rho_2, alpha, beta, delta;
64 Vector1 r(b), z(b), p(b), q(b);
65 Vector1 r_tilde(b), z_tilde(b), p_tilde(b), q_tilde(b);
72 int success_init = iter.
Init(b);
73 if (success_init != 0)
79 iter.
MltAdd(-one, A, x, one, r);
91 M.TransSolve(A, r_tilde, z_tilde);
93 rho_1 = DotProd(z, r_tilde);
97 iter.
Fail(1,
"Bicg breakdown #1");
104 Copy(z_tilde, p_tilde);
110 beta = rho_1 / rho_2;
114 Add(one, z_tilde, p_tilde);
121 iter.
Mlt(SeldonTrans, A, p_tilde, q_tilde);
123 delta = DotProd(p_tilde, q);
126 iter.
Fail(2,
"Bicg breakdown #2");
130 alpha = rho_1 / delta;
136 Add(-alpha, q_tilde, r_tilde);
148 #define SELDON_FILE_ITERATIVE_BICG_CXX