1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-13 01:05:36 +00:00

result layout standardised, iterator size more elegant

This commit is contained in:
Felix Erben 2019-10-15 18:48:51 +01:00
parent 8d166a81c0
commit 3c702b510b

View File

@ -69,19 +69,19 @@ public:
FERM_TYPE_ALIASES(FImpl3, 3); FERM_TYPE_ALIASES(FImpl3, 3);
BASIC_TYPE_ALIASES(ScalarImplCR, Scalar); BASIC_TYPE_ALIASES(ScalarImplCR, Scalar);
SINK_TYPE_ALIASES(Scalar); SINK_TYPE_ALIASES(Scalar);
class Result: Serializable class Metadata: Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result, GRID_SERIALIZABLE_CLASS_MEMBERS(Metadata,
Gamma::Algebra, gammaA_left, Gamma::Algebra, gammaA_left,
Gamma::Algebra, gammaB_left, Gamma::Algebra, gammaB_left,
Gamma::Algebra, gammaA_right, Gamma::Algebra, gammaA_right,
Gamma::Algebra, gammaB_right, Gamma::Algebra, gammaB_right,
std::string, quarks, std::string, quarks,
std::string, prefactors, std::string, prefactors,
int, parity, int, parity);
std::vector<Complex>, corr);
}; };
typedef Correlator<Metadata> Result;
public: public:
// constructor // constructor
TBaryon(const std::string name); TBaryon(const std::string name);
@ -136,11 +136,11 @@ void TBaryon<FImpl1, FImpl2,FImpl3>::parseGammaString(std::vector<GammaABPair> &
std::string gammaString = par().gammas; std::string gammaString = par().gammas;
//Shorthands for standard baryon operators //Shorthands for standard baryon operators
gammaString = regex_replace(gammaString, std::regex("j12"),"(Identity SigmaXZ)"); gammaString = regex_replace(gammaString, std::regex("j12"),"(Identity SigmaXZ)");
gammaString = regex_replace(gammaString, std::regex("j32X"),"(Identity GammaZGamma5)"); gammaString = regex_replace(gammaString, std::regex("j32X"),"(Identity MinusGammaZGamma5)");
gammaString = regex_replace(gammaString, std::regex("j32Y"),"(Identity GammaT)"); gammaString = regex_replace(gammaString, std::regex("j32Y"),"(Identity GammaT)");
gammaString = regex_replace(gammaString, std::regex("j32Z"),"(Identity GammaXGamma5)"); gammaString = regex_replace(gammaString, std::regex("j32Z"),"(Identity GammaXGamma5)");
//Shorthands for less common baryon operators //Shorthands for less common baryon operators
gammaString = regex_replace(gammaString, std::regex("j12_alt1"),"(Gamma5 SigmaYT)"); gammaString = regex_replace(gammaString, std::regex("j12_alt1"),"(Gamma5 MinusSigmaYT)");
gammaString = regex_replace(gammaString, std::regex("j12_alt2"),"(Identity GammaYGamma5)"); gammaString = regex_replace(gammaString, std::regex("j12_alt2"),"(Identity GammaYGamma5)");
//A single gamma matrix //A single gamma matrix
@ -154,11 +154,13 @@ void TBaryon<FImpl1, FImpl2,FImpl3>::parseGammaString(std::vector<GammaABPair> &
auto gamma_begin = std::sregex_iterator(gammaString.begin(), gammaString.end(), rex_g); auto gamma_begin = std::sregex_iterator(gammaString.begin(), gammaString.end(), rex_g);
auto gamma_end = std::sregex_iterator(); auto gamma_end = std::sregex_iterator();
int nGamma = std::distance(gamma_begin, gamma_end);
//couldn't find out how to count the size in the iterator, other than looping through it... //couldn't find out how to count the size in the iterator, other than looping through it...
int nGamma=0; /* int nGamma=0;
for (std::sregex_iterator i = gamma_begin; i != gamma_end; ++i) { for (std::sregex_iterator i = gamma_begin; i != gamma_end; ++i) {
nGamma++; nGamma++;
} }
*/
gammaList.resize(nGamma/4); gammaList.resize(nGamma/4);
std::vector<std::string> gS; std::vector<std::string> gS;
gS.resize(nGamma); gS.resize(nGamma);
@ -222,19 +224,11 @@ void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void)
TComplex cs; TComplex cs;
TComplex ch; TComplex ch;
std::vector<Result> result; std::vector<Result> result;
result.resize(gammaList.size()); Result r;
for (unsigned int i = 0; i < result.size(); ++i) r.info.parity = parity;
{ r.info.quarks = par().quarks;
result[i].gammaA_left = gammaList[i].first.first; r.info.prefactors = par().prefactors;
result[i].gammaB_left = gammaList[i].first.second;
result[i].gammaA_right = gammaList[i].second.first;
result[i].gammaB_right = gammaList[i].second.second;
result[i].corr.resize(nt);
result[i].parity = parity;
result[i].quarks = par().quarks;
result[i].prefactors = par().prefactors;
}
if (envHasType(SlicedPropagator1, par().q1) and if (envHasType(SlicedPropagator1, par().q1) and
envHasType(SlicedPropagator2, par().q2) and envHasType(SlicedPropagator2, par().q2) and
@ -243,14 +237,20 @@ void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void)
auto &q1 = envGet(SlicedPropagator1, par().q1); auto &q1 = envGet(SlicedPropagator1, par().q1);
auto &q2 = envGet(SlicedPropagator2, par().q2); auto &q2 = envGet(SlicedPropagator2, par().q2);
auto &q3 = envGet(SlicedPropagator3, par().q3); auto &q3 = envGet(SlicedPropagator3, par().q3);
for (unsigned int i = 0; i < result.size(); ++i) for (unsigned int i = 0; i < gammaList.size(); ++i)
{ {
r.info.gammaA_left = gammaList[i].first.first;
r.info.gammaB_left = gammaList[i].first.second;
r.info.gammaA_right = gammaList[i].second.first;
r.info.gammaB_right = gammaList[i].second.second;
Gamma gAl(gammaList[i].first.first); Gamma gAl(gammaList[i].first.first);
Gamma gBl(gammaList[i].first.second); Gamma gBl(gammaList[i].first.second);
Gamma gAr(gammaList[i].second.first); Gamma gAr(gammaList[i].second.first);
Gamma gBr(gammaList[i].second.second); Gamma gBr(gammaList[i].second.second);
LOG(Message) << "(propagator already sinked)" << std::endl; LOG(Message) << "(propagator already sinked)" << std::endl;
r.corr.clear();
for (unsigned int t = 0; t < buf.size(); ++t) for (unsigned int t = 0; t < buf.size(); ++t)
{ {
cs = Zero(); cs = Zero();
@ -260,8 +260,9 @@ void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void)
cs += prefactors[iQ1]*prefactors[iQ2]*ch; cs += prefactors[iQ1]*prefactors[iQ2]*ch;
} }
} }
result[i].corr[t] = TensorRemove(cs); r.corr.push_back(TensorRemove(cs));
} }
result.push_back(r);
} }
} }
else else
@ -269,8 +270,13 @@ void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void)
auto &q1 = envGet(PropagatorField1, par().q1); auto &q1 = envGet(PropagatorField1, par().q1);
auto &q2 = envGet(PropagatorField2, par().q2); auto &q2 = envGet(PropagatorField2, par().q2);
auto &q3 = envGet(PropagatorField3, par().q3); auto &q3 = envGet(PropagatorField3, par().q3);
for (unsigned int i = 0; i < result.size(); ++i) for (unsigned int i = 0; i < gammaList.size(); ++i)
{ {
r.info.gammaA_left = gammaList[i].first.first;
r.info.gammaB_left = gammaList[i].first.second;
r.info.gammaA_right = gammaList[i].second.first;
r.info.gammaB_right = gammaList[i].second.second;
Gamma gAl(gammaList[i].first.first); Gamma gAl(gammaList[i].first.first);
Gamma gBl(gammaList[i].first.second); Gamma gBl(gammaList[i].first.second);
Gamma gAr(gammaList[i].second.first); Gamma gAr(gammaList[i].second.first);
@ -304,10 +310,12 @@ void TBaryon<FImpl1, FImpl2, FImpl3>::execute(void)
SinkFnScalar &sink = envGet(SinkFnScalar, par().sink); SinkFnScalar &sink = envGet(SinkFnScalar, par().sink);
buf = sink(c); buf = sink(c);
} }
r.corr.clear();
for (unsigned int t = 0; t < buf.size(); ++t) for (unsigned int t = 0; t < buf.size(); ++t)
{ {
result[i].corr[t] = TensorRemove(buf[t]); r.corr.push_back(TensorRemove(buf[t]));
} }
result.push_back(r);
} }
} }