diff --git a/Grid/algorithms/LinearOperator.h b/Grid/algorithms/LinearOperator.h index 5096231d..6733d0d0 100644 --- a/Grid/algorithms/LinearOperator.h +++ b/Grid/algorithms/LinearOperator.h @@ -145,6 +145,44 @@ public: } }; +//////////////////////////////////////////////////////////////////// +// Create a shifted HermOp +//////////////////////////////////////////////////////////////////// +template +class ShiftedHermOpLinearOperator : public LinearOperatorBase { + LinearOperatorBase &_Mat; + RealD _shift; +public: + ShiftedHermOpLinearOperator(LinearOperatorBase &Mat,RealD shift): _Mat(Mat), _shift(shift){}; + // Support for coarsening to a multigrid + void OpDiag (const Field &in, Field &out) { + assert(0); + } + void OpDir (const Field &in, Field &out,int dir,int disp) { + assert(0); + } + void OpDirAll (const Field &in, std::vector &out){ + assert(0); + }; + void Op (const Field &in, Field &out){ + assert(0); + } + void AdjOp (const Field &in, Field &out){ + assert(0); + } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ + HermOp(in,out); + ComplexD dot = innerProduct(in,out); + n1=real(dot); + n2=norm2(out); + } + void HermOp(const Field &in, Field &out){ + _Mat.HermOp(in,out); + out = out + _shift*in; + } +}; + + //////////////////////////////////////////////////////////////////// // Wrap an already herm matrix ////////////////////////////////////////////////////////////////////