2015-06-02 16:57:12 +01:00
|
|
|
#include <Grid.h>
|
|
|
|
|
|
|
|
namespace Grid {
|
|
|
|
namespace QCD {
|
|
|
|
|
2015-06-04 00:00:45 +01:00
|
|
|
void ContinuedFractionFermion5D::SetCoefficientsTanh(Approx::zolotarev_data *zdata,RealD b,RealD c)
|
|
|
|
{
|
|
|
|
SetCoefficientsZolotarev(1.0,zdata,b,c);
|
|
|
|
}
|
|
|
|
void ContinuedFractionFermion5D::SetCoefficientsZolotarev(RealD zolo_hi,Approx::zolotarev_data *zdata,RealD b,RealD c)
|
|
|
|
{
|
|
|
|
R=(1+this->mass)/(1-this->mass);
|
|
|
|
|
|
|
|
Beta.resize(Ls);
|
|
|
|
cc.resize(Ls);
|
|
|
|
cc_d.resize(Ls);
|
|
|
|
sqrt_cc.resize(Ls);
|
|
|
|
for(int i=0; i < Ls ; i++){
|
|
|
|
Beta[i] = zdata -> beta[i];
|
|
|
|
cc[i] = 1.0/Beta[i];
|
|
|
|
cc_d[i]=sqrt(cc[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
cc_d[Ls-1]=1.0;
|
|
|
|
for(int i=0; i < Ls-1 ; i++){
|
|
|
|
sqrt_cc[i]= sqrt(cc[i]*cc[i+1]);
|
|
|
|
}
|
|
|
|
sqrt_cc[Ls-2]=sqrt(cc[Ls-2]);
|
|
|
|
|
|
|
|
|
|
|
|
ZoloHiInv =1.0/zolo_hi;
|
|
|
|
double dw_diag = (4.0-M5)*ZoloHiInv;
|
|
|
|
|
|
|
|
See.resize(Ls);
|
|
|
|
Aee.resize(Ls);
|
|
|
|
int sign=1;
|
|
|
|
for(int s=0;s<Ls;s++){
|
|
|
|
Aee[s] = sign * Beta[s] * dw_diag;
|
|
|
|
sign = - sign;
|
|
|
|
}
|
|
|
|
Aee[Ls-1] += R;
|
|
|
|
|
|
|
|
See[0] = Aee[0];
|
|
|
|
for(int s=1;s<Ls;s++){
|
|
|
|
See[s] = Aee[s] - 1.0/See[s-1];
|
|
|
|
}
|
|
|
|
for(int s=0;s<Ls;s++){
|
|
|
|
std::cout <<"s = "<<s<<" Beta "<<Beta[s]<<" Aee "<<Aee[s] <<" See "<<See[s] <<std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-06-02 16:57:12 +01:00
|
|
|
RealD ContinuedFractionFermion5D::M (const LatticeFermion &psi, LatticeFermion &chi)
|
|
|
|
{
|
|
|
|
LatticeFermion D(psi._grid);
|
|
|
|
|
|
|
|
DW(psi,D,DaggerNo);
|
|
|
|
|
|
|
|
int sign=1;
|
|
|
|
for(int s=0;s<Ls;s++){
|
|
|
|
if ( s==0 ) {
|
2015-06-04 00:00:45 +01:00
|
|
|
ag5xpby_ssp(chi,cc[0]*Beta[0]*sign*ZoloHiInv,D,sqrt_cc[0],psi,s,s+1); // Multiplies Dw by G5 so Hw
|
2015-06-02 16:57:12 +01:00
|
|
|
} else if ( s==(Ls-1) ){
|
|
|
|
RealD R=(1.0+mass)/(1.0-mass);
|
2015-06-04 00:00:45 +01:00
|
|
|
ag5xpby_ssp(chi,Beta[s]*ZoloHiInv,D,sqrt_cc[s-1],psi,s,s-1);
|
2015-06-02 16:57:12 +01:00
|
|
|
ag5xpby_ssp(chi,R,psi,1.0,chi,s,s);
|
|
|
|
} else {
|
2015-06-04 00:00:45 +01:00
|
|
|
ag5xpby_ssp(chi,cc[s]*Beta[s]*sign*ZoloHiInv,D,sqrt_cc[s],psi,s,s+1);
|
2015-06-02 16:57:12 +01:00
|
|
|
axpby_ssp(chi,1.0,chi,sqrt_cc[s-1],psi,s,s-1);
|
|
|
|
}
|
|
|
|
sign=-sign;
|
|
|
|
}
|
|
|
|
return norm2(chi);
|
|
|
|
}
|
|
|
|
RealD ContinuedFractionFermion5D::Mdag (const LatticeFermion &psi, LatticeFermion &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::Meooe (const LatticeFermion &psi, LatticeFermion &chi)
|
|
|
|
{
|
2015-06-04 00:00:45 +01:00
|
|
|
// Apply 4d dslash
|
|
|
|
if ( psi.checkerboard == Odd ) {
|
|
|
|
DhopEO(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
|
|
|
} else {
|
|
|
|
DhopOE(psi,chi,DaggerNo); // Dslash on diagonal. g5 Dslash is hermitian
|
|
|
|
}
|
2015-06-02 16:57:12 +01:00
|
|
|
|
|
|
|
int sign=1;
|
|
|
|
for(int s=0;s<Ls;s++){
|
|
|
|
if ( s==(Ls-1) ){
|
2015-06-04 00:00:45 +01:00
|
|
|
ag5xpby_ssp(chi,Beta[s]*ZoloHiInv,chi,0.0,chi,s,s);
|
2015-06-02 16:57:12 +01:00
|
|
|
} else {
|
2015-06-04 00:00:45 +01:00
|
|
|
ag5xpby_ssp(chi,cc[s]*Beta[s]*sign*ZoloHiInv,chi,0.0,chi,s,s);
|
2015-06-02 16:57:12 +01:00
|
|
|
}
|
|
|
|
sign=-sign;
|
2015-06-04 00:00:45 +01:00
|
|
|
}
|
2015-06-02 16:57:12 +01:00
|
|
|
}
|
|
|
|
void ContinuedFractionFermion5D::MeooeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
|
|
|
{
|
|
|
|
Meooe(psi,chi);
|
|
|
|
}
|
|
|
|
void ContinuedFractionFermion5D::Mooee (const LatticeFermion &psi, LatticeFermion &chi)
|
|
|
|
{
|
2015-06-04 00:00:45 +01:00
|
|
|
double dw_diag = (4.0-M5)*ZoloHiInv;
|
2015-06-02 16:57:12 +01:00
|
|
|
|
|
|
|
int sign=1;
|
|
|
|
for(int s=0;s<Ls;s++){
|
|
|
|
if ( s==0 ) {
|
|
|
|
ag5xpby_ssp(chi,cc[0]*Beta[0]*sign*dw_diag,psi,sqrt_cc[0],psi,s,s+1); // Multiplies Dw by G5 so Hw
|
|
|
|
} else if ( s==(Ls-1) ){
|
|
|
|
// Drop the CC here.
|
2015-06-04 00:00:45 +01:00
|
|
|
double R=(1+mass)/(1-mass);
|
2015-06-02 16:57:12 +01:00
|
|
|
ag5xpby_ssp(chi,Beta[s]*dw_diag,psi,sqrt_cc[s-1],psi,s,s-1);
|
|
|
|
ag5xpby_ssp(chi,R,psi,1.0,chi,s,s);
|
|
|
|
} else {
|
|
|
|
ag5xpby_ssp(chi,cc[s]*Beta[s]*sign*dw_diag,psi,sqrt_cc[s],psi,s,s+1);
|
|
|
|
axpby_ssp(chi,1.0,chi,sqrt_cc[s-1],psi,s,s-1);
|
|
|
|
}
|
|
|
|
sign=-sign;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContinuedFractionFermion5D::MooeeDag (const LatticeFermion &psi, LatticeFermion &chi)
|
|
|
|
{
|
|
|
|
Mooee(psi,chi);
|
|
|
|
}
|
|
|
|
void ContinuedFractionFermion5D::MooeeInv (const LatticeFermion &psi, LatticeFermion &chi)
|
|
|
|
{
|
|
|
|
// Apply Linv
|
2015-06-04 00:00:45 +01:00
|
|
|
axpby_ssp(chi,1.0/cc_d[0],psi,0.0,psi,0,0);
|
2015-06-02 16:57:12 +01:00
|
|
|
for(int s=1;s<Ls;s++){
|
|
|
|
axpbg5y_ssp(chi,1.0/cc_d[s],psi,-1.0/See[s-1],chi,s,s-1);
|
|
|
|
}
|
|
|
|
// Apply Dinv
|
|
|
|
for(int s=0;s<Ls;s++){
|
|
|
|
ag5xpby_ssp(chi,1.0/See[s],chi,0.0,chi,s,s); //only appearance of See[0]
|
|
|
|
}
|
|
|
|
// Apply Uinv = (Linv)^T
|
2015-06-04 00:00:45 +01:00
|
|
|
axpby_ssp(chi,1.0/cc_d[Ls-1],chi,0.0,chi,Ls-1,Ls-1);
|
2015-06-02 16:57:12 +01:00
|
|
|
for(int s=Ls-2;s>=0;s--){
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
MooeeInv(psi,chi);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
ContinuedFractionFermion5D::ContinuedFractionFermion5D(
|
|
|
|
LatticeGaugeField &_Umu,
|
|
|
|
GridCartesian &FiveDimGrid,
|
|
|
|
GridRedBlackCartesian &FiveDimRedBlackGrid,
|
|
|
|
GridCartesian &FourDimGrid,
|
|
|
|
GridRedBlackCartesian &FourDimRedBlackGrid,
|
|
|
|
RealD _mass,RealD M5) :
|
|
|
|
WilsonFermion5D(_Umu,
|
|
|
|
FiveDimGrid, FiveDimRedBlackGrid,
|
|
|
|
FourDimGrid, FourDimRedBlackGrid,M5),
|
|
|
|
mass(_mass)
|
|
|
|
{
|
2015-06-04 00:00:45 +01:00
|
|
|
assert((Ls&0x1)==1); // Odd Ls required
|
|
|
|
int nrational=Ls-1;// Even rational order
|
|
|
|
zdata = Approx::grid_higham(1.0,nrational);// eps is ignored for higham
|
|
|
|
SetCoefficientsTanh(zdata,1.0,0.0);
|
2015-06-02 16:57:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|