7 #ifndef TBCI_SOLVER_QMR_H
8 #define TBCI_SOLVER_QMR_H
10 #include "tbci/basics.h"
58 template < typename T,typename SysMatrix,typename SysVector >
61 unsigned int &max_iter,
double &tol)
63 double rho, rho_1, xi;
68 double gamma, gamma_1;
70 typename SysVector::value_type theta, theta_1;
72 typename SysVector::value_type eta, delta, beta;
73 typename SysVector::value_type ep = (
typename SysVector::value_type)0;
75 const unsigned int dim = A.rows();
77 SysVector r(dim), v_tld(dim),
y(dim), w_tld(dim),
z(dim);
78 SysVector
v(dim), w(dim), y_tld(dim), z_tld(dim);
79 SysVector
p(dim), q(dim), p_tld(dim), d(dim), s(dim);
82 double normbsqr = b.fabssqr();
86 normbsqr = 1.0/normbsqr;
87 const double tolsqr =
sqr(tol);
93 #define QMR_OUT(r) do { err = r; goto qmr_out; } while(0)
96 if ((residsqr = r.fabssqr() * normbsqr) <= tolsqr)
111 eta = (
typename SysVector::value_type)-1.0;
112 theta = (
typename SysVector::value_type) 0.0;
114 for (i = 1; i <= max_iter; i++)
122 v = v_tld * (1. / rho);
125 w = w_tld * (1. / xi);
137 p = y_tld - (
typename SysVector::value_type)(xi * delta / ep) *
p;
138 q = z_tld - (
typename SysVector::value_type)(rho* delta / ep) * q;
154 v_tld = p_tld - beta *
v;
160 w_tld = A.transMult(q) - beta * w;
168 theta = rho / (gamma_1 * beta);
179 # ifdef HAVE_LIBC_NEQ_CPLX_BUG
180 # if !defined(_SGI_SOURCE) || !defined(_COMPILER_VERSION)
193 #if defined(USE_BUILTIN_CPLX) && defined(TYPE)
194 eta = -hcplx(eta)* rho_1 * gamma * gamma /
195 (beta * gamma_1 * gamma_1);
197 eta = -eta * rho_1 * gamma * gamma /
198 (beta * gamma_1 * gamma_1);
202 const typename SysVector::value_type _tmp =
fabssqr(theta_1) *
fabssqr(gamma);
203 d = eta * p + _tmp * d;
204 s = eta * p_tld + _tmp * s;
213 if ((residsqr = r.fabssqr() * normbsqr) <= tolsqr)
const Vector< T > const Vector< T > & x
Abstract base class for all Preconditioners.
const Vector< T > const Vector< T > const Vector< T > & p
The class BdMatrix is an implementation to store and do operations on sparse Matrices with a band str...
virtual TVector< T > transSolve(const Vector< T > &) const =0
NAMESPACE_TBCI Vector< T > class NN friend int QMR(const BdMatrix< T > &, Vector< T > &, const Vector< T > &, const Preconditioner_Sig< T, BdMatrix< T > > &, const Preconditioner_Sig< T, BdMatrix< T > > &, unsigned int &, double &)
cplx< double > gamma(const cplx< double > &z)
const Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > & z
cplx< T > sqr(const cplx< T > &c)
const Vector< T > const Vector< T > const Vector< T > int T T & err
virtual TVector< T > solve(const Vector< T > &) const =0
const Vector< T > Vector< T > Vector< T > Vector< T > & y
double fabssqr(const double a)
const Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > Vector< T > long int int char v
< find minimun of func on grid with resolution res