21 #ifndef SELDON_FILE_ITERATIVE_CGS_CXX
45 #ifdef SELDON_WITH_VIRTUAL
46 template<
class T,
class Vector1>
47 int Cgs(
const VirtualMatrix<T>& A, Vector1& x,
const Vector1& b,
48 Preconditioner_Base<T>& M,
49 Iteration<
typename ClassComplexType<T>::Treal>& iter)
51 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
52 int Cgs(
const Matrix1& A, Vector1& x,
const Vector1& b,
56 const int N = A.GetM();
60 typedef typename Vector1::value_type Complexe;
61 Complexe rho_1, rho_2, alpha, beta, delta;
62 Vector1 p(b), phat(b), q(b), qhat(b), vhat(b), u(b), uhat(b),
70 int success_init = iter.
Init(b);
71 if (success_init != 0)
77 iter.
MltAdd(-one, A, x, one, r);
87 rho_1 = DotProd(rtilde, r);
91 iter.
Fail(1,
"Cgs breakdown #1");
104 beta = rho_1 / rho_2;
117 iter.
Mlt(A, phat, vhat); ++iter;
118 delta = DotProd(rtilde, vhat);
121 iter.
Fail(2,
"Cgs breakdown #2");
125 alpha = rho_1 /delta;
127 Add(-alpha, vhat, q);
134 iter.
Mlt(A, uhat, qhat);
135 Add(-alpha, qhat, r);
147 #define SELDON_FILE_ITERATIVE_CGS_CXX