21 #ifndef SELDON_FILE_ITERATIVE_MINRES_CXX
46 #ifdef SELDON_WITH_VIRTUAL
47 template<
class T,
class Vector1>
48 int MinRes(
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 MinRes(
const Matrix1& A, Vector1& x,
const Vector1& b,
57 const int N = A.GetM();
61 typedef typename Vector1::value_type Complexe;
62 Vector1 u_old(b), u(b), r(b), v_old(b), v(b),
63 w_old(b), w(b), z(b), w_oold(b);
65 Complexe dp, beta, ibeta, beta_old, alpha, eta, ceta;
66 Complexe cold, coold, c, soold, sold, s, rho0, rho1, rho2, rho3;
71 int success_init = iter.
Init(b);
72 if (success_init != 0)
78 iter.
MltAdd(-one, A, x, one, r);
82 u_old.Fill(zero); v_old.Fill(zero);
83 w_old.Fill(zero); w.Fill(zero); w_oold.Fill(zero);
88 dp = sqrt(dp); beta = dp; eta = beta;
89 Copy(r, v); Copy(z, u);
92 Mlt(ibeta, v); Mlt(ibeta, u);
94 c = one; s = zero; cold = one; sold = zero;
95 typedef typename ClassComplexType<Complexe>::Treal Treal;
104 alpha = DotProd(r, u);
114 Add(-beta, v_old, r);
115 Add(-beta, u_old, z);
123 coold = cold; cold = c; soold = sold; sold = s;
125 rho0 = cold * alpha - coold * sold * beta_old;
126 rho1 = sqrt(rho0*rho0 + beta*beta);
127 rho2 = sold * alpha + coold * cold * beta_old;
128 rho3 = soold * beta_old;
133 iter.
Fail(1,
"Minres breakdown #1");
140 Copy(w_old, w_oold); Copy(w, w_old);
143 Add(-rho2, w_old, w);
144 Add(-rho3, w_oold, w);
151 Copy(v, v_old); Copy(u, u_old);
152 Copy(r, v); Copy(z, u);
155 iter.
Fail(2,
"MinRes breakdown #2");
159 Mlt(ibeta, v); Mlt(ibeta, u);
170 #define SELDON_FILE_ITERATIVE_MINRES_CXX