diff --git a/Grid/algorithms/LinearOperator.h b/Grid/algorithms/LinearOperator.h index fb996bf1..04cd6dcb 100644 --- a/Grid/algorithms/LinearOperator.h +++ b/Grid/algorithms/LinearOperator.h @@ -103,6 +103,38 @@ public: _Mat.MdagM(in,out); } }; +template +class MMdagLinearOperator : public LinearOperatorBase { + Matrix &_Mat; +public: + MMdagLinearOperator(Matrix &Mat): _Mat(Mat){}; + + // Support for coarsening to a multigrid + void OpDiag (const Field &in, Field &out) { + _Mat.Mdiag(in,out); + } + void OpDir (const Field &in, Field &out,int dir,int disp) { + _Mat.Mdir(in,out,dir,disp); + } + void OpDirAll (const Field &in, std::vector &out){ + _Mat.MdirAll(in,out); + }; + void Op (const Field &in, Field &out){ + _Mat.M(in,out); + } + void AdjOp (const Field &in, Field &out){ + _Mat.Mdag(in,out); + } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ + _Mat.MMdag(in,out); + ComplexD dot = innerProduct(in,out); + n1=real(dot); + n2=norm2(out); + } + void HermOp(const Field &in, Field &out){ + _Mat.MMdag(in,out); + } +}; //////////////////////////////////////////////////////////////////// // Construct herm op and shift it for mgrid smoother