mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-14 13:57:07 +01:00
Rework/global edit to enforce type templating of fermion operators.
Allows multi-precision work and paves the way for alternate BC's and such like allowing for example G-parity which is important for K pipi programme. In particular, can drive an extra flavour index into the fermion fields using template types.
This commit is contained in:
@ -3,11 +3,13 @@
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
void ContinuedFractionFermion5D::SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD scale)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD scale)
|
||||
{
|
||||
SetCoefficientsZolotarev(1.0/scale,zdata);
|
||||
}
|
||||
void ContinuedFractionFermion5D::SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata)
|
||||
{
|
||||
// How to check Ls matches??
|
||||
// std::cout<<GridLogMessage << Ls << " Ls"<<std::endl;
|
||||
@ -16,7 +18,7 @@ namespace Grid {
|
||||
// std::cout<<GridLogMessage << zdata->db << " -db"<<std::endl;
|
||||
// std::cout<<GridLogMessage << zdata->dn << " -dn"<<std::endl;
|
||||
// std::cout<<GridLogMessage << zdata->dd << " -dd"<<std::endl;
|
||||
|
||||
int Ls = this->Ls;
|
||||
assert(zdata->db==Ls);// Beta has Ls coeffs
|
||||
|
||||
R=(1+this->mass)/(1-this->mass);
|
||||
@ -39,7 +41,7 @@ namespace Grid {
|
||||
|
||||
|
||||
ZoloHiInv =1.0/zolo_hi;
|
||||
dw_diag = (4.0-M5)*ZoloHiInv;
|
||||
dw_diag = (4.0-this->M5)*ZoloHiInv;
|
||||
|
||||
See.resize(Ls);
|
||||
Aee.resize(Ls);
|
||||
@ -61,11 +63,14 @@ namespace Grid {
|
||||
|
||||
|
||||
|
||||
RealD ContinuedFractionFermion5D::M (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
RealD ContinuedFractionFermion5D<Impl>::M (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
LatticeFermion D(psi._grid);
|
||||
int Ls = this->Ls;
|
||||
|
||||
DW(psi,D,DaggerNo);
|
||||
FermionField D(psi._grid);
|
||||
|
||||
this->DW(psi,D,DaggerNo);
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
@ -83,15 +88,20 @@ namespace Grid {
|
||||
}
|
||||
return norm2(chi);
|
||||
}
|
||||
RealD ContinuedFractionFermion5D::Mdag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
RealD ContinuedFractionFermion5D<Impl>::Mdag (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
// This matrix is already hermitian. (g5 Dw) = Dw dag g5 = (g5 Dw)dag
|
||||
// The rest of matrix is symmetric.
|
||||
// Can ignore "dag"
|
||||
return M(psi,chi);
|
||||
}
|
||||
void ContinuedFractionFermion5D::Mdir (const LatticeFermion &psi, LatticeFermion &chi,int dir,int disp){
|
||||
DhopDir(psi,chi,dir,disp); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::Mdir (const FermionField &psi, FermionField &chi,int dir,int disp){
|
||||
int Ls = this->Ls;
|
||||
|
||||
this->DhopDir(psi,chi,dir,disp); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==(Ls-1) ){
|
||||
@ -102,13 +112,16 @@ namespace Grid {
|
||||
sign=-sign;
|
||||
}
|
||||
}
|
||||
void ContinuedFractionFermion5D::Meooe (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::Meooe (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
int Ls = this->Ls;
|
||||
|
||||
// Apply 4d dslash
|
||||
if ( psi.checkerboard == Odd ) {
|
||||
DhopEO(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
this->DhopEO(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
} else {
|
||||
DhopOE(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
this->DhopOE(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
||||
}
|
||||
|
||||
int sign=1;
|
||||
@ -121,12 +134,16 @@ namespace Grid {
|
||||
sign=-sign;
|
||||
}
|
||||
}
|
||||
void ContinuedFractionFermion5D::MeooeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MeooeDag (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
Meooe(psi,chi);
|
||||
this->Meooe(psi,chi);
|
||||
}
|
||||
void ContinuedFractionFermion5D::Mooee (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::Mooee (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
int Ls = this->Ls;
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
if ( s==0 ) {
|
||||
@ -144,12 +161,16 @@ namespace Grid {
|
||||
}
|
||||
}
|
||||
|
||||
void ContinuedFractionFermion5D::MooeeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MooeeDag (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
Mooee(psi,chi);
|
||||
this->Mooee(psi,chi);
|
||||
}
|
||||
void ContinuedFractionFermion5D::MooeeInv (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MooeeInv (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
int Ls = this->Ls;
|
||||
|
||||
// Apply Linv
|
||||
axpby_ssp(chi,1.0/cc_d[0],psi,0.0,psi,0,0);
|
||||
for(int s=1;s<Ls;s++){
|
||||
@ -165,15 +186,19 @@ namespace Grid {
|
||||
axpbg5y_ssp(chi,1.0/cc_d[s],chi,-1.0*cc_d[s+1]/See[s]/cc_d[s],chi,s,s+1);
|
||||
}
|
||||
}
|
||||
void ContinuedFractionFermion5D::MooeeInvDag (const LatticeFermion &psi, LatticeFermion &chi)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MooeeInvDag (const FermionField &psi, FermionField &chi)
|
||||
{
|
||||
MooeeInv(psi,chi);
|
||||
this->MooeeInv(psi,chi);
|
||||
}
|
||||
|
||||
// force terms; five routines; default to Dhop on diagonal
|
||||
void ContinuedFractionFermion5D::MDeriv (LatticeGaugeField &mat,const LatticeFermion &U,const LatticeFermion &V,int dag)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MDeriv (GaugeField &mat,const FermionField &U,const FermionField &V,int dag)
|
||||
{
|
||||
LatticeFermion D(V._grid);
|
||||
int Ls = this->Ls;
|
||||
|
||||
FermionField D(V._grid);
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
@ -184,11 +209,14 @@ namespace Grid {
|
||||
}
|
||||
sign=-sign;
|
||||
}
|
||||
DhopDeriv(mat,D,V,DaggerNo);
|
||||
this->DhopDeriv(mat,D,V,DaggerNo);
|
||||
};
|
||||
void ContinuedFractionFermion5D::MoeDeriv(LatticeGaugeField &mat,const LatticeFermion &U,const LatticeFermion &V,int dag)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MoeDeriv(GaugeField &mat,const FermionField &U,const FermionField &V,int dag)
|
||||
{
|
||||
LatticeFermion D(V._grid);
|
||||
int Ls = this->Ls;
|
||||
|
||||
FermionField D(V._grid);
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
@ -199,11 +227,14 @@ namespace Grid {
|
||||
}
|
||||
sign=-sign;
|
||||
}
|
||||
DhopDerivOE(mat,D,V,DaggerNo);
|
||||
this->DhopDerivOE(mat,D,V,DaggerNo);
|
||||
};
|
||||
void ContinuedFractionFermion5D::MeoDeriv(LatticeGaugeField &mat,const LatticeFermion &U,const LatticeFermion &V,int dag)
|
||||
template<class Impl>
|
||||
void ContinuedFractionFermion5D<Impl>::MeoDeriv(GaugeField &mat,const FermionField &U,const FermionField &V,int dag)
|
||||
{
|
||||
LatticeFermion D(V._grid);
|
||||
int Ls = this->Ls;
|
||||
|
||||
FermionField D(V._grid);
|
||||
|
||||
int sign=1;
|
||||
for(int s=0;s<Ls;s++){
|
||||
@ -214,25 +245,29 @@ namespace Grid {
|
||||
}
|
||||
sign=-sign;
|
||||
}
|
||||
DhopDerivEO(mat,D,V,DaggerNo);
|
||||
this->DhopDerivEO(mat,D,V,DaggerNo);
|
||||
};
|
||||
|
||||
// Constructors
|
||||
ContinuedFractionFermion5D::ContinuedFractionFermion5D(
|
||||
LatticeGaugeField &_Umu,
|
||||
template<class Impl>
|
||||
ContinuedFractionFermion5D<Impl>::ContinuedFractionFermion5D(
|
||||
GaugeField &_Umu,
|
||||
GridCartesian &FiveDimGrid,
|
||||
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
||||
GridCartesian &FourDimGrid,
|
||||
GridRedBlackCartesian &FourDimRedBlackGrid,
|
||||
RealD _mass,RealD M5) :
|
||||
WilsonFermion5D(_Umu,
|
||||
WilsonFermion5D<Impl>(_Umu,
|
||||
FiveDimGrid, FiveDimRedBlackGrid,
|
||||
FourDimGrid, FourDimRedBlackGrid,M5),
|
||||
mass(_mass)
|
||||
{
|
||||
int Ls = this->Ls;
|
||||
assert((Ls&0x1)==1); // Odd Ls required
|
||||
}
|
||||
|
||||
FermOpTemplateInstantiate(ContinuedFractionFermion5D);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user