73 const multi1d<Real>& shifts,
74 const multi1d<Real>&
RsdCG,
80 const Subset& sub =
A.subset();
82 int n_shift = shifts.size();
85 QDP_error_exit(
"MinvCG: You must supply at least 1 mass: mass.size() = %d",
91 for(
int findit=1; findit < n_shift; ++findit) {
92 if ( toBool( shifts[findit] < shifts[
isz]) ) {
98 QDPIO::cout <<
"n_shift = " << n_shift <<
" isz = " <<
isz <<
" shift = " << shifts[0] << std::endl;
104 if(
psi.size() < n_shift ) {
110 for(
int i= 0;
i < n_shift; ++
i) {
128 multi1d<Double>
rsd_sq(n_shift);
129 multi1d<Double> rsdcg_sq(n_shift);
133 for(
s = 0;
s < n_shift; ++
s) {
144 Double zeta = 1 / norm2(
r,sub);
147 multi1d<T>
p(n_shift);
148 for(
s = 0;
s < n_shift; ++
s) {
163 Real rsd_sq_min =
rsd_sq[0];
164 for(
s = 1;
s < n_shift; ++
s) {
165 if( toBool(
rsd_sq[
s] < rsd_sq_min ) ) {
170 Real inner_tol = sqrt(rsd_sq_min)*sqrt(zeta);
172 Ap[sub] +=
p[
isz] * shifts[
isz];
182 multi1d<Double> bs(n_shift);
183 multi2d<Double>
z(2, n_shift);
191 for(
s = 0;
s < n_shift; ++
s)
201 r[sub] += Ap * Real(
b);
204 for(
s = 0;
s < n_shift; ++
s) {
213 multi1d<bool> convsP(n_shift);
214 for(
s = 0;
s < n_shift; ++
s) {
221 QDPIO::cout <<
"MInvCG: k = 0 r = " << sqrt(
c) << std::endl;
234 for(
k = 1;
k <=
MaxCG && !convP ; ++
k)
242 for(
s = 0;
s < n_shift; ++
s) {
247 p[
s][sub] *= Real(
a);
255 p[
s][sub] *= Real(as);
256 p[
s][sub] +=
r * Real(
z[
iz][
s]);
274 while ( convsP[unc] ==
true ) {
280 for(
s = unc+1;
s < n_shift; ++
s) {
282 if( toBool(
rsd_sq[
s] < rsd_sq_min ) ) {
288 inner_tol = sqrt(rsd_sq_min)*sqrt(zeta);
290 Ap[sub] +=
p[
isz] * shifts[
isz];
301 for(
s = 0;
s < n_shift;
s++) {
304 if (
s !=
isz && !convsP[
s] ) {
314 r[sub] += Ap * Real(
b);
318 for(
s = 0;
s < n_shift; ++
s) {
320 psi[
s][sub] -=
p[
s] * Real(bs[
s]);
331 for(
s = 0;
s < n_shift;
s++) {
340 QDPIO::cout <<
"MInvCG (shift=" <<
s <<
") k = " <<
k <<
" r = "
341 << css <<
" rsd_sq["<<
s<<
"] = " <<
rsd_sq[
s] << std::endl;
344 convsP[
s] = toBool( css <
rsd_sq[
s] );
354 cs = norm2(
p[
s],sub);
358 d = norm2(
psi[
s],sub);
363 convsP[
s] = toBool( cs <
d );
366 QDPIO::cout <<
"MInvCG (shift=" <<
s <<
") k = " <<
k <<
" cs = "
367 << cs <<
" d = " <<
d << std::endl;
380 for(
s = 0;
s < n_shift; ++
s)
383 Ap[sub] +=
psi[
s] * shifts[
s];
389 QDPIO::cout <<
"MInvCG (conv): s = " <<
s
390 <<
" shift = " << shifts[
s]
391 <<
" r = " << Real(sqrt(
c)/
chi_norm) << std::endl;
401 QDPIO::cout <<
"MinvCG: " <<
n_count <<
" iterations" << std::endl;
411 const LatticeFermion&
chi,
412 multi1d<LatticeFermion>&
psi,
413 const multi1d<Real>& shifts,
414 const multi1d<Real>&
RsdCG,
void MInvRelCG_a(const LinearOperator< T > &A, const T &chi, multi1d< T > &psi, const multi1d< Real > &shifts, const multi1d< Real > &RsdCG, int MaxCG, int &n_count)
Multishift Conjugate-Gradient (CG1) algorithm for a Linear Operator.
BinaryReturn< C1, C2, FnInnerProduct >::Type_t innerProduct(const QDPSubType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
Asqtad Staggered-Dirac operator.
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
LinOpSysSolverMGProtoClover::T T
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > int MaxCG
multi1d< LatticeFermion > chi(Ncb)
void MInvRelCG(const LinearOperator< LatticeFermion > &M, const LatticeFermion &chi, multi1d< LatticeFermion > &psi, const multi1d< Real > &shifts, const multi1d< Real > &RsdCG, int MaxCG, int &n_count)
multi1d< LatticeFermion > s(Ncb)
FloatingPoint< double > Double