diff --git a/lib/qcd/action/gauge/PlaqPlusRectangleAction.h b/lib/qcd/action/gauge/PlaqPlusRectangleAction.h index 82e21aed..0f39b8f3 100644 --- a/lib/qcd/action/gauge/PlaqPlusRectangleAction.h +++ b/lib/qcd/action/gauge/PlaqPlusRectangleAction.h @@ -34,29 +34,43 @@ namespace Grid{ return action; }; - virtual void deriv(const GaugeField &U,GaugeField & dSdU) { + virtual void deriv(const GaugeField &Umu,GaugeField & dSdU) { //extend Ta to include Lorentz indexes RealD factor_p = c_plaq/RealD(Nc)*0.5; RealD factor_r = c_rect/RealD(Nc)*0.5; - GaugeLinkField Umu(U._grid); - GaugeLinkField dSdU_mu(U._grid); - GaugeLinkField staple(U._grid); + GridBase *grid = Umu._grid; + + std::vector U (Nd,grid); + std::vector U2(Nd,grid); + + for(int mu=0;mu(Umu,mu); + WilsonLoops::RectStapleDouble(U2[mu],U[mu],mu); + } + + GaugeLinkField dSdU_mu(grid); + GaugeLinkField staple(grid); + for (int mu=0; mu < Nd; mu++){ - Umu = PeekIndex(U,mu); - // Staple in direction mu - WilsonLoops::Staple(staple,U,mu); - dSdU_mu = Ta(Umu*staple)*factor_p; - - WilsonLoops::RectStaple(staple,U,mu); - dSdU_mu = dSdU_mu + Ta(Umu*staple)*factor_r; + + WilsonLoops::Staple(staple,Umu,mu); + + dSdU_mu = Ta(U[mu]*staple)*factor_p; + + // WilsonLoops::RectStaple(staple,Umu,mu); + + WilsonLoops::RectStapleOptimised(staple,U2,U,mu); + + dSdU_mu = dSdU_mu + Ta(U[mu]*staple)*factor_r; PokeIndex(dSdU, dSdU_mu, mu); - } + }; + }; // Convenience for common physically defined cases. diff --git a/lib/qcd/utils/CovariantCshift.h b/lib/qcd/utils/CovariantCshift.h index e090f497..8bc0986f 100644 --- a/lib/qcd/utils/CovariantCshift.h +++ b/lib/qcd/utils/CovariantCshift.h @@ -5,6 +5,7 @@ namespace QCD { //////////////////////////////////////////////////////////////////////// // Low performance implementation of CovariantCshift API //////////////////////////////////////////////////////////////////////// +// Make these members of an Impl class for BC's. template Lattice CovShiftForward(const Lattice &Link, int mu, const Lattice &field) @@ -19,5 +20,6 @@ template Lattice CovShiftBackward(const tmp = adj(Link)*field; return Cshift(tmp,mu,-1);// moves towards positive mu } + }} #endif diff --git a/lib/qcd/utils/WilsonLoops.h b/lib/qcd/utils/WilsonLoops.h index cc6eab0b..36fbe51c 100644 --- a/lib/qcd/utils/WilsonLoops.h +++ b/lib/qcd/utils/WilsonLoops.h @@ -206,8 +206,96 @@ public: ////////////////////////////////////////////////// // the sum over all staples on each site ////////////////////////////////////////////////// + static void RectStapleDouble(GaugeMat &U2,const GaugeMat & U,int mu){ + U2 = U * Cshift(U,mu,1); + } + static void RectStapleOptimised(GaugeMat &Stap,std::vector &U2,std::vector &U,int mu){ + + Stap = zero; + + GridBase *grid = U[0]._grid; + + GaugeMat Staple2x1 (grid); + GaugeMat tmp (grid); + + for(int nu=0;nu U (Nd,grid); + std::vector U2(Nd,grid); + + for(int mu=0;mu(Umu,mu); + RectStapleDouble(U2[mu],U[mu],mu); + } + + RectStapleOptimised(Stap,U2,U,mu); +#endif + } + + static void RectStapleUnoptimised(GaugeMat &Stap,const GaugeLorentz &Umu,int mu){ GridBase *grid = Umu._grid; std::vector U(4,grid);