1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-13 20:57:06 +01:00

Merge branch 'feature/hadrons' into feature/rare_kaon

This commit is contained in:
Lanny91
2017-02-06 14:12:21 +00:00
10 changed files with 2850 additions and 2727 deletions

View File

@ -113,6 +113,7 @@ int main(int argc,char **argv)
// test serializable class writing
myclass obj(1234); // non-trivial constructor
std::vector<myclass> vec;
std::pair<myenum, myenum> pair;
std::cout << "-- serialisable class writing to 'bother.xml'..." << std::endl;
write(WR,"obj",obj);
@ -120,6 +121,8 @@ int main(int argc,char **argv)
vec.push_back(myclass(1234));
vec.push_back(myclass(5678));
vec.push_back(myclass(3838));
pair = std::make_pair(myenum::red, myenum::blue);
write(WR, "objvec", vec);
std::cout << "-- serialisable class writing to std::cout:" << std::endl;
std::cout << obj << std::endl;
@ -127,21 +130,30 @@ int main(int argc,char **argv)
std::cout << "vec[0] == obj: " << ((vec[0] == obj) ? "true" : "false") << std::endl;
std::cout << "vec[1] == obj: " << ((vec[1] == obj) ? "true" : "false") << std::endl;
write(WR, "objpair", pair);
std::cout << "-- pair writing to std::cout:" << std::endl;
std::cout << pair << std::endl;
// read tests
std::cout << "\n==== IO self-consistency tests" << std::endl;
//// XML
ioTest<XmlWriter, XmlReader>("iotest.xml", obj, "XML (object) ");
ioTest<XmlWriter, XmlReader>("iotest.xml", vec, "XML (vector of objects)");
ioTest<XmlWriter, XmlReader>("iotest.xml", pair, "XML (pair of objects)");
//// binary
ioTest<BinaryWriter, BinaryReader>("iotest.bin", obj, "binary (object) ");
ioTest<BinaryWriter, BinaryReader>("iotest.bin", vec, "binary (vector of objects)");
ioTest<BinaryWriter, BinaryReader>("iotest.bin", pair, "binary (pair of objects)");
//// text
ioTest<TextWriter, TextReader>("iotest.dat", obj, "text (object) ");
ioTest<TextWriter, TextReader>("iotest.dat", vec, "text (vector of objects)");
ioTest<TextWriter, TextReader>("iotest.dat", pair, "text (pair of objects)");
//// HDF5
#undef HAVE_HDF5
#ifdef HAVE_HDF5
ioTest<Hdf5Writer, Hdf5Reader>("iotest.h5", obj, "HDF5 (object) ");
ioTest<Hdf5Writer, Hdf5Reader>("iotest.h5", vec, "HDF5 (vector of objects)");
ioTest<Hdf5Writer, Hdf5Reader>("iotest.h5", pair, "HDF5 (pair of objects)");
#endif
std::cout << "\n==== vector flattening/reconstruction" << std::endl;

View File

@ -137,7 +137,7 @@ void test(const Expr &a, const Expr &b)
}
}
void checkMat(const Gamma::Algebra a, GridSerialRNG &rng)
void checkGamma(const Gamma::Algebra a, GridSerialRNG &rng)
{
SpinVector v;
SpinMatrix m, &testg = testAlgebra[a];
@ -212,6 +212,28 @@ std::cout << std::endl;
#undef CHECK_PROJ
}
void checkGammaL(const Gamma::Algebra a, GridSerialRNG &rng)
{
SpinVector v;
SpinMatrix m, &testg = testAlgebra[a], pl;
GammaL gl(a);
bool pass = true;
random(rng, v);
random(rng, m);
pl = testAlgebra[Gamma::Algebra::Identity]
- testAlgebra[Gamma::Algebra::Gamma5];
std::cout << GridLogMessage << "Checking left-projected " << Gamma::name[a] << ": ";
std::cout << "vecmul ";
test(gl*v, testg*pl*v);
std::cout << "matlmul ";
test(gl*m, testg*pl*m);
std::cout << "matrmul ";
test(m*gl, m*testg*pl);
std::cout << std::endl;
}
int main(int argc, char *argv[])
{
Grid_init(&argc,&argv);
@ -230,7 +252,7 @@ int main(int argc, char *argv[])
std::cout << GridLogMessage << "======== Multiplication operators check" << std::endl;
for (int i = 0; i < Gamma::nGamma; ++i)
{
checkMat(i, sRNG);
checkGamma(i, sRNG);
}
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "======== Algebra multiplication table check" << std::endl;
@ -249,6 +271,11 @@ int main(int argc, char *argv[])
std::cout << GridLogMessage << "======== Spin projectors check" << std::endl;
checkProject(sRNG);
std::cout << GridLogMessage << std::endl;
std::cout << GridLogMessage << "======== Gamma-left matrices check" << std::endl;
for (int i = 0; i < Gamma::nGamma; ++i)
{
checkGammaL(i, sRNG);
}
Grid_finalize();