From 5ac625f7167ec14ec0fff81c317f0a103f769612 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Tue, 21 Jul 2015 13:54:09 +0900 Subject: [PATCH] No changes shown on git diff --- lib/algorithms/LinearOperator.h | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/algorithms/LinearOperator.h b/lib/algorithms/LinearOperator.h index a804bceb..31e086ba 100644 --- a/lib/algorithms/LinearOperator.h +++ b/lib/algorithms/LinearOperator.h @@ -71,6 +71,47 @@ namespace Grid { } }; + //////////////////////////////////////////////////////////////////// + // Construct herm op and shift it for mgrid smoother + //////////////////////////////////////////////////////////////////// + template + class ShiftedMdagMLinearOperator : public LinearOperatorBase { + Matrix &_Mat; + RealD _shift; + public: + ShiftedMdagMLinearOperator(Matrix &Mat,RealD shift): _Mat(Mat), _shift(shift){}; + // Support for coarsening to a multigrid + void OpDiag (const Field &in, Field &out) { + _Mat.Mdiag(in,out); + assert(0); + } + void OpDir (const Field &in, Field &out,int dir,int disp) { + _Mat.Mdir(in,out,dir,disp); + assert(0); + } + void Op (const Field &in, Field &out){ + _Mat.M(in,out); + assert(0); + } + void AdjOp (const Field &in, Field &out){ + _Mat.Mdag(in,out); + assert(0); + } + void HermOpAndNorm(const Field &in, Field &out,RealD &n1,RealD &n2){ + _Mat.MdagM(in,out,n1,n2); + out = out + _shift*in; + + ComplexD dot; + dot= innerProduct(in,out); + n1=real(dot); + n2=norm2(out); + } + void HermOp(const Field &in, Field &out){ + RealD n1,n2; + HermOpAndNorm(in,out,n1,n2); + } + }; + //////////////////////////////////////////////////////////////////// // Wrap an already herm matrix ////////////////////////////////////////////////////////////////////