21 #ifndef SELDON_FILE_ITERATIVE_TFQMR_CXX
44 #ifdef SELDON_WITH_VIRTUAL
45 template<
class T,
class Vector1>
46 int TfQmr(
const VirtualMatrix<T>& A, Vector1& x,
const Vector1& b,
47 Preconditioner_Base<T>& M,
48 Iteration<
typename ClassComplexType<T>::Treal>& iter)
50 template <
class Titer,
class Matrix1,
class Vector1,
class Preconditioner>
51 int TfQmr(
const Matrix1& A, Vector1& x,
const Vector1& b,
55 const int N = A.GetM();
59 Vector1 tmp(b), r0(b), v(b), h(b), w(b),
60 y1(b), g(b), y0(b), rtilde(b), d(b);
62 typedef typename Vector1::value_type Complexe;
63 Complexe sigma, alpha, beta, eta, rho, rho0;
64 typedef typename ClassComplexType<Complexe>::Treal Treal;
65 Treal c, kappa, tau, theta;
75 iter.
MltAdd(-one, A, x, one, tmp);
82 int success_init = iter.
Init(r0);
83 if (success_init != 0)
112 rho = DotProd(rtilde, r0);
123 sigma = DotProd(rtilde, v);
127 iter.
Fail(1,
"Tfqmr breakdown: sigma=0");
149 iter.
Fail(2,
"Tfqmr breakdown: alpha=0");
153 Mlt(theta * theta * eta / alpha, d);
159 iter.
Fail(3,
"Tfqmr breakdown: tau=0");
162 theta =
Norm2(w) / tau;
165 c = Treal(1) / sqrt(Treal(1) + theta * theta);
168 tau = tau * c * theta;
192 Mlt(theta * theta * eta / alpha,d);
197 iter.
Fail(4,
"Tfqmr breakdown: tau=0");
200 theta =
Norm2(w) / tau;
203 c = Treal(1) / sqrt(Treal(1) + theta * theta);
206 tau = tau * c * theta;
227 rho = DotProd(rtilde, w);
230 iter.
Fail(5,
"tfqmr breakdown: beta=0");
258 #define SELDON_FILE_ITERATIVE_TFQMR_CXX