21 #ifndef SELDON_FILE_ITERATIVE_QCGS_CXX
46 #ifdef SELDON_WITH_VIRTUAL
47 template<
class T,
class Vector1>
48 int QCgs(
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 QCgs(
const Matrix1& A, Vector1& x,
const Vector1& b,
57 const int N = A.GetM();
61 typedef typename Vector1::value_type Complexe;
62 Complexe rho_1, rho_2, mu, nu, alpha, beta, sigma, delta;
63 Vector1 p(b), q(b), r(b), rtilde(b), u(b),
64 phat(b), r_qcgs(b), x_qcgs(b), v(b);
71 int success_init = iter.
Init(b);
72 if (success_init != 0)
78 iter.
MltAdd(-one, A, x, one, r);
84 q.Fill(zero); p.Fill(zero);
85 Copy(r, r_qcgs); Copy(x, x_qcgs);
93 rho_2 = DotProd(rtilde, r);
97 iter.
Fail(1,
"QCgs breakdown #1");
115 iter.
Mlt(A, phat, v); ++iter;
116 sigma = DotProd(rtilde, v);
119 iter.
Fail(2,
"Qcgs breakdown #2");
123 alpha = rho_2 /sigma;
134 iter.
Mlt(A, phat, u);
141 bt_b(0,0) = DotProd(u, u);
142 bt_b(1,1) = DotProd(v, v);
143 bt_b(1,0) = DotProd(u, v);
146 delta = bt_b(0,0)*bt_b(1,1) - bt_b(1,0)*bt_b(0,1);
149 iter.
Fail(3,
"Qcgs breakdown #3");
152 bt_b_m1(0,0) = bt_b(1,1)/delta;
153 bt_b_m1(1,1) = bt_b(0,0)/delta;
154 bt_b_m1(1,0) = -bt_b(1,0)/delta;
156 bt_rn(0) = -DotProd(u, r); bt_rn(1) = -DotProd(v, r);
157 mu = bt_b_m1(0,0)*bt_rn(0)+bt_b_m1(0,1)*bt_rn(1);
158 nu = bt_b_m1(1,0)*bt_rn(0)+bt_b_m1(1,1)*bt_rn(1);
162 Copy(r, r_qcgs); Add(mu, u, r_qcgs);
166 Add(one-mu, x, x_qcgs);
174 M.Solve(A, x_qcgs, x);
180 #define SELDON_FILE_ITERATIVE_QCGS_CXX