15 CG3::CG3(DiracMatrix &
mat, SolverParam &
param, TimeProfile &profile) :
23 void CG3::operator()(cudaColorSpinorField &
x, cudaColorSpinorField &
b)
27 const double b2 =
norm2(
b);
30 printfQuda(
"Warning: inverting on zero-field source\n");
33 param.true_res_hq = 0.0;
41 cudaColorSpinorField x_prev(
b,
csParam);
42 cudaColorSpinorField r_prev(
b,
csParam);
43 cudaColorSpinorField temp(
b,
csParam);
45 cudaColorSpinorField r(
b);
46 cudaColorSpinorField
w(
b);
50 double r2 = xmyNormCuda(
b,r);
51 PrintStats(
"CG3", 0, r2, b2, 0.0);
54 double stop = stopping(
param.tol, b2,
param.residual_type);
55 if(convergence(r2, 0.0, stop, 0.0))
return;
58 double rAr = reDotProductCuda(r,
w);
60 double gamma_prev = 0.0;
61 double gamma = r2/rAr;
64 cudaColorSpinorField x_new(
x);
65 cudaColorSpinorField r_new(r);
66 axpyCuda(
gamma, r, x_new);
67 axpyCuda(-
gamma,
w, r_new);
75 while(!convergence(r2, 0.0, stop, 0.0) && k<
param.maxiter){
76 x_prev =
x;
x = x_new;
77 r_prev = r; r = r_new;
79 rAr = reDotProductCuda(r,
w);
84 PrintStats(
"CG3", k, r2, b2, 0.0);
88 rho = 1.0/(1. - (
gamma/gamma_prev)*(r2/r2_prev)*(1.0/rho));
92 axpyCuda(rho*
gamma,r,x_new);
93 axpyCuda((1. - rho),x_prev,x_new);
97 axpyCuda(-rho*
gamma,
w,r_new);
98 axpyCuda((1.-rho),r_prev,r_new);
101 double rr_old = reDotProductCuda(r_new,r);
110 if(k ==
param.maxiter)
117 PrintSummary(
"CG3", k, r2, b2);
__host__ __device__ ValueType sqrt(ValueType x)
double norm2(const CloverField &a, bool inverse=false)
double gamma(double) __attribute__((availability(macosx
void mat(void *out, void **link, void *in, int dagger_bit, int mu, QudaPrecision sPrecision, QudaPrecision gPrecision)