diff --git a/Grid/algorithms/iterative/BlockConjugateGradient.h b/Grid/algorithms/iterative/BlockConjugateGradient.h index 0bd7cf51..14707d7b 100644 --- a/Grid/algorithms/iterative/BlockConjugateGradient.h +++ b/Grid/algorithms/iterative/BlockConjugateGradient.h @@ -52,6 +52,7 @@ class BlockConjugateGradient : public OperatorFunction { Integer MaxIterations; Integer IterationsToComplete; //Number of iterations the CG took to finish. Filled in upon completion Integer PrintInterval; //GridLogMessages or Iterative + RealD TrueResidual; BlockConjugateGradient(BlockCGtype cgtype,int _Orthog,RealD tol, Integer maxit, bool err_on_no_conv = true) : Tolerance(tol), CGtype(cgtype), blockDim(_Orthog), MaxIterations(maxit), ErrorOnNoConverge(err_on_no_conv),PrintInterval(100) @@ -306,7 +307,8 @@ void BlockCGrQsolve(LinearOperatorBase &Linop, const Field &B, Field &X) Linop.HermOp(X, AD); AD = AD-B; - std::cout << GridLogMessage <<"\t True residual is " << std::sqrt(norm2(AD)/norm2(B)) < &Linop, const Field &Src, Field & Linop.HermOp(Psi, AP); AP = AP-Src; - std::cout < &Linop, const std::vector IterationsToComplete; + // Integer IterationsToComplete; //Number of iterations the CG took to finish. Filled in upon completion int verbose; MultiShiftFunction shifts; + std::vector TrueResiduals; ConjugateGradientMultiShift(Integer maxit,MultiShiftFunction &_shifts) : MaxIterations(maxit), shifts(_shifts) { verbose=1; + IterationsToComplete.resize(_shifts.order); + TrueResiduals.resize(_shifts.order); } void operator() (LinearOperatorBase &Linop, const Field &src, Field &psi) @@ -125,6 +129,17 @@ public: // Residuals "r" are src // First search direction "p" is also src cp = norm2(src); + + // Handle trivial case of zero src. + if( cp == 0. ){ + for(int s=0;s