20 #ifndef SELDON_FILE_ITERATIVE_SYMMLQ_CXX
45 #ifdef SELDON_WITH_VIRTUAL
46 template<
class T,
class Vector1>
47 int Symmlq(
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 Symmlq(
const Matrix1& A, Vector1& x,
const Vector1& b,
56 const int N = A.GetM();
60 typedef typename Vector1::value_type Complexe;
61 Complexe alpha, beta, ibeta, beta_old, beta1,
62 ceta, ceta_oold, ceta_old, ceta_bar;
63 Complexe c, cold, s, sold, coold, soold, rho0, rho1, rho2, rho3, dp;
69 Vector1 r(b), z(b), u(b), v(b), w(b), u_old(b), v_old(b), w_bar(b);
71 typedef typename ClassComplexType<Complexe>::Treal Treal;
73 u_old.Fill(zero); v_old.Fill(zero); w.Fill(zero); w_bar.Fill(zero);
75 int success_init = iter.
Init(b);
76 if (success_init != 0)
82 iter.
MltAdd(-one, A, x, one, r);
86 ceta_oold = zero; ceta_old = zero;
87 c = one; cold = one; s = zero; sold = zero;
91 dp = sqrt(dp); beta = dp; beta1 = beta;
94 Copy(r, v); Copy(z, u);
96 Mlt(ibeta, v); Mlt(ibeta, u);
107 Copy(v, v_old); Copy(u, u_old);
111 Copy(r, v); Mlt(ibeta, v);
112 Copy(z, u); Mlt(ibeta, u);
114 Copy(w_bar, w); Mlt(c, w); Add(s, u, w);
116 Mlt(-s,w_bar); Add(c, u, w_bar);
120 ceta_oold = ceta_old;
126 alpha = DotProd(u, r);
137 Add(-beta, v_old, r);
138 Add(-beta, u_old, z);
145 coold = cold; cold = c; soold = sold; sold = s;
146 rho0 = cold * alpha - coold * sold * beta_old;
147 rho1 = sqrt(rho0*rho0 + beta*beta);
148 rho2 = sold * alpha + coold * cold * beta_old;
149 rho3 = soold * beta_old;
152 c = rho0 / rho1; s = beta / rho1;
157 ceta = -(rho2*ceta_old + rho3*ceta_oold)/rho1;
168 ceta_bar = ceta*1e15;
172 Add(ceta_bar, w_bar, x);
179 #define SELDON_FILE_ITERATIVE_SYMMLQ_CXX