diff --git a/.gitignore b/.gitignore index da7de5e4..d30b5fff 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ ################ *~ *# +*.sublime-* # Precompiled Headers # ####################### @@ -103,4 +104,16 @@ lib/fftw/* # libtool macros # ################## m4/lt* -m4/libtool.m4 \ No newline at end of file +m4/libtool.m4 + +# Buck files # +############## +.buck* +buck-out +BUCK +make-bin-BUCK.sh + +# generated sources # +##################### +lib/qcd/spin/gamma-gen/*.h +lib/qcd/spin/gamma-gen/*.cc \ No newline at end of file diff --git a/benchmarks/Benchmark_dwf.cc b/benchmarks/Benchmark_dwf.cc index 09893d8f..686d00a1 100644 --- a/benchmarks/Benchmark_dwf.cc +++ b/benchmarks/Benchmark_dwf.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; typedef WilsonFermion5D WilsonFermion5DR; @@ -351,7 +351,7 @@ int main (int argc, char ** argv) ref = zero; for(int mu=0;mu & L, int Ls, int threads, int report =0 ); diff --git a/benchmarks/Benchmark_wilson.cc b/benchmarks/Benchmark_wilson.cc index 4930713c..11f1353f 100644 --- a/benchmarks/Benchmark_wilson.cc +++ b/benchmarks/Benchmark_wilson.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; bool overlapComms = false; @@ -106,7 +106,7 @@ int main (int argc, char ** argv) { // Naive wilson implementation ref = zero; for(int mu=0;mu(par_.seed)); + env().setSeed(strToVec(par_.seed)); } const Application::GlobalPar & Application::getPar(void) @@ -89,7 +94,7 @@ const Application::GlobalPar & Application::getPar(void) // execute ///////////////////////////////////////////////////////////////////// void Application::run(void) { - if (!parameterFileName_.empty() and (env_.getNModule() == 0)) + if (!parameterFileName_.empty() and (env().getNModule() == 0)) { parseParameterFile(parameterFileName_); } @@ -124,7 +129,7 @@ void Application::parseParameterFile(const std::string parameterFileName) do { read(reader, "id", id); - env_.createModule(id.name, id.type, reader); + env().createModule(id.name, id.type, reader); } while (reader.nextElement("module")); pop(reader); pop(reader); @@ -134,7 +139,7 @@ void Application::saveParameterFile(const std::string parameterFileName) { XmlWriter writer(parameterFileName); ObjectId id; - const unsigned int nMod = env_.getNModule(); + const unsigned int nMod = env().getNModule(); LOG(Message) << "Saving application to '" << parameterFileName << "'..." << std::endl; write(writer, "parameters", getPar()); @@ -142,10 +147,10 @@ void Application::saveParameterFile(const std::string parameterFileName) for (unsigned int i = 0; i < nMod; ++i) { push(writer, "module"); - id.name = env_.getModuleName(i); - id.type = env_.getModule(i)->getRegisteredName(); + id.name = env().getModuleName(i); + id.type = env().getModule(i)->getRegisteredName(); write(writer, "id", id); - env_.getModule(i)->saveParameters(writer, "options"); + env().getModule(i)->saveParameters(writer, "options"); pop(writer); } pop(writer); @@ -164,10 +169,10 @@ auto memPeak = [this](const std::vector &program)\ \ msg = HadronsLogMessage.isActive();\ HadronsLogMessage.Active(false);\ - env_.dryRun(true);\ - memPeak = env_.executeProgram(program);\ - env_.dryRun(false);\ - env_.freeAll();\ + env().dryRun(true);\ + memPeak = env().executeProgram(program);\ + env().dryRun(false);\ + env().freeAll();\ HadronsLogMessage.Active(true);\ \ return memPeak;\ @@ -179,7 +184,7 @@ void Application::schedule(void) // build module dependency graph LOG(Message) << "Building module graph..." << std::endl; - auto graph = env_.makeModuleGraph(); + auto graph = env().makeModuleGraph(); auto con = graph.getConnectedComponents(); // constrained topological sort using a genetic algorithm @@ -256,7 +261,7 @@ void Application::saveSchedule(const std::string filename) << std::endl; for (auto address: program_) { - program.push_back(env_.getModuleName(address)); + program.push_back(env().getModuleName(address)); } write(writer, "schedule", program); } @@ -274,7 +279,7 @@ void Application::loadSchedule(const std::string filename) program_.clear(); for (auto &name: program) { - program_.push_back(env_.getModuleAddress(name)); + program_.push_back(env().getModuleAddress(name)); } scheduled_ = true; memPeak_ = memPeak(program_); @@ -291,7 +296,7 @@ void Application::printSchedule(void) for (unsigned int i = 0; i < program_.size(); ++i) { LOG(Message) << std::setw(4) << i + 1 << ": " - << env_.getModuleName(program_[i]) << std::endl; + << env().getModuleName(program_[i]) << std::endl; } } @@ -304,9 +309,9 @@ void Application::configLoop(void) { LOG(Message) << BIG_SEP << " Starting measurement for trajectory " << t << " " << BIG_SEP << std::endl; - env_.setTrajectory(t); - env_.executeProgram(program_); - env_.freeAll(); + env().setTrajectory(t); + env().executeProgram(program_); } LOG(Message) << BIG_SEP << " End of measurement " << BIG_SEP << std::endl; + env().freeAll(); } diff --git a/extras/Hadrons/Application.hpp b/extras/Hadrons/Application.hpp index 4ea262df..fce9b6eb 100644 --- a/extras/Hadrons/Application.hpp +++ b/extras/Hadrons/Application.hpp @@ -98,11 +98,13 @@ public: void printSchedule(void); // loop on configurations void configLoop(void); +private: + // environment shortcut + Environment & env(void) const; private: long unsigned int locVol_; std::string parameterFileName_{""}; GlobalPar par_; - Environment &env_; std::vector program_; Environment::Size memPeak_; bool scheduled_{false}; @@ -115,14 +117,14 @@ private: template void Application::createModule(const std::string name) { - env_.createModule(name); + env().createModule(name); } template void Application::createModule(const std::string name, const typename M::Par &par) { - env_.createModule(name, par); + env().createModule(name, par); } END_HADRONS_NAMESPACE diff --git a/extras/Hadrons/Environment.cc b/extras/Hadrons/Environment.cc index 4b230e20..37f2a3d7 100644 --- a/extras/Hadrons/Environment.cc +++ b/extras/Hadrons/Environment.cc @@ -41,8 +41,9 @@ using namespace Hadrons; // constructor ///////////////////////////////////////////////////////////////// Environment::Environment(void) { + nd_ = GridDefaultLatt().size(); grid4d_.reset(SpaceTimeGrid::makeFourDimGrid( - GridDefaultLatt(), GridDefaultSimd(Nd, vComplex::Nsimd()), + GridDefaultLatt(), GridDefaultSimd(nd_, vComplex::Nsimd()), GridDefaultMpi())); gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get())); auto loc = getGrid()->LocalDimensions(); @@ -126,6 +127,11 @@ GridRedBlackCartesian * Environment::getRbGrid(const unsigned int Ls) const } } +unsigned int Environment::getNd(void) const +{ + return nd_; +} + // random number generator ///////////////////////////////////////////////////// void Environment::setSeed(const std::vector &seed) { @@ -410,12 +416,19 @@ Environment::Size Environment::executeProgram(const std::vector &p) // general memory management /////////////////////////////////////////////////// void Environment::addObject(const std::string name, const int moduleAddress) { - ObjInfo info; - - info.name = name; - info.module = moduleAddress; - object_.push_back(std::move(info)); - objectAddress_[name] = static_cast(object_.size() - 1); + if (!hasObject(name)) + { + ObjInfo info; + + info.name = name; + info.module = moduleAddress; + object_.push_back(std::move(info)); + objectAddress_[name] = static_cast(object_.size() - 1); + } + else + { + HADRON_ERROR("object '" + name + "' already exists"); + } } void Environment::registerObject(const unsigned int address, @@ -444,6 +457,10 @@ void Environment::registerObject(const unsigned int address, void Environment::registerObject(const std::string name, const unsigned int size, const unsigned int Ls) { + if (!hasObject(name)) + { + addObject(name); + } registerObject(getObjectAddress(name), size, Ls); } @@ -573,6 +590,30 @@ bool Environment::hasRegisteredObject(const std::string name) const } } +bool Environment::hasCreatedObject(const unsigned int address) const +{ + if (hasObject(address)) + { + return (object_[address].data != nullptr); + } + else + { + return false; + } +} + +bool Environment::hasCreatedObject(const std::string name) const +{ + if (hasObject(name)) + { + return hasCreatedObject(getObjectAddress(name)); + } + else + { + return false; + } +} + bool Environment::isObject5d(const unsigned int address) const { return (getObjectLs(address) > 1); diff --git a/extras/Hadrons/Environment.hpp b/extras/Hadrons/Environment.hpp index 41a7a008..2628e5a0 100644 --- a/extras/Hadrons/Environment.hpp +++ b/extras/Hadrons/Environment.hpp @@ -106,6 +106,7 @@ public: void createGrid(const unsigned int Ls); GridCartesian * getGrid(const unsigned int Ls = 1) const; GridRedBlackCartesian * getRbGrid(const unsigned int Ls = 1) const; + unsigned int getNd(void) const; // random number generator void setSeed(const std::vector &seed); GridParallelRNG * get4dRng(void) const; @@ -137,7 +138,7 @@ public: Size executeProgram(const std::vector &p); // general memory management void addObject(const std::string name, - const int moduleAddress); + const int moduleAddress = -1); void registerObject(const unsigned int address, const unsigned int size, const unsigned int Ls = 1); @@ -176,6 +177,8 @@ public: bool hasObject(const std::string name) const; bool hasRegisteredObject(const unsigned int address) const; bool hasRegisteredObject(const std::string name) const; + bool hasCreatedObject(const unsigned int address) const; + bool hasCreatedObject(const std::string name) const; bool isObject5d(const unsigned int address) const; bool isObject5d(const std::string name) const; Environment::Size getTotalSize(void) const; @@ -198,6 +201,7 @@ private: std::map grid5d_; GridRbPt gridRb4d_; std::map gridRb5d_; + unsigned int nd_; // random number generator RngPt rng4d_; // module and related maps diff --git a/extras/Hadrons/GeneticScheduler.hpp b/extras/Hadrons/GeneticScheduler.hpp index 7b5fc183..d0c52596 100644 --- a/extras/Hadrons/GeneticScheduler.hpp +++ b/extras/Hadrons/GeneticScheduler.hpp @@ -134,7 +134,7 @@ void GeneticScheduler::nextGeneration(void) LOG(Debug) << "Starting population:\n" << *this << std::endl; // random mutations - PARALLEL_FOR_LOOP + //PARALLEL_FOR_LOOP for (unsigned int i = 0; i < par_.popSize; ++i) { doMutation(); @@ -142,7 +142,7 @@ void GeneticScheduler::nextGeneration(void) LOG(Debug) << "After mutations:\n" << *this << std::endl; // mating - PARALLEL_FOR_LOOP + //PARALLEL_FOR_LOOP for (unsigned int i = 0; i < par_.popSize/2; ++i) { doCrossover(); @@ -166,7 +166,7 @@ void GeneticScheduler::initPopulation(void) { auto p = graph_.topoSort(gen_); - population_.emplace(func_(p), p); + population_.insert(std::make_pair(func_(p), p)); } } @@ -180,8 +180,8 @@ void GeneticScheduler::doCrossover(void) crossover(c1, c2, p1, p2); PARALLEL_CRITICAL { - population_.emplace(func_(c1), c1); - population_.emplace(func_(c2), c2); + population_.insert(std::make_pair(func_(c1), c1)); + population_.insert(std::make_pair(func_(c2), c2)); } } @@ -200,7 +200,7 @@ void GeneticScheduler::doMutation(void) mutation(m, it->second); PARALLEL_CRITICAL { - population_.emplace(func_(m), m); + population_.insert(std::make_pair(func_(m), m)); } } } diff --git a/extras/Hadrons/Modules/MContraction/Meson.hpp b/extras/Hadrons/Modules/MContraction/Meson.hpp index dc4f60ee..c8ea3371 100644 --- a/extras/Hadrons/Modules/MContraction/Meson.hpp +++ b/extras/Hadrons/Modules/MContraction/Meson.hpp @@ -45,9 +45,11 @@ class MesonPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(MesonPar, - std::string, q1, - std::string, q2, - std::string, output); + std::string, q1, + std::string, q2, + std::string, output, + Gamma::Algebra, gammaSource, + Gamma::Algebra, gammaSink); }; template @@ -59,8 +61,7 @@ public: class Result: Serializable { public: - GRID_SERIALIZABLE_CLASS_MEMBERS(Result, - std::vector>>, corr); + GRID_SERIALIZABLE_CLASS_MEMBERS(Result, std::vector, corr); }; public: // constructor @@ -114,29 +115,17 @@ void TMeson::execute(void) PropagatorField1 &q1 = *env().template getObject(par().q1); PropagatorField2 &q2 = *env().template getObject(par().q2); LatticeComplex c(env().getGrid()); - SpinMatrix g[Ns*Ns], g5; + Gamma gSrc(par().gammaSource), gSnk(par().gammaSink); + Gamma g5(Gamma::Algebra::Gamma5); std::vector buf; Result result; - g5 = makeGammaProd(Ns*Ns - 1); - result.corr.resize(Ns*Ns); - for (unsigned int i = 0; i < Ns*Ns; ++i) + c = trace(gSnk*q1*adj(gSrc)*g5*adj(q2)*g5); + sliceSum(c, buf, Tp); + result.corr.resize(buf.size()); + for (unsigned int t = 0; t < buf.size(); ++t) { - g[i] = makeGammaProd(i); - } - for (unsigned int iSink = 0; iSink < Ns*Ns; ++iSink) - { - result.corr[iSink].resize(Ns*Ns); - for (unsigned int iSrc = 0; iSrc < Ns*Ns; ++iSrc) - { - c = trace(g[iSink]*q1*g[iSrc]*g5*adj(q2)*g5); - sliceSum(c, buf, Tp); - result.corr[iSink][iSrc].resize(buf.size()); - for (unsigned int t = 0; t < buf.size(); ++t) - { - result.corr[iSink][iSrc][t] = TensorRemove(buf[t]); - } - } + result.corr[t] = TensorRemove(buf[t]); } write(writer, "meson", result); } diff --git a/extras/Hadrons/Modules/MSource/SeqGamma.hpp b/extras/Hadrons/Modules/MSource/SeqGamma.hpp index 181f9532..5cb8483f 100644 --- a/extras/Hadrons/Modules/MSource/SeqGamma.hpp +++ b/extras/Hadrons/Modules/MSource/SeqGamma.hpp @@ -60,11 +60,11 @@ class SeqGammaPar: Serializable { public: GRID_SERIALIZABLE_CLASS_MEMBERS(SeqGammaPar, - std::string, q, - unsigned int, tA, - unsigned int, tB, - unsigned int, gamma, - std::string, mom); + std::string, q, + unsigned int, tA, + unsigned int, tB, + Gamma::Algebra, gamma, + std::string, mom); }; template @@ -140,21 +140,20 @@ void TSeqGamma::execute(void) PropagatorField &q = *env().template getObject(par().q); Lattice> t(env().getGrid()); LatticeComplex ph(env().getGrid()), coor(env().getGrid()); - SpinMatrix g; + Gamma g(par().gamma); std::vector p; Complex i(0.0,1.0); - g = makeGammaProd(par().gamma); p = strToVec(par().mom); ph = zero; - for(unsigned int mu = 0; mu < Nd; mu++) + for(unsigned int mu = 0; mu < env().getNd(); mu++) { LatticeCoordinate(coor, mu); ph = ph + p[mu]*coor; } ph = exp(i*ph); LatticeCoordinate(t, Tp); - src = where((t >= par().tA) and (t <= par().tB), g*ph*q, 0.*q); + src = where((t >= par().tA) and (t <= par().tB), ph*(g*q), 0.*q); } END_MODULE_NAMESPACE diff --git a/lib/Grid.h b/lib/Grid.h index 6430703a..543b0330 100644 --- a/lib/Grid.h +++ b/lib/Grid.h @@ -40,7 +40,7 @@ Author: paboyle #include #include -#include +#include #include #include diff --git a/lib/GridCore.h b/lib/GridCore.h index 6ec23594..26fbc1b9 100644 --- a/lib/GridCore.h +++ b/lib/GridCore.h @@ -61,12 +61,12 @@ Author: paboyle /////////////////// #include "Config.h" -#include #include #include #include #include #include +#include #include #include #include diff --git a/lib/GridQCDcore.h b/lib/GridQCDcore.h index 0a9fdbd8..7f50761f 100644 --- a/lib/GridQCDcore.h +++ b/lib/GridQCDcore.h @@ -27,7 +27,6 @@ Author: paboyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ - #ifndef GRID_QCD_CORE_H #define GRID_QCD_CORE_H diff --git a/lib/Makefile.am b/lib/Makefile.am index a779135f..fac622ca 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,4 +1,5 @@ extra_sources= +extra_headers= if BUILD_COMMS_MPI extra_sources+=communicator/Communicator_mpi.cc extra_sources+=communicator/Communicator_base.cc @@ -24,6 +25,12 @@ if BUILD_COMMS_NONE extra_sources+=communicator/Communicator_base.cc endif +if BUILD_HDF5 + extra_sources+=serialisation/Hdf5IO.cc + extra_headers+=serialisation/Hdf5IO.h + extra_headers+=serialisation/Hdf5Type.h +endif + # # Libraries # @@ -32,6 +39,9 @@ include Eigen.inc lib_LIBRARIES = libGrid.a -libGrid_a_SOURCES = $(CCFILES) $(extra_sources) +CCFILES += $(extra_sources) +HFILES += $(extra_headers) + +libGrid_a_SOURCES = $(CCFILES) libGrid_adir = $(pkgincludedir) nobase_dist_pkginclude_HEADERS = $(HFILES) $(eigen_files) Config.h diff --git a/lib/algorithms/approx/Remez.h b/lib/algorithms/approx/Remez.h index 804bce7c..31938779 100644 --- a/lib/algorithms/approx/Remez.h +++ b/lib/algorithms/approx/Remez.h @@ -16,7 +16,7 @@ #define INCLUDED_ALG_REMEZ_H #include -#include +#include #ifdef HAVE_LIBGMP #include "bigfloat.h" diff --git a/lib/algorithms/iterative/ConjugateGradient.h b/lib/algorithms/iterative/ConjugateGradient.h index cf3872c8..0f24ae94 100644 --- a/lib/algorithms/iterative/ConjugateGradient.h +++ b/lib/algorithms/iterative/ConjugateGradient.h @@ -45,6 +45,8 @@ class ConjugateGradient : public OperatorFunction { // Defaults true. RealD Tolerance; Integer MaxIterations; + Integer IterationsToComplete; //Number of iterations the CG took to finish. Filled in upon completion + ConjugateGradient(RealD tol, Integer maxit, bool err_on_no_conv = true) : Tolerance(tol), MaxIterations(maxit), @@ -155,13 +157,14 @@ class ConjugateGradient : public OperatorFunction { std::cout << std::endl; if (ErrorOnNoConverge) assert(true_residual / Tolerance < 10000.0); - + IterationsToComplete = k; return; } } std::cout << GridLogMessage << "ConjugateGradient did NOT converge" << std::endl; if (ErrorOnNoConverge) assert(0); + IterationsToComplete = k; } }; } diff --git a/lib/algorithms/iterative/ConjugateGradientMixedPrec.h b/lib/algorithms/iterative/ConjugateGradientMixedPrec.h index 446465a1..c7332455 100644 --- a/lib/algorithms/iterative/ConjugateGradientMixedPrec.h +++ b/lib/algorithms/iterative/ConjugateGradientMixedPrec.h @@ -35,6 +35,7 @@ namespace Grid { class MixedPrecisionConjugateGradient : public LinearFunction { public: RealD Tolerance; + RealD InnerTolerance; //Initial tolerance for inner CG. Defaults to Tolerance but can be changed Integer MaxInnerIterations; Integer MaxOuterIterations; GridBase* SinglePrecGrid; //Grid for single-precision fields @@ -42,12 +43,16 @@ namespace Grid { LinearOperatorBase &Linop_f; LinearOperatorBase &Linop_d; + Integer TotalInnerIterations; //Number of inner CG iterations + Integer TotalOuterIterations; //Number of restarts + Integer TotalFinalStepIterations; //Number of CG iterations in final patch-up step + //Option to speed up *inner single precision* solves using a LinearFunction that produces a guess LinearFunction *guesser; MixedPrecisionConjugateGradient(RealD tol, Integer maxinnerit, Integer maxouterit, GridBase* _sp_grid, LinearOperatorBase &_Linop_f, LinearOperatorBase &_Linop_d) : Linop_f(_Linop_f), Linop_d(_Linop_d), - Tolerance(tol), MaxInnerIterations(maxinnerit), MaxOuterIterations(maxouterit), SinglePrecGrid(_sp_grid), + Tolerance(tol), InnerTolerance(tol), MaxInnerIterations(maxinnerit), MaxOuterIterations(maxouterit), SinglePrecGrid(_sp_grid), OuterLoopNormMult(100.), guesser(NULL){ }; void useGuesser(LinearFunction &g){ @@ -55,6 +60,8 @@ namespace Grid { } void operator() (const FieldD &src_d_in, FieldD &sol_d){ + TotalInnerIterations = 0; + GridStopWatch TotalTimer; TotalTimer.Start(); @@ -74,7 +81,7 @@ namespace Grid { FieldD src_d(DoublePrecGrid); src_d = src_d_in; //source for next inner iteration, computed from residual during operation - RealD inner_tol = Tolerance; + RealD inner_tol = InnerTolerance; FieldF src_f(SinglePrecGrid); src_f.checkerboard = cb; @@ -89,7 +96,9 @@ namespace Grid { GridStopWatch PrecChangeTimer; - for(Integer outer_iter = 0; outer_iter < MaxOuterIterations; outer_iter++){ + Integer &outer_iter = TotalOuterIterations; //so it will be equal to the final iteration count + + for(outer_iter = 0; outer_iter < MaxOuterIterations; outer_iter++){ //Compute double precision rsd and also new RHS vector. Linop_d.HermOp(sol_d, tmp_d); RealD norm = axpy_norm(src_d, -1., tmp_d, src_d_in); //src_d is residual vector @@ -117,6 +126,7 @@ namespace Grid { InnerCGtimer.Start(); CG_f(Linop_f, src_f, sol_f); InnerCGtimer.Stop(); + TotalInnerIterations += CG_f.IterationsToComplete; //Convert sol back to double and add to double prec solution PrecChangeTimer.Start(); @@ -131,9 +141,11 @@ namespace Grid { ConjugateGradient CG_d(Tolerance, MaxInnerIterations); CG_d(Linop_d, src_d_in, sol_d); + TotalFinalStepIterations = CG_d.IterationsToComplete; TotalTimer.Stop(); - std::cout< #include #include #include -#include +#include /** Sign function **/ diff --git a/lib/lattice/Lattice_rng.h b/lib/lattice/Lattice_rng.h index a1e423b8..3d653d17 100644 --- a/lib/lattice/Lattice_rng.h +++ b/lib/lattice/Lattice_rng.h @@ -30,6 +30,7 @@ Author: paboyle #define GRID_LATTICE_RNG_H #include +#include namespace Grid { @@ -127,10 +128,14 @@ namespace Grid { typedef uint64_t RngStateType; typedef std::ranlux48 RngEngine; static const int RngStateCount = 15; -#else +#elif RNG_MT19937 typedef std::mt19937 RngEngine; typedef uint32_t RngStateType; static const int RngStateCount = std::mt19937::state_size; +#elif RNG_SITMO + typedef sitmo::prng_engine RngEngine; + typedef uint64_t RngStateType; + static const int RngStateCount = 4; #endif std::vector _generators; std::vector> _uniform; diff --git a/lib/lattice/Lattice_transfer.h b/lib/lattice/Lattice_transfer.h index 3f4719c5..8eb75f15 100644 --- a/lib/lattice/Lattice_transfer.h +++ b/lib/lattice/Lattice_transfer.h @@ -429,7 +429,7 @@ void ExtractSlice(Lattice &lowDim, Lattice & higherDim,int slice, in std::vector lcoor(nl); std::vector hcoor(nh); lg->LocalIndexToLocalCoor(idx,lcoor); - ddl=0; + int ddl=0; hcoor[orthog] = slice; for(int d=0;d #include - namespace Grid { - bool PmuStat::pmu_initialized=false; diff --git a/lib/pugixml/pugixml.cc b/lib/pugixml/pugixml.cc index 525d1419..a4f8fde2 100644 --- a/lib/pugixml/pugixml.cc +++ b/lib/pugixml/pugixml.cc @@ -14,7 +14,7 @@ #ifndef SOURCE_PUGIXML_CPP #define SOURCE_PUGIXML_CPP -#include +#include #include #include diff --git a/lib/qcd/action/Action.h b/lib/qcd/action/Action.h index 37b13a9f..7272c90d 100644 --- a/lib/qcd/action/Action.h +++ b/lib/qcd/action/Action.h @@ -30,23 +30,18 @@ Author: paboyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#ifndef GRID_QCD_ACTIONS_H -#define GRID_QCD_ACTIONS_H - -// * Linear operators (Hermitian and non-hermitian) .. my LinearOperator -// * System solvers (Hermitian and non-hermitian) .. my OperatorFunction -// * MultiShift System solvers (Hermitian and non-hermitian) .. my OperatorFunction +#ifndef GRID_QCD_ACTION_H +#define GRID_QCD_ACTION_H //////////////////////////////////////////// // Abstract base interface //////////////////////////////////////////// #include - //////////////////////////////////////////////////////////////////////// // Fermion actions; prevent coupling fermion.cc files to other headers //////////////////////////////////////////////////////////////////////// +#include #include - //////////////////////////////////////// // Pseudo fermion combinations for HMC //////////////////////////////////////// diff --git a/lib/qcd/action/fermion/Fermion.h b/lib/qcd/action/fermion/Fermion.h index c806342d..f08a45df 100644 --- a/lib/qcd/action/fermion/Fermion.h +++ b/lib/qcd/action/fermion/Fermion.h @@ -25,8 +25,8 @@ Author: Peter Boyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#ifndef GRID_QCD_FERMION_ACTIONS_H -#define GRID_QCD_FERMION_ACTIONS_H +#ifndef GRID_QCD_FERMION_H +#define GRID_QCD_FERMION_H //////////////////////////////////////////////////////////////////////////////////////////////////// // Explicit explicit template instantiation is still required in the .cc files diff --git a/lib/qcd/action/fermion/PartialFractionFermion5D.cc b/lib/qcd/action/fermion/PartialFractionFermion5D.cc index ec004816..3a78e043 100644 --- a/lib/qcd/action/fermion/PartialFractionFermion5D.cc +++ b/lib/qcd/action/fermion/PartialFractionFermion5D.cc @@ -28,6 +28,7 @@ Author: Peter Boyle /* END LEGAL */ #include #include + namespace Grid { namespace QCD { diff --git a/lib/qcd/action/fermion/WilsonFermion.cc b/lib/qcd/action/fermion/WilsonFermion.cc index 0320bb27..ca200b10 100644 --- a/lib/qcd/action/fermion/WilsonFermion.cc +++ b/lib/qcd/action/fermion/WilsonFermion.cc @@ -134,7 +134,6 @@ void WilsonFermion::MooeeInvDag(const FermionField &in, FermionField &out) out.checkerboard = in.checkerboard; MooeeInv(in,out); } - template void WilsonFermion::MomentumSpacePropagator(FermionField &out, const FermionField &in,RealD _m) { @@ -145,11 +144,11 @@ void WilsonFermion::MomentumSpacePropagator(FermionField &out, const Fermi // what type LatticeComplex conformable(_grid,out._grid); - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; std::vector latt_size = _grid->_fdimensions; diff --git a/lib/qcd/action/fermion/WilsonFermion5D.cc b/lib/qcd/action/fermion/WilsonFermion5D.cc index 62f339ed..6027322b 100644 --- a/lib/qcd/action/fermion/WilsonFermion5D.cc +++ b/lib/qcd/action/fermion/WilsonFermion5D.cc @@ -563,11 +563,11 @@ void WilsonFermion5D::MomentumSpacePropagatorHt(FermionField &out,const Fe typedef iSinglet Tcomplex; typedef Lattice > LatComplex; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; std::vector latt_size = _grid->_fdimensions; @@ -634,11 +634,11 @@ void WilsonFermion5D::MomentumSpacePropagatorHt(FermionField &out,const Fe template void WilsonFermion5D::MomentumSpacePropagatorHw(FermionField &out,const FermionField &in,RealD mass) { - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; GridBase *_grid = _FourDimGrid; diff --git a/lib/qcd/action/fermion/WilsonKernels.cc b/lib/qcd/action/fermion/WilsonKernels.cc index e44d58b6..6e72e089 100644 --- a/lib/qcd/action/fermion/WilsonKernels.cc +++ b/lib/qcd/action/fermion/WilsonKernels.cc @@ -29,6 +29,7 @@ directory *************************************************************************************/ /* END LEGAL */ #include + namespace Grid { namespace QCD { diff --git a/lib/qcd/action/fermion/WilsonKernelsAsm.cc b/lib/qcd/action/fermion/WilsonKernelsAsm.cc index 2d11523a..d43d9c92 100644 --- a/lib/qcd/action/fermion/WilsonKernelsAsm.cc +++ b/lib/qcd/action/fermion/WilsonKernelsAsm.cc @@ -32,7 +32,6 @@ Author: Guido Cossu #include - namespace Grid { namespace QCD { diff --git a/lib/qcd/action/fermion/g5HermitianLinop.h b/lib/qcd/action/fermion/g5HermitianLinop.h index af23c36f..cca7a113 100644 --- a/lib/qcd/action/fermion/g5HermitianLinop.h +++ b/lib/qcd/action/fermion/g5HermitianLinop.h @@ -80,7 +80,7 @@ class Gamma5HermitianLinearOperator : public LinearOperatorBase { Matrix &_Mat; Gamma g5; public: - Gamma5HermitianLinearOperator(Matrix &Mat): _Mat(Mat), g5(Gamma::Gamma5) {}; + Gamma5HermitianLinearOperator(Matrix &Mat): _Mat(Mat), g5(Gamma::Algebra::Gamma5) {}; void Op (const Field &in, Field &out){ HermOp(in,out); } diff --git a/lib/qcd/action/gauge/Gauge.h b/lib/qcd/action/gauge/Gauge.h index da670911..f3e0e53b 100644 --- a/lib/qcd/action/gauge/Gauge.h +++ b/lib/qcd/action/gauge/Gauge.h @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#ifndef GRID_QCD_GAUGE_AGGREGATE_H -#define GRID_QCD_GAUGE_AGGREGATE_H +#ifndef GRID_QCD_GAUGE_H +#define GRID_QCD_GAUGE_H #include #include diff --git a/lib/qcd/spin/Dirac.cc b/lib/qcd/spin/Dirac.cc deleted file mode 100644 index 70e052de..00000000 --- a/lib/qcd/spin/Dirac.cc +++ /dev/null @@ -1,96 +0,0 @@ - /************************************************************************************* - - Grid physics library, www.github.com/paboyle/Grid - - Source file: ./lib/qcd/spin/Dirac.cc - - Copyright (C) 2015 - -Author: Peter Boyle - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - See the full license in the file "LICENSE" in the top level distribution directory - *************************************************************************************/ - /* END LEGAL */ -#include -#include - -namespace Grid { - - namespace QCD { - - Gamma::GammaMatrix Gamma::GammaMatrices [] = { - Gamma::Identity, - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT, - Gamma::Gamma5, - Gamma::MinusIdentity, - Gamma::MinusGammaX, - Gamma::MinusGammaY, - Gamma::MinusGammaZ, - Gamma::MinusGammaT, - Gamma::MinusGamma5 - }; - const char *Gamma::GammaMatrixNames[] = { - "Identity ", - "GammaX ", - "GammaY ", - "GammaZ ", - "GammaT ", - "Gamma5 ", - "-Identity", - "-GammaX ", - "-GammaY ", - "-GammaZ ", - "-GammaT ", - "-Gamma5 ", - " " - }; - - SpinMatrix makeGammaProd(const unsigned int i) - { - SpinMatrix g; - - g = 1.; - if (i & 0x1) - { - g = g*Gamma(Gamma::GammaMatrix::GammaX); - } - if (i & 0x2) - { - g = g*Gamma(Gamma::GammaMatrix::GammaY); - } - if (i & 0x4) - { - g = g*Gamma(Gamma::GammaMatrix::GammaZ); - } - if (i & 0x8) - { - g = g*Gamma(Gamma::GammaMatrix::GammaT); - } - - return g; - } - - // void sprojMul( vHalfSpinColourVector &out,vColourMatrix &u, vSpinColourVector &in){ - // vHalfSpinColourVector hspin; - // spProjXp(hspin,in); - // mult(&out,&u,&hspin); - // } - } -} diff --git a/lib/qcd/spin/Dirac.h b/lib/qcd/spin/Dirac.h index 00bd519c..ed22ec97 100644 --- a/lib/qcd/spin/Dirac.h +++ b/lib/qcd/spin/Dirac.h @@ -1,628 +1,232 @@ - /************************************************************************************* +/************************************************************************************* - Grid physics library, www.github.com/paboyle/Grid +Grid physics library, www.github.com/paboyle/Grid - Source file: ./lib/qcd/spin/Dirac.h +Source file: lib/qcd/spin/Dirac.h - Copyright (C) 2015 +Copyright (C) 2015 +Copyright (C) 2016 +Author: Antonin Portelli Author: Peter Boyle Author: Peter Boyle +Author: paboyle - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - See the full license in the file "LICENSE" in the top level distribution directory - *************************************************************************************/ - /* END LEGAL */ +See the full license in the file "LICENSE" in the top level distribution directory +*************************************************************************************/ +/* END LEGAL */ #ifndef GRID_QCD_DIRAC_H #define GRID_QCD_DIRAC_H -namespace Grid{ + +// Gamma matrices using the code generated by the Mathematica notebook +// gamma-gen/gamma-gen.nb in Gamma.cc & Gamma.h +//////////////////////////////////////////////////////////////////////////////// +#include + +namespace Grid { + +// Dirac algebra adjoint operator (not in QCD:: to overload other adj) +inline QCD::Gamma adj(const QCD::Gamma &g) +{ + return QCD::Gamma (QCD::Gamma::adj[g.g]); +} namespace QCD { +// Dirac algebra mutliplication operator +inline Gamma operator*(const Gamma &g1, const Gamma &g2) +{ + return Gamma (Gamma::mul[g1.g][g2.g]); +} - class Gamma { +// general left multiply +template +inline auto operator*(const Gamma &G, const iScalar &arg) +->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type +{ + iScalar ret; + ret._internal=G*arg._internal; + return ret; +} - public: +template +inline auto operator*(const Gamma &G, const iVector &arg) +->typename std::enable_if,SpinorIndex>::notvalue,iVector>::type +{ + iVector ret; + for(int i=0;i +inline auto operator*(const Gamma &G, const iMatrix &arg) +->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type +{ + iMatrix ret; + for(int i=0;i +inline auto operator*(const iScalar &arg, const Gamma &G) +->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type +{ + iScalar ret; + ret._internal=arg._internal*G; + return ret; +} - GammaMatrix _g; +template +inline auto operator * (const iMatrix &arg, const Gamma &G) +->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type +{ + iMatrix ret; + for(int i=0;i +inline auto operator*(const GammaL &gl, const iVector &arg) +->typename std::enable_if, SpinorIndex>::value, iVector>::type +{ + iVector buf; - // Make gamma products (Chroma convention) - SpinMatrix makeGammaProd(const unsigned int i); - - /* Gx - * 0 0 0 i - * 0 0 i 0 - * 0 -i 0 0 - * -i 0 0 0 - */ - // right multiplication makes sense for matrix args, not for vector since there is - // no concept of row versus columnar indices - template inline void rmultMinusGammaX(iMatrix &ret,const iMatrix &rhs){ - for(int i=0;i inline void rmultGammaX(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaX(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multMinusGammaX(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaX(iVector &ret, const iVector &rhs){ - ret._internal[0] = timesI(rhs._internal[3]); - ret._internal[1] = timesI(rhs._internal[2]); - ret._internal[2] = timesMinusI(rhs._internal[1]); - ret._internal[3] = timesMinusI(rhs._internal[0]); - }; - template inline void multMinusGammaX(iVector &ret, const iVector &rhs){ - ret(0) = timesMinusI(rhs(3)); - ret(1) = timesMinusI(rhs(2)); - ret(2) = timesI(rhs(1)); - ret(3) = timesI(rhs(0)); - }; +// matrix left multiply +template +inline auto operator*(const GammaL &gl, const iMatrix &arg) +->typename std::enable_if, SpinorIndex>::value, iMatrix>::type +{ + iMatrix buf; + + for(unsigned int i = 0; i < Ns; ++i) + { + buf(0, i) = 0.; + buf(1, i) = 0.; + buf(2, i) = 2.*arg(2, i); + buf(3, i) = 2.*arg(3, i); + } + + return gl.gamma*buf; +}; +// matrix right multiply +template +inline auto operator*(const iMatrix &arg, const GammaL &gl) +->typename std::enable_if, SpinorIndex>::value, iMatrix>::type +{ + iMatrix buf; + + buf = arg*gl.gamma; + for(unsigned int i = 0; i < Ns; ++i) + { + buf(i, 0) = 0.; + buf(i, 1) = 0.; + buf(i, 2) = 2.*buf(i, 2); + buf(i, 3) = 2.*buf(i, 3); + } + + return buf; +}; - /*Gy - * 0 0 0 -1 [0] -+ [3] - * 0 0 1 0 [1] +- [2] - * 0 1 0 0 - * -1 0 0 0 - */ - template inline void rmultGammaY(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void rmultMinusGammaY(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaY(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multMinusGammaY(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaY(iVector &ret, const iVector &rhs){ - ret(0) = -rhs(3); - ret(1) = rhs(2); - ret(2) = rhs(1); - ret(3) = -rhs(0); - }; - template inline void multMinusGammaY(iVector &ret, const iVector &rhs){ - ret(0) = rhs(3); - ret(1) = -rhs(2); - ret(2) = -rhs(1); - ret(3) = rhs(0); - }; - /*Gz - * 0 0 i 0 [0]+-i[2] - * 0 0 0 -i [1]-+i[3] - * -i 0 0 0 - * 0 i 0 0 - */ - template inline void rmultGammaZ(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void rmultMinusGammaZ(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaZ(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multMinusGammaZ(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaZ(iVector &ret, const iVector &rhs){ - ret(0) = timesI(rhs(2)); - ret(1) =timesMinusI(rhs(3)); - ret(2) =timesMinusI(rhs(0)); - ret(3) = timesI(rhs(1)); - }; - template inline void multMinusGammaZ(iVector &ret, const iVector &rhs){ - ret(0) = timesMinusI(rhs(2)); - ret(1) = timesI(rhs(3)); - ret(2) = timesI(rhs(0)); - ret(3) = timesMinusI(rhs(1)); - }; - /*Gt - * 0 0 1 0 [0]+-[2] - * 0 0 0 1 [1]+-[3] - * 1 0 0 0 - * 0 1 0 0 - */ - template inline void rmultGammaT(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void rmultMinusGammaT(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaT(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multMinusGammaT(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multGammaT(iVector &ret, const iVector &rhs){ - ret(0) = rhs(2); - ret(1) = rhs(3); - ret(2) = rhs(0); - ret(3) = rhs(1); - }; - template inline void multMinusGammaT(iVector &ret, const iVector &rhs){ - ret(0) =-rhs(2); - ret(1) =-rhs(3); - ret(2) =-rhs(0); - ret(3) =-rhs(1); - }; - /*G5 - * 1 0 0 0 [0]+-[2] - * 0 1 0 0 [1]+-[3] - * 0 0 -1 0 - * 0 0 0 -1 - */ - template inline void rmultGamma5(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void rmultMinusGamma5(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i +inline auto operator*(const GammaL &gl, const iScalar &arg) +->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type +{ + iScalar ret; + ret._internal=gl*arg._internal; + return ret; +} - template inline void multGamma5(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i inline void multMinusGamma5(iMatrix &ret, const iMatrix &rhs){ - for(int i=0;i +inline auto operator*(const GammaL &gl, const iVector &arg) +->typename std::enable_if,SpinorIndex>::notvalue,iVector>::type +{ + iVector ret; + for(int i=0;i inline void multGamma5(iVector &ret, const iVector &rhs){ - ret(0) = rhs(0); - ret(1) = rhs(1); - ret(2) =-rhs(2); - ret(3) =-rhs(3); - }; - template inline void multMinusGamma5(iVector &ret, const iVector &rhs){ - ret(0) =-rhs(0); - ret(1) =-rhs(1); - ret(2) = rhs(2); - ret(3) = rhs(3); - }; +template +inline auto operator*(const GammaL &gl, const iMatrix &arg) +->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type +{ + iMatrix ret; + for(int i=0;i +inline auto operator*(const iScalar &arg, const GammaL &gl) +->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type +{ + iScalar ret; + ret._internal=arg._internal*gl; + return ret; +} +template +inline auto operator * (const iMatrix &arg, const GammaL &gl) +->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type +{ + iMatrix ret; + for(int i=0;i inline auto operator * ( const Gamma &G,const iScalar &arg) -> - typename std::enable_if,SpinorIndex>::notvalue,iScalar >::type - - { - iScalar ret; - ret._internal=G*arg._internal; - return ret; - } - template inline auto operator * ( const Gamma &G,const iVector &arg) -> - typename std::enable_if,SpinorIndex>::notvalue,iVector >::type - { - iVector ret; - for(int i=0;i inline auto operator * ( const Gamma &G,const iMatrix &arg) -> - typename std::enable_if,SpinorIndex>::notvalue,iMatrix >::type - { - iMatrix ret; - for(int i=0;i inline auto operator * (const iScalar &arg, const Gamma &G) -> - typename std::enable_if,SpinorIndex>::notvalue,iScalar >::type - - { - iScalar ret; - ret._internal=arg._internal*G; - return ret; - } - template inline auto operator * (const iVector &arg, const Gamma &G) -> - typename std::enable_if,SpinorIndex>::notvalue,iVector >::type - { - iVector ret; - for(int i=0;i inline auto operator * (const iMatrix &arg, const Gamma &G) -> - typename std::enable_if,SpinorIndex>::notvalue,iMatrix >::type - { - iMatrix ret; - for(int i=0;i inline auto operator * ( const Gamma &G,const iMatrix &arg) -> - typename std::enable_if,SpinorIndex>::value,iMatrix >::type - { - iMatrix ret; - switch (G._g) { - case Gamma::Identity: - ret = arg; - break; - case Gamma::MinusIdentity: - ret = -arg; - break; - case Gamma::GammaX: - multGammaX(ret,arg); - break; - case Gamma::MinusGammaX: - multMinusGammaX(ret,arg); - break; - case Gamma::GammaY: - multGammaY(ret,arg); - break; - case Gamma::MinusGammaY: - multMinusGammaY(ret,arg); - break; - case Gamma::GammaZ: - multGammaZ(ret,arg); - break; - case Gamma::MinusGammaZ: - multMinusGammaZ(ret,arg); - break; - case Gamma::GammaT: - multGammaT(ret,arg); - break; - case Gamma::MinusGammaT: - multMinusGammaT(ret,arg); - break; - case Gamma::Gamma5: - multGamma5(ret,arg); - break; - case Gamma::MinusGamma5: - multMinusGamma5(ret,arg); - break; - default: - assert(0); - break; - } - return ret; - } - // Could have used type trait for Matrix/vector and then an enable if to share code - template inline auto operator * ( const Gamma &G,const iVector &arg) -> - typename std::enable_if,SpinorIndex>::value,iVector >::type - { - iVector ret; - switch (G._g) { - case Gamma::Identity: - ret = arg; - break; - case Gamma::MinusIdentity: - ret = -arg; - break; - case Gamma::GammaX: - multGammaX(ret,arg); - break; - case Gamma::MinusGammaX: - multMinusGammaX(ret,arg); - break; - case Gamma::GammaY: - multGammaY(ret,arg); - break; - case Gamma::MinusGammaY: - multMinusGammaY(ret,arg); - break; - case Gamma::GammaZ: - multGammaZ(ret,arg); - break; - case Gamma::MinusGammaZ: - multMinusGammaZ(ret,arg); - break; - case Gamma::GammaT: - multGammaT(ret,arg); - break; - case Gamma::MinusGammaT: - multMinusGammaT(ret,arg); - break; - case Gamma::Gamma5: - multGamma5(ret,arg); - break; - case Gamma::MinusGamma5: - multMinusGamma5(ret,arg); - break; - default: - assert(0); - break; - } - return ret; - } - - template inline auto operator * (const iMatrix &arg, const Gamma &G) -> - typename std::enable_if,SpinorIndex>::value,iMatrix >::type - { - iMatrix ret; - switch (G._g) { - case Gamma::Identity: - ret = arg; - break; - case Gamma::MinusIdentity: - ret = -arg; - break; - case Gamma::GammaX: - rmultGammaX(ret,arg); - break; - case Gamma::MinusGammaX: - rmultMinusGammaX(ret,arg); - break; - case Gamma::GammaY: - rmultGammaY(ret,arg); - break; - case Gamma::MinusGammaY: - rmultMinusGammaY(ret,arg); - break; - case Gamma::GammaZ: - rmultGammaZ(ret,arg); - break; - case Gamma::MinusGammaZ: - rmultMinusGammaZ(ret,arg); - break; - case Gamma::GammaT: - rmultGammaT(ret,arg); - break; - case Gamma::MinusGammaT: - rmultMinusGammaT(ret,arg); - break; - case Gamma::Gamma5: - rmultGamma5(ret,arg); - break; - case Gamma::MinusGamma5: - rmultMinusGamma5(ret,arg); - break; - default: - assert(0); - break; - } - return ret; - } - - - /* Output from test -./Grid_gamma -Identity((1,0),(0,0),(0,0),(0,0)) - ((0,0),(1,0),(0,0),(0,0)) - ((0,0),(0,0),(1,0),(0,0)) - ((0,0),(0,0),(0,0),(1,0)) OK - -GammaX ((0,0),(0,0),(0,0),(0,1)) - ((0,0),(0,0),(0,1),(0,0)) - ((0,0),(0,-1),(0,0),(0,0)) - ((0,-1),(0,0),(0,0),(0,0)) OK - * Gx - * 0 0 0 i - * 0 0 i 0 - * 0 -i 0 0 - * -i 0 0 0 - -GammaY ((-0,-0),(-0,-0),(-0,-0),(-1,-0)) - ((0,0),(0,0),(1,0),(0,0)) - ((0,0),(1,0),(0,0),(0,0)) OK - ((-1,-0),(-0,-0),(-0,-0),(-0,-0)) - *Gy - * 0 0 0 -1 [0] -+ [3] - * 0 0 1 0 [1] +- [2] - * 0 1 0 0 - * -1 0 0 0 - -GammaZ ((0,0),(0,0),(0,1),(0,0)) - ((0,0),(0,0),(0,0),(0,-1)) - ((0,-1),(0,0),(0,0),(0,0)) - ((0,0),(0,1),(0,0),(0,0)) OK - * 0 0 i 0 [0]+-i[2] - * 0 0 0 -i [1]-+i[3] - * -i 0 0 0 - * 0 i 0 0 - -GammaT ((0,0),(0,0),(1,0),(0,0)) - ((0,0),(0,0),(0,0),(1,0)) OK - ((1,0),(0,0),(0,0),(0,0)) - ((0,0),(1,0),(0,0),(0,0)) - * 0 0 1 0 [0]+-[2] - * 0 0 0 1 [1]+-[3] - * 1 0 0 0 - * 0 1 0 0 - -Gamma5 ((1,0),(0,0),(0,0),(0,0)) - ((0,0),(1,0),(0,0),(0,0)) - ((-0,-0),(-0,-0),(-1,-0),(-0,-0)) - ((-0,-0),(-0,-0),(-0,-0),(-1,-0)) - * 1 0 0 0 [0]+-[2] - * 0 1 0 0 [1]+-[3] OK - * 0 0 -1 0 - * 0 0 0 -1 - */ - -} //namespace QCD -} // Grid #endif diff --git a/lib/qcd/spin/Gamma.cc b/lib/qcd/spin/Gamma.cc new file mode 100644 index 00000000..5d9b7719 --- /dev/null +++ b/lib/qcd/spin/Gamma.cc @@ -0,0 +1,1140 @@ +// code generated by the Mathematica notebook gamma-gen/gamma-gen.nb + +#include + +namespace Grid { +namespace QCD { + +const std::array Gamma::gmu = {{ + Gamma(Gamma::Algebra::GammaX), + Gamma(Gamma::Algebra::GammaY), + Gamma(Gamma::Algebra::GammaZ), + Gamma(Gamma::Algebra::GammaT)}}; + +const std::array Gamma::name = {{ + "-Gamma5 ", + "Gamma5 ", + "-GammaT ", + "GammaT ", + "-GammaTGamma5", + "GammaTGamma5 ", + "-GammaX ", + "GammaX ", + "-GammaXGamma5", + "GammaXGamma5 ", + "-GammaY ", + "GammaY ", + "-GammaYGamma5", + "GammaYGamma5 ", + "-GammaZ ", + "GammaZ ", + "-GammaZGamma5", + "GammaZGamma5 ", + "-Identity ", + "Identity ", + "-SigmaXT ", + "SigmaXT ", + "-SigmaXY ", + "SigmaXY ", + "-SigmaXZ ", + "SigmaXZ ", + "-SigmaYT ", + "SigmaYT ", + "-SigmaYZ ", + "SigmaYZ ", + "-SigmaZT ", + "SigmaZT "}}; + +const std::array Gamma::adj = {{ + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT}}; + +const std::array, Gamma::nGamma> Gamma::mul = {{ + {{Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY}} + , + {{Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY}} + , + {{Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ}} + , + {{Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ}} + , + {{Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5}} + , + {{Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5}} + , + {{Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5}} + , + {{Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5}} + , + {{Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY}} + , + {{Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY}} + , + {{Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5}} + , + {{Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5}} + , + {{Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX}} + , + {{Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX}} + , + {{Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT}} + , + {{Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT}} + , + {{Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5}} + , + {{Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5}} + , + {{Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT}} + , + {{Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT}} + , + {{Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ}} + , + {{Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ}} + , + {{Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5}} + , + {{Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5}} + , + {{Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT}} + , + {{Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT}} + , + {{Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ}} + , + {{Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ}} + , + {{Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT}} + , + {{Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT}} + , + {{Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::SigmaXY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaX, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::Gamma5, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusIdentity, + Gamma::Algebra::Identity}} + , + {{Gamma::Algebra::SigmaXY, + Gamma::Algebra::MinusSigmaXY, + Gamma::Algebra::MinusGammaZ, + Gamma::Algebra::GammaZ, + Gamma::Algebra::MinusGammaZGamma5, + Gamma::Algebra::GammaZGamma5, + Gamma::Algebra::GammaYGamma5, + Gamma::Algebra::MinusGammaYGamma5, + Gamma::Algebra::GammaY, + Gamma::Algebra::MinusGammaY, + Gamma::Algebra::MinusGammaXGamma5, + Gamma::Algebra::GammaXGamma5, + Gamma::Algebra::MinusGammaX, + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaT, + Gamma::Algebra::MinusGammaT, + Gamma::Algebra::GammaTGamma5, + Gamma::Algebra::MinusGammaTGamma5, + Gamma::Algebra::MinusSigmaZT, + Gamma::Algebra::SigmaZT, + Gamma::Algebra::MinusSigmaXZ, + Gamma::Algebra::SigmaXZ, + Gamma::Algebra::MinusGamma5, + Gamma::Algebra::Gamma5, + Gamma::Algebra::SigmaXT, + Gamma::Algebra::MinusSigmaXT, + Gamma::Algebra::MinusSigmaYZ, + Gamma::Algebra::SigmaYZ, + Gamma::Algebra::SigmaYT, + Gamma::Algebra::MinusSigmaYT, + Gamma::Algebra::Identity, + Gamma::Algebra::MinusIdentity}} +}}; + +}} diff --git a/lib/qcd/spin/Gamma.h b/lib/qcd/spin/Gamma.h new file mode 100644 index 00000000..bc32eab9 --- /dev/null +++ b/lib/qcd/spin/Gamma.h @@ -0,0 +1,1348 @@ +#ifndef GRID_QCD_GAMMA_H +#define GRID_QCD_GAMMA_H + +// code generated by the Mathematica notebook gamma-gen/gamma-gen.nb + +#include + +namespace Grid { +namespace QCD { + +class Gamma { + public: + GRID_SERIALIZABLE_ENUM(Algebra, undef, + MinusGamma5 , 0, + Gamma5 , 1, + MinusGammaT , 2, + GammaT , 3, + MinusGammaTGamma5, 4, + GammaTGamma5 , 5, + MinusGammaX , 6, + GammaX , 7, + MinusGammaXGamma5, 8, + GammaXGamma5 , 9, + MinusGammaY , 10, + GammaY , 11, + MinusGammaYGamma5, 12, + GammaYGamma5 , 13, + MinusGammaZ , 14, + GammaZ , 15, + MinusGammaZGamma5, 16, + GammaZGamma5 , 17, + MinusIdentity , 18, + Identity , 19, + MinusSigmaXT , 20, + SigmaXT , 21, + MinusSigmaXY , 22, + SigmaXY , 23, + MinusSigmaXZ , 24, + SigmaXZ , 25, + MinusSigmaYT , 26, + SigmaYT , 27, + MinusSigmaYZ , 28, + SigmaYZ , 29, + MinusSigmaZT , 30, + SigmaZT , 31); + static constexpr unsigned int nGamma = 32; + static const std::array name; + static const std::array, nGamma> mul; + static const std::array adj; + static const std::array gmu; + Algebra g; + public: + Gamma(Algebra initg): g(initg) {} +}; + +template +inline void multMinusGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(0); + ret(1) = -rhs(1); + ret(2) = rhs(2); + ret(3) = rhs(3); +}; + +template +inline void lmultMinusGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(0, i); + ret(1, i) = -rhs(1, i); + ret(2, i) = rhs(2, i); + ret(3, i) = rhs(3, i); + } +}; + +template +inline void rmultMinusGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 0); + ret(i, 1) = -rhs(i, 1); + ret(i, 2) = rhs(i, 2); + ret(i, 3) = rhs(i, 3); + } +}; + +template +inline void multGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(0); + ret(1) = rhs(1); + ret(2) = -rhs(2); + ret(3) = -rhs(3); +}; + +template +inline void lmultGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(0, i); + ret(1, i) = rhs(1, i); + ret(2, i) = -rhs(2, i); + ret(3, i) = -rhs(3, i); + } +}; + +template +inline void rmultGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 0); + ret(i, 1) = rhs(i, 1); + ret(i, 2) = -rhs(i, 2); + ret(i, 3) = -rhs(i, 3); + } +}; + +template +inline void multMinusGammaT(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(2); + ret(1) = -rhs(3); + ret(2) = -rhs(0); + ret(3) = -rhs(1); +}; + +template +inline void lmultMinusGammaT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(2, i); + ret(1, i) = -rhs(3, i); + ret(2, i) = -rhs(0, i); + ret(3, i) = -rhs(1, i); + } +}; + +template +inline void rmultMinusGammaT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 2); + ret(i, 1) = -rhs(i, 3); + ret(i, 2) = -rhs(i, 0); + ret(i, 3) = -rhs(i, 1); + } +}; + +template +inline void multGammaT(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(2); + ret(1) = rhs(3); + ret(2) = rhs(0); + ret(3) = rhs(1); +}; + +template +inline void lmultGammaT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(2, i); + ret(1, i) = rhs(3, i); + ret(2, i) = rhs(0, i); + ret(3, i) = rhs(1, i); + } +}; + +template +inline void rmultGammaT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 2); + ret(i, 1) = rhs(i, 3); + ret(i, 2) = rhs(i, 0); + ret(i, 3) = rhs(i, 1); + } +}; + +template +inline void multMinusGammaTGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(2); + ret(1) = rhs(3); + ret(2) = -rhs(0); + ret(3) = -rhs(1); +}; + +template +inline void lmultMinusGammaTGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(2, i); + ret(1, i) = rhs(3, i); + ret(2, i) = -rhs(0, i); + ret(3, i) = -rhs(1, i); + } +}; + +template +inline void rmultMinusGammaTGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 2); + ret(i, 1) = -rhs(i, 3); + ret(i, 2) = rhs(i, 0); + ret(i, 3) = rhs(i, 1); + } +}; + +template +inline void multGammaTGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(2); + ret(1) = -rhs(3); + ret(2) = rhs(0); + ret(3) = rhs(1); +}; + +template +inline void lmultGammaTGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(2, i); + ret(1, i) = -rhs(3, i); + ret(2, i) = rhs(0, i); + ret(3, i) = rhs(1, i); + } +}; + +template +inline void rmultGammaTGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 2); + ret(i, 1) = rhs(i, 3); + ret(i, 2) = -rhs(i, 0); + ret(i, 3) = -rhs(i, 1); + } +}; + +template +inline void multMinusGammaX(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(3)); + ret(1) = timesMinusI(rhs(2)); + ret(2) = timesI(rhs(1)); + ret(3) = timesI(rhs(0)); +}; + +template +inline void lmultMinusGammaX(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(3, i)); + ret(1, i) = timesMinusI(rhs(2, i)); + ret(2, i) = timesI(rhs(1, i)); + ret(3, i) = timesI(rhs(0, i)); + } +}; + +template +inline void rmultMinusGammaX(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 3)); + ret(i, 1) = timesI(rhs(i, 2)); + ret(i, 2) = timesMinusI(rhs(i, 1)); + ret(i, 3) = timesMinusI(rhs(i, 0)); + } +}; + +template +inline void multGammaX(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(3)); + ret(1) = timesI(rhs(2)); + ret(2) = timesMinusI(rhs(1)); + ret(3) = timesMinusI(rhs(0)); +}; + +template +inline void lmultGammaX(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(3, i)); + ret(1, i) = timesI(rhs(2, i)); + ret(2, i) = timesMinusI(rhs(1, i)); + ret(3, i) = timesMinusI(rhs(0, i)); + } +}; + +template +inline void rmultGammaX(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 3)); + ret(i, 1) = timesMinusI(rhs(i, 2)); + ret(i, 2) = timesI(rhs(i, 1)); + ret(i, 3) = timesI(rhs(i, 0)); + } +}; + +template +inline void multMinusGammaXGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(3)); + ret(1) = timesI(rhs(2)); + ret(2) = timesI(rhs(1)); + ret(3) = timesI(rhs(0)); +}; + +template +inline void lmultMinusGammaXGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(3, i)); + ret(1, i) = timesI(rhs(2, i)); + ret(2, i) = timesI(rhs(1, i)); + ret(3, i) = timesI(rhs(0, i)); + } +}; + +template +inline void rmultMinusGammaXGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 3)); + ret(i, 1) = timesI(rhs(i, 2)); + ret(i, 2) = timesI(rhs(i, 1)); + ret(i, 3) = timesI(rhs(i, 0)); + } +}; + +template +inline void multGammaXGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(3)); + ret(1) = timesMinusI(rhs(2)); + ret(2) = timesMinusI(rhs(1)); + ret(3) = timesMinusI(rhs(0)); +}; + +template +inline void lmultGammaXGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(3, i)); + ret(1, i) = timesMinusI(rhs(2, i)); + ret(2, i) = timesMinusI(rhs(1, i)); + ret(3, i) = timesMinusI(rhs(0, i)); + } +}; + +template +inline void rmultGammaXGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 3)); + ret(i, 1) = timesMinusI(rhs(i, 2)); + ret(i, 2) = timesMinusI(rhs(i, 1)); + ret(i, 3) = timesMinusI(rhs(i, 0)); + } +}; + +template +inline void multMinusGammaY(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(3); + ret(1) = -rhs(2); + ret(2) = -rhs(1); + ret(3) = rhs(0); +}; + +template +inline void lmultMinusGammaY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(3, i); + ret(1, i) = -rhs(2, i); + ret(2, i) = -rhs(1, i); + ret(3, i) = rhs(0, i); + } +}; + +template +inline void rmultMinusGammaY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 3); + ret(i, 1) = -rhs(i, 2); + ret(i, 2) = -rhs(i, 1); + ret(i, 3) = rhs(i, 0); + } +}; + +template +inline void multGammaY(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(3); + ret(1) = rhs(2); + ret(2) = rhs(1); + ret(3) = -rhs(0); +}; + +template +inline void lmultGammaY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(3, i); + ret(1, i) = rhs(2, i); + ret(2, i) = rhs(1, i); + ret(3, i) = -rhs(0, i); + } +}; + +template +inline void rmultGammaY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 3); + ret(i, 1) = rhs(i, 2); + ret(i, 2) = rhs(i, 1); + ret(i, 3) = -rhs(i, 0); + } +}; + +template +inline void multMinusGammaYGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(3); + ret(1) = rhs(2); + ret(2) = -rhs(1); + ret(3) = rhs(0); +}; + +template +inline void lmultMinusGammaYGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(3, i); + ret(1, i) = rhs(2, i); + ret(2, i) = -rhs(1, i); + ret(3, i) = rhs(0, i); + } +}; + +template +inline void rmultMinusGammaYGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 3); + ret(i, 1) = -rhs(i, 2); + ret(i, 2) = rhs(i, 1); + ret(i, 3) = -rhs(i, 0); + } +}; + +template +inline void multGammaYGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(3); + ret(1) = -rhs(2); + ret(2) = rhs(1); + ret(3) = -rhs(0); +}; + +template +inline void lmultGammaYGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(3, i); + ret(1, i) = -rhs(2, i); + ret(2, i) = rhs(1, i); + ret(3, i) = -rhs(0, i); + } +}; + +template +inline void rmultGammaYGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 3); + ret(i, 1) = rhs(i, 2); + ret(i, 2) = -rhs(i, 1); + ret(i, 3) = rhs(i, 0); + } +}; + +template +inline void multMinusGammaZ(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(2)); + ret(1) = timesI(rhs(3)); + ret(2) = timesI(rhs(0)); + ret(3) = timesMinusI(rhs(1)); +}; + +template +inline void lmultMinusGammaZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(2, i)); + ret(1, i) = timesI(rhs(3, i)); + ret(2, i) = timesI(rhs(0, i)); + ret(3, i) = timesMinusI(rhs(1, i)); + } +}; + +template +inline void rmultMinusGammaZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 2)); + ret(i, 1) = timesMinusI(rhs(i, 3)); + ret(i, 2) = timesMinusI(rhs(i, 0)); + ret(i, 3) = timesI(rhs(i, 1)); + } +}; + +template +inline void multGammaZ(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(2)); + ret(1) = timesMinusI(rhs(3)); + ret(2) = timesMinusI(rhs(0)); + ret(3) = timesI(rhs(1)); +}; + +template +inline void lmultGammaZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(2, i)); + ret(1, i) = timesMinusI(rhs(3, i)); + ret(2, i) = timesMinusI(rhs(0, i)); + ret(3, i) = timesI(rhs(1, i)); + } +}; + +template +inline void rmultGammaZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 2)); + ret(i, 1) = timesI(rhs(i, 3)); + ret(i, 2) = timesI(rhs(i, 0)); + ret(i, 3) = timesMinusI(rhs(i, 1)); + } +}; + +template +inline void multMinusGammaZGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(2)); + ret(1) = timesMinusI(rhs(3)); + ret(2) = timesI(rhs(0)); + ret(3) = timesMinusI(rhs(1)); +}; + +template +inline void lmultMinusGammaZGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(2, i)); + ret(1, i) = timesMinusI(rhs(3, i)); + ret(2, i) = timesI(rhs(0, i)); + ret(3, i) = timesMinusI(rhs(1, i)); + } +}; + +template +inline void rmultMinusGammaZGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 2)); + ret(i, 1) = timesMinusI(rhs(i, 3)); + ret(i, 2) = timesI(rhs(i, 0)); + ret(i, 3) = timesMinusI(rhs(i, 1)); + } +}; + +template +inline void multGammaZGamma5(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(2)); + ret(1) = timesI(rhs(3)); + ret(2) = timesMinusI(rhs(0)); + ret(3) = timesI(rhs(1)); +}; + +template +inline void lmultGammaZGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(2, i)); + ret(1, i) = timesI(rhs(3, i)); + ret(2, i) = timesMinusI(rhs(0, i)); + ret(3, i) = timesI(rhs(1, i)); + } +}; + +template +inline void rmultGammaZGamma5(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 2)); + ret(i, 1) = timesI(rhs(i, 3)); + ret(i, 2) = timesMinusI(rhs(i, 0)); + ret(i, 3) = timesI(rhs(i, 1)); + } +}; + +template +inline void multMinusIdentity(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(0); + ret(1) = -rhs(1); + ret(2) = -rhs(2); + ret(3) = -rhs(3); +}; + +template +inline void lmultMinusIdentity(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(0, i); + ret(1, i) = -rhs(1, i); + ret(2, i) = -rhs(2, i); + ret(3, i) = -rhs(3, i); + } +}; + +template +inline void rmultMinusIdentity(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 0); + ret(i, 1) = -rhs(i, 1); + ret(i, 2) = -rhs(i, 2); + ret(i, 3) = -rhs(i, 3); + } +}; + +template +inline void multIdentity(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(0); + ret(1) = rhs(1); + ret(2) = rhs(2); + ret(3) = rhs(3); +}; + +template +inline void lmultIdentity(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(0, i); + ret(1, i) = rhs(1, i); + ret(2, i) = rhs(2, i); + ret(3, i) = rhs(3, i); + } +}; + +template +inline void rmultIdentity(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 0); + ret(i, 1) = rhs(i, 1); + ret(i, 2) = rhs(i, 2); + ret(i, 3) = rhs(i, 3); + } +}; + +template +inline void multMinusSigmaXT(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(1)); + ret(1) = timesMinusI(rhs(0)); + ret(2) = timesI(rhs(3)); + ret(3) = timesI(rhs(2)); +}; + +template +inline void lmultMinusSigmaXT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(1, i)); + ret(1, i) = timesMinusI(rhs(0, i)); + ret(2, i) = timesI(rhs(3, i)); + ret(3, i) = timesI(rhs(2, i)); + } +}; + +template +inline void rmultMinusSigmaXT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 1)); + ret(i, 1) = timesMinusI(rhs(i, 0)); + ret(i, 2) = timesI(rhs(i, 3)); + ret(i, 3) = timesI(rhs(i, 2)); + } +}; + +template +inline void multSigmaXT(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(1)); + ret(1) = timesI(rhs(0)); + ret(2) = timesMinusI(rhs(3)); + ret(3) = timesMinusI(rhs(2)); +}; + +template +inline void lmultSigmaXT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(1, i)); + ret(1, i) = timesI(rhs(0, i)); + ret(2, i) = timesMinusI(rhs(3, i)); + ret(3, i) = timesMinusI(rhs(2, i)); + } +}; + +template +inline void rmultSigmaXT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 1)); + ret(i, 1) = timesI(rhs(i, 0)); + ret(i, 2) = timesMinusI(rhs(i, 3)); + ret(i, 3) = timesMinusI(rhs(i, 2)); + } +}; + +template +inline void multMinusSigmaXY(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(0)); + ret(1) = timesMinusI(rhs(1)); + ret(2) = timesI(rhs(2)); + ret(3) = timesMinusI(rhs(3)); +}; + +template +inline void lmultMinusSigmaXY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(0, i)); + ret(1, i) = timesMinusI(rhs(1, i)); + ret(2, i) = timesI(rhs(2, i)); + ret(3, i) = timesMinusI(rhs(3, i)); + } +}; + +template +inline void rmultMinusSigmaXY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 0)); + ret(i, 1) = timesMinusI(rhs(i, 1)); + ret(i, 2) = timesI(rhs(i, 2)); + ret(i, 3) = timesMinusI(rhs(i, 3)); + } +}; + +template +inline void multSigmaXY(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(0)); + ret(1) = timesI(rhs(1)); + ret(2) = timesMinusI(rhs(2)); + ret(3) = timesI(rhs(3)); +}; + +template +inline void lmultSigmaXY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(0, i)); + ret(1, i) = timesI(rhs(1, i)); + ret(2, i) = timesMinusI(rhs(2, i)); + ret(3, i) = timesI(rhs(3, i)); + } +}; + +template +inline void rmultSigmaXY(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 0)); + ret(i, 1) = timesI(rhs(i, 1)); + ret(i, 2) = timesMinusI(rhs(i, 2)); + ret(i, 3) = timesI(rhs(i, 3)); + } +}; + +template +inline void multMinusSigmaXZ(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(1); + ret(1) = -rhs(0); + ret(2) = rhs(3); + ret(3) = -rhs(2); +}; + +template +inline void lmultMinusSigmaXZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(1, i); + ret(1, i) = -rhs(0, i); + ret(2, i) = rhs(3, i); + ret(3, i) = -rhs(2, i); + } +}; + +template +inline void rmultMinusSigmaXZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 1); + ret(i, 1) = rhs(i, 0); + ret(i, 2) = -rhs(i, 3); + ret(i, 3) = rhs(i, 2); + } +}; + +template +inline void multSigmaXZ(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(1); + ret(1) = rhs(0); + ret(2) = -rhs(3); + ret(3) = rhs(2); +}; + +template +inline void lmultSigmaXZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(1, i); + ret(1, i) = rhs(0, i); + ret(2, i) = -rhs(3, i); + ret(3, i) = rhs(2, i); + } +}; + +template +inline void rmultSigmaXZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 1); + ret(i, 1) = -rhs(i, 0); + ret(i, 2) = rhs(i, 3); + ret(i, 3) = -rhs(i, 2); + } +}; + +template +inline void multMinusSigmaYT(iVector &ret, const iVector &rhs) +{ + ret(0) = rhs(1); + ret(1) = -rhs(0); + ret(2) = -rhs(3); + ret(3) = rhs(2); +}; + +template +inline void lmultMinusSigmaYT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = rhs(1, i); + ret(1, i) = -rhs(0, i); + ret(2, i) = -rhs(3, i); + ret(3, i) = rhs(2, i); + } +}; + +template +inline void rmultMinusSigmaYT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = -rhs(i, 1); + ret(i, 1) = rhs(i, 0); + ret(i, 2) = rhs(i, 3); + ret(i, 3) = -rhs(i, 2); + } +}; + +template +inline void multSigmaYT(iVector &ret, const iVector &rhs) +{ + ret(0) = -rhs(1); + ret(1) = rhs(0); + ret(2) = rhs(3); + ret(3) = -rhs(2); +}; + +template +inline void lmultSigmaYT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = -rhs(1, i); + ret(1, i) = rhs(0, i); + ret(2, i) = rhs(3, i); + ret(3, i) = -rhs(2, i); + } +}; + +template +inline void rmultSigmaYT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = rhs(i, 1); + ret(i, 1) = -rhs(i, 0); + ret(i, 2) = -rhs(i, 3); + ret(i, 3) = rhs(i, 2); + } +}; + +template +inline void multMinusSigmaYZ(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(1)); + ret(1) = timesI(rhs(0)); + ret(2) = timesI(rhs(3)); + ret(3) = timesI(rhs(2)); +}; + +template +inline void lmultMinusSigmaYZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(1, i)); + ret(1, i) = timesI(rhs(0, i)); + ret(2, i) = timesI(rhs(3, i)); + ret(3, i) = timesI(rhs(2, i)); + } +}; + +template +inline void rmultMinusSigmaYZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 1)); + ret(i, 1) = timesI(rhs(i, 0)); + ret(i, 2) = timesI(rhs(i, 3)); + ret(i, 3) = timesI(rhs(i, 2)); + } +}; + +template +inline void multSigmaYZ(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(1)); + ret(1) = timesMinusI(rhs(0)); + ret(2) = timesMinusI(rhs(3)); + ret(3) = timesMinusI(rhs(2)); +}; + +template +inline void lmultSigmaYZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(1, i)); + ret(1, i) = timesMinusI(rhs(0, i)); + ret(2, i) = timesMinusI(rhs(3, i)); + ret(3, i) = timesMinusI(rhs(2, i)); + } +}; + +template +inline void rmultSigmaYZ(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 1)); + ret(i, 1) = timesMinusI(rhs(i, 0)); + ret(i, 2) = timesMinusI(rhs(i, 3)); + ret(i, 3) = timesMinusI(rhs(i, 2)); + } +}; + +template +inline void multMinusSigmaZT(iVector &ret, const iVector &rhs) +{ + ret(0) = timesMinusI(rhs(0)); + ret(1) = timesI(rhs(1)); + ret(2) = timesI(rhs(2)); + ret(3) = timesMinusI(rhs(3)); +}; + +template +inline void lmultMinusSigmaZT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesMinusI(rhs(0, i)); + ret(1, i) = timesI(rhs(1, i)); + ret(2, i) = timesI(rhs(2, i)); + ret(3, i) = timesMinusI(rhs(3, i)); + } +}; + +template +inline void rmultMinusSigmaZT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesMinusI(rhs(i, 0)); + ret(i, 1) = timesI(rhs(i, 1)); + ret(i, 2) = timesI(rhs(i, 2)); + ret(i, 3) = timesMinusI(rhs(i, 3)); + } +}; + +template +inline void multSigmaZT(iVector &ret, const iVector &rhs) +{ + ret(0) = timesI(rhs(0)); + ret(1) = timesMinusI(rhs(1)); + ret(2) = timesMinusI(rhs(2)); + ret(3) = timesI(rhs(3)); +}; + +template +inline void lmultSigmaZT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(0, i) = timesI(rhs(0, i)); + ret(1, i) = timesMinusI(rhs(1, i)); + ret(2, i) = timesMinusI(rhs(2, i)); + ret(3, i) = timesI(rhs(3, i)); + } +}; + +template +inline void rmultSigmaZT(iMatrix &ret, const iMatrix &rhs) +{ + for(unsigned int i = 0; i < Ns; ++i) + { + ret(i, 0) = timesI(rhs(i, 0)); + ret(i, 1) = timesMinusI(rhs(i, 1)); + ret(i, 2) = timesMinusI(rhs(i, 2)); + ret(i, 3) = timesI(rhs(i, 3)); + } +}; + +template +inline auto operator*(const Gamma &G, const iVector &arg) +->typename std::enable_if, SpinorIndex>::value, iVector>::type +{ + iVector ret; + + switch (G.g) + { + case Gamma::Algebra::MinusGamma5: + multMinusGamma5(ret, arg); break; + case Gamma::Algebra::Gamma5: + multGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaT: + multMinusGammaT(ret, arg); break; + case Gamma::Algebra::GammaT: + multGammaT(ret, arg); break; + case Gamma::Algebra::MinusGammaTGamma5: + multMinusGammaTGamma5(ret, arg); break; + case Gamma::Algebra::GammaTGamma5: + multGammaTGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaX: + multMinusGammaX(ret, arg); break; + case Gamma::Algebra::GammaX: + multGammaX(ret, arg); break; + case Gamma::Algebra::MinusGammaXGamma5: + multMinusGammaXGamma5(ret, arg); break; + case Gamma::Algebra::GammaXGamma5: + multGammaXGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaY: + multMinusGammaY(ret, arg); break; + case Gamma::Algebra::GammaY: + multGammaY(ret, arg); break; + case Gamma::Algebra::MinusGammaYGamma5: + multMinusGammaYGamma5(ret, arg); break; + case Gamma::Algebra::GammaYGamma5: + multGammaYGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaZ: + multMinusGammaZ(ret, arg); break; + case Gamma::Algebra::GammaZ: + multGammaZ(ret, arg); break; + case Gamma::Algebra::MinusGammaZGamma5: + multMinusGammaZGamma5(ret, arg); break; + case Gamma::Algebra::GammaZGamma5: + multGammaZGamma5(ret, arg); break; + case Gamma::Algebra::MinusIdentity: + multMinusIdentity(ret, arg); break; + case Gamma::Algebra::Identity: + multIdentity(ret, arg); break; + case Gamma::Algebra::MinusSigmaXT: + multMinusSigmaXT(ret, arg); break; + case Gamma::Algebra::SigmaXT: + multSigmaXT(ret, arg); break; + case Gamma::Algebra::MinusSigmaXY: + multMinusSigmaXY(ret, arg); break; + case Gamma::Algebra::SigmaXY: + multSigmaXY(ret, arg); break; + case Gamma::Algebra::MinusSigmaXZ: + multMinusSigmaXZ(ret, arg); break; + case Gamma::Algebra::SigmaXZ: + multSigmaXZ(ret, arg); break; + case Gamma::Algebra::MinusSigmaYT: + multMinusSigmaYT(ret, arg); break; + case Gamma::Algebra::SigmaYT: + multSigmaYT(ret, arg); break; + case Gamma::Algebra::MinusSigmaYZ: + multMinusSigmaYZ(ret, arg); break; + case Gamma::Algebra::SigmaYZ: + multSigmaYZ(ret, arg); break; + case Gamma::Algebra::MinusSigmaZT: + multMinusSigmaZT(ret, arg); break; + case Gamma::Algebra::SigmaZT: + multSigmaZT(ret, arg); break; + default: assert(0); + } + + return ret; +} + +template +inline auto operator*(const Gamma &G, const iMatrix &arg) +->typename std::enable_if, SpinorIndex>::value, iMatrix>::type +{ + iMatrix ret; + + switch (G.g) + { + case Gamma::Algebra::MinusGamma5: + lmultMinusGamma5(ret, arg); break; + case Gamma::Algebra::Gamma5: + lmultGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaT: + lmultMinusGammaT(ret, arg); break; + case Gamma::Algebra::GammaT: + lmultGammaT(ret, arg); break; + case Gamma::Algebra::MinusGammaTGamma5: + lmultMinusGammaTGamma5(ret, arg); break; + case Gamma::Algebra::GammaTGamma5: + lmultGammaTGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaX: + lmultMinusGammaX(ret, arg); break; + case Gamma::Algebra::GammaX: + lmultGammaX(ret, arg); break; + case Gamma::Algebra::MinusGammaXGamma5: + lmultMinusGammaXGamma5(ret, arg); break; + case Gamma::Algebra::GammaXGamma5: + lmultGammaXGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaY: + lmultMinusGammaY(ret, arg); break; + case Gamma::Algebra::GammaY: + lmultGammaY(ret, arg); break; + case Gamma::Algebra::MinusGammaYGamma5: + lmultMinusGammaYGamma5(ret, arg); break; + case Gamma::Algebra::GammaYGamma5: + lmultGammaYGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaZ: + lmultMinusGammaZ(ret, arg); break; + case Gamma::Algebra::GammaZ: + lmultGammaZ(ret, arg); break; + case Gamma::Algebra::MinusGammaZGamma5: + lmultMinusGammaZGamma5(ret, arg); break; + case Gamma::Algebra::GammaZGamma5: + lmultGammaZGamma5(ret, arg); break; + case Gamma::Algebra::MinusIdentity: + lmultMinusIdentity(ret, arg); break; + case Gamma::Algebra::Identity: + lmultIdentity(ret, arg); break; + case Gamma::Algebra::MinusSigmaXT: + lmultMinusSigmaXT(ret, arg); break; + case Gamma::Algebra::SigmaXT: + lmultSigmaXT(ret, arg); break; + case Gamma::Algebra::MinusSigmaXY: + lmultMinusSigmaXY(ret, arg); break; + case Gamma::Algebra::SigmaXY: + lmultSigmaXY(ret, arg); break; + case Gamma::Algebra::MinusSigmaXZ: + lmultMinusSigmaXZ(ret, arg); break; + case Gamma::Algebra::SigmaXZ: + lmultSigmaXZ(ret, arg); break; + case Gamma::Algebra::MinusSigmaYT: + lmultMinusSigmaYT(ret, arg); break; + case Gamma::Algebra::SigmaYT: + lmultSigmaYT(ret, arg); break; + case Gamma::Algebra::MinusSigmaYZ: + lmultMinusSigmaYZ(ret, arg); break; + case Gamma::Algebra::SigmaYZ: + lmultSigmaYZ(ret, arg); break; + case Gamma::Algebra::MinusSigmaZT: + lmultMinusSigmaZT(ret, arg); break; + case Gamma::Algebra::SigmaZT: + lmultSigmaZT(ret, arg); break; + default: assert(0); + } + + return ret; +} + +template +inline auto operator*(const iMatrix &arg, const Gamma &G) +->typename std::enable_if, SpinorIndex>::value, iMatrix>::type +{ + iMatrix ret; + + switch (G.g) + { + case Gamma::Algebra::MinusGamma5: + rmultMinusGamma5(ret, arg); break; + case Gamma::Algebra::Gamma5: + rmultGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaT: + rmultMinusGammaT(ret, arg); break; + case Gamma::Algebra::GammaT: + rmultGammaT(ret, arg); break; + case Gamma::Algebra::MinusGammaTGamma5: + rmultMinusGammaTGamma5(ret, arg); break; + case Gamma::Algebra::GammaTGamma5: + rmultGammaTGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaX: + rmultMinusGammaX(ret, arg); break; + case Gamma::Algebra::GammaX: + rmultGammaX(ret, arg); break; + case Gamma::Algebra::MinusGammaXGamma5: + rmultMinusGammaXGamma5(ret, arg); break; + case Gamma::Algebra::GammaXGamma5: + rmultGammaXGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaY: + rmultMinusGammaY(ret, arg); break; + case Gamma::Algebra::GammaY: + rmultGammaY(ret, arg); break; + case Gamma::Algebra::MinusGammaYGamma5: + rmultMinusGammaYGamma5(ret, arg); break; + case Gamma::Algebra::GammaYGamma5: + rmultGammaYGamma5(ret, arg); break; + case Gamma::Algebra::MinusGammaZ: + rmultMinusGammaZ(ret, arg); break; + case Gamma::Algebra::GammaZ: + rmultGammaZ(ret, arg); break; + case Gamma::Algebra::MinusGammaZGamma5: + rmultMinusGammaZGamma5(ret, arg); break; + case Gamma::Algebra::GammaZGamma5: + rmultGammaZGamma5(ret, arg); break; + case Gamma::Algebra::MinusIdentity: + rmultMinusIdentity(ret, arg); break; + case Gamma::Algebra::Identity: + rmultIdentity(ret, arg); break; + case Gamma::Algebra::MinusSigmaXT: + rmultMinusSigmaXT(ret, arg); break; + case Gamma::Algebra::SigmaXT: + rmultSigmaXT(ret, arg); break; + case Gamma::Algebra::MinusSigmaXY: + rmultMinusSigmaXY(ret, arg); break; + case Gamma::Algebra::SigmaXY: + rmultSigmaXY(ret, arg); break; + case Gamma::Algebra::MinusSigmaXZ: + rmultMinusSigmaXZ(ret, arg); break; + case Gamma::Algebra::SigmaXZ: + rmultSigmaXZ(ret, arg); break; + case Gamma::Algebra::MinusSigmaYT: + rmultMinusSigmaYT(ret, arg); break; + case Gamma::Algebra::SigmaYT: + rmultSigmaYT(ret, arg); break; + case Gamma::Algebra::MinusSigmaYZ: + rmultMinusSigmaYZ(ret, arg); break; + case Gamma::Algebra::SigmaYZ: + rmultSigmaYZ(ret, arg); break; + case Gamma::Algebra::MinusSigmaZT: + rmultMinusSigmaZT(ret, arg); break; + case Gamma::Algebra::SigmaZT: + rmultSigmaZT(ret, arg); break; + default: assert(0); + } + + return ret; +} + +}} + +#endif // GRID_QCD_GAMMA_H diff --git a/lib/qcd/spin/gamma-gen/gamma-gen.nb b/lib/qcd/spin/gamma-gen/gamma-gen.nb new file mode 100644 index 00000000..b9753df7 --- /dev/null +++ b/lib/qcd/spin/gamma-gen/gamma-gen.nb @@ -0,0 +1,1488 @@ +(* Content-type: application/vnd.wolfram.mathematica *) + +(*** Wolfram Notebook File ***) +(* http://www.wolfram.com/nb *) + +(* CreatedBy='Mathematica 11.0' *) + +(*CacheID: 234*) +(* Internal cache information: +NotebookFileLineBreakTest +NotebookFileLineBreakTest +NotebookDataPosition[ 158, 7] +NotebookDataLength[ 56640, 1480] +NotebookOptionsPosition[ 55061, 1426] +NotebookOutlinePosition[ 55421, 1442] +CellTagsIndexPosition[ 55378, 1439] +WindowFrame->Normal*) + +(* Beginning of Notebook Content *) +Notebook[{ +Cell[TextData[StyleBox["Grid physics library, www.github.com/paboyle/Grid \n\n\ +Source file: lib/qcd/spin/gamma-gen/gamma-gen.nb\n\nCopyright (C) 2015\n\ +Copyright (C) 2016\nCopyright (C) 2017\n\nAuthor: Antonin Portelli \ +\n\nThis program is free software; you can \ +redistribute it and/or modify\nit under the terms of the GNU General Public \ +License as published by\nthe Free Software Foundation; either version 2 of \ +the License, or\n(at your option) any later version.\n\nThis program is \ +distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; \ +without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A \ +PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\n\ +You should have received a copy of the GNU General Public License along\nwith \ +this program; if not, write to the Free Software Foundation, Inc.,\n51 \ +Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nSee the full \ +license in the file \[OpenCurlyDoubleQuote]LICENSE\[CloseCurlyDoubleQuote] in \ +the top level distribution directory", + Background->RGBColor[1, 1, 0.85]]], "Text", + CellChangeTimes->{{3.694192702097444*^9, 3.694192776106186*^9}, { + 3.6942089129622507`*^9, 3.694208916624515*^9}}, + Background->RGBColor[1, 1, 0.85]], + +Cell[CellGroupData[{ + +Cell[BoxData[{ + RowBox[{"ClearAll", "[", "\"\\"", "]"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Unprotect", "[", "\"\\"", "]"}], ";", + RowBox[{"Unprotect", "[", "\"\\"", "]"}], + ";"}], "\[IndentingNewLine]", + RowBox[{"SetDirectory", "[", + RowBox[{"NotebookDirectory", "[", "]"}], "]"}]}], "Input", + CellChangeTimes->{{3.69418610909842*^9, 3.694186122331771*^9}, { + 3.694189694542165*^9, 3.6941897146300087`*^9}, {3.694297413625847*^9, + 3.694297419003489*^9}}], + +Cell[BoxData["\<\"/Users/antonin/Development/Grid/lib/qcd/spin/gamma-gen\"\>"]\ +, "Output", + CellChangeTimes->{{3.694189715067813*^9, 3.694189718130962*^9}, { + 3.694207343654113*^9, 3.694207368715312*^9}, 3.694208353902673*^9, + 3.694208422714191*^9, 3.694208720092059*^9, 3.694208887255764*^9, + 3.6942115023319197`*^9, 3.694211674672401*^9, 3.694211769773765*^9, + 3.694212832251072*^9, 3.694212924703574*^9, 3.694213477890645*^9, + 3.694214215876555*^9, 3.694214744582322*^9, 3.694214868607993*^9, { + 3.694214930774279*^9, 3.694214956189962*^9}, 3.69421520097348*^9, + 3.6942153028002653`*^9, 3.694215388363636*^9, 3.694215531793765*^9, + 3.694293467607703*^9, 3.694294096138891*^9, 3.694297419616928*^9, + 3.694297655191285*^9, 3.69429782738804*^9, 3.694297901657515*^9, + 3.6942984168973837`*^9, 3.6948949168128557`*^9, 3.69489495942482*^9, + 3.6949627104409447`*^9, {3.694962842273374*^9, 3.6949628507953672`*^9}, + 3.694963445768766*^9, 3.6949643976358423`*^9, {3.694964715764683*^9, + 3.6949647261937733`*^9}, 3.6949650592533703`*^9, 3.694965165070952*^9}] +}, Open ]], + +Cell[CellGroupData[{ + +Cell["Clifford algebra generation", "Section", + CellChangeTimes->{{3.6942089434583883`*^9, 3.694208978559093*^9}}], + +Cell[BoxData[{ + RowBox[{ + RowBox[{"com", "[", + RowBox[{"a_", ",", "b_"}], "]"}], ":=", + RowBox[{ + RowBox[{"a", ".", "b"}], "-", + RowBox[{"b", ".", "a"}]}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"acom", "[", + RowBox[{"a_", ",", "b_"}], "]"}], ":=", + RowBox[{ + RowBox[{"a", ".", "b"}], "+", + RowBox[{"b", ".", "a"}]}]}]}], "Input", + CellChangeTimes->{{3.694184330267939*^9, 3.694184337479828*^9}, { + 3.694184821238667*^9, 3.6941848260602217`*^9}}], + +Cell["Definition of the matrix representation of the algebra:", "Text", + CellChangeTimes->{{3.6942090405172586`*^9, 3.694209073962101*^9}, { + 3.6942974330697393`*^9, 3.694297433821431*^9}}], + +Cell[BoxData[{ + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "id", "]"}], "=", + RowBox[{"IdentityMatrix", "[", "4", "]"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "gx", "]"}], "=", + RowBox[{"(", GridBox[{ + {"0", "0", "0", "\[ImaginaryI]"}, + {"0", "0", "\[ImaginaryI]", "0"}, + {"0", + RowBox[{"-", "\[ImaginaryI]"}], "0", "0"}, + { + RowBox[{"-", "\[ImaginaryI]"}], "0", "0", "0"} + }], ")"}]}], ";", + RowBox[{ + RowBox[{"mat", "[", "gy", "]"}], "=", + RowBox[{"(", GridBox[{ + {"0", "0", "0", + RowBox[{"-", "1"}]}, + {"0", "0", "1", "0"}, + {"0", "1", "0", "0"}, + { + RowBox[{"-", "1"}], "0", "0", "0"} + }], ")"}]}], ";", + RowBox[{ + RowBox[{"mat", "[", "gz", "]"}], "=", + RowBox[{"(", GridBox[{ + {"0", "0", "\[ImaginaryI]", "0"}, + {"0", "0", "0", + RowBox[{"-", "\[ImaginaryI]"}]}, + { + RowBox[{"-", "\[ImaginaryI]"}], "0", "0", "0"}, + {"0", "\[ImaginaryI]", "0", "0"} + }], ")"}]}], ";", + RowBox[{ + RowBox[{"mat", "[", "gt", "]"}], "=", + RowBox[{"(", GridBox[{ + {"0", "0", "1", "0"}, + {"0", "0", "0", "1"}, + {"1", "0", "0", "0"}, + {"0", "1", "0", "0"} + }], ")"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "g5", "]"}], "=", + RowBox[{ + RowBox[{"mat", "[", "gx", "]"}], ".", + RowBox[{"mat", "[", "gy", "]"}], ".", + RowBox[{"mat", "[", "gz", "]"}], ".", + RowBox[{"mat", "[", "gt", "]"}]}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "gx5", "]"}], "=", + RowBox[{ + RowBox[{"mat", "[", "gx", "]"}], ".", + RowBox[{"mat", "[", "g5", "]"}]}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "gy5", "]"}], "=", + RowBox[{ + RowBox[{"mat", "[", "gy", "]"}], ".", + RowBox[{"mat", "[", "g5", "]"}]}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "gz5", "]"}], "=", + RowBox[{ + RowBox[{"mat", "[", "gz", "]"}], ".", + RowBox[{"mat", "[", "g5", "]"}]}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "gt5", "]"}], "=", + RowBox[{ + RowBox[{"mat", "[", "gt", "]"}], ".", + RowBox[{"mat", "[", "g5", "]"}]}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "\[Sigma]xy", "]"}], "=", + RowBox[{ + RowBox[{"com", "[", + RowBox[{ + RowBox[{"mat", "[", "gx", "]"}], ",", + RowBox[{"mat", "[", "gy", "]"}]}], "]"}], "/", "2"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "\[Sigma]xz", "]"}], "=", + RowBox[{ + RowBox[{"com", "[", + RowBox[{ + RowBox[{"mat", "[", "gx", "]"}], ",", + RowBox[{"mat", "[", "gz", "]"}]}], "]"}], "/", "2"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "\[Sigma]xt", "]"}], "=", + RowBox[{ + RowBox[{"com", "[", + RowBox[{ + RowBox[{"mat", "[", "gx", "]"}], ",", + RowBox[{"mat", "[", "gt", "]"}]}], "]"}], "/", "2"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "\[Sigma]yz", "]"}], "=", + RowBox[{ + RowBox[{"com", "[", + RowBox[{ + RowBox[{"mat", "[", "gy", "]"}], ",", + RowBox[{"mat", "[", "gz", "]"}]}], "]"}], "/", "2"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "\[Sigma]yt", "]"}], "=", + RowBox[{ + RowBox[{"com", "[", + RowBox[{ + RowBox[{"mat", "[", "gy", "]"}], ",", + RowBox[{"mat", "[", "gt", "]"}]}], "]"}], "/", "2"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "\[Sigma]zt", "]"}], "=", + RowBox[{ + RowBox[{"com", "[", + RowBox[{ + RowBox[{"mat", "[", "gz", "]"}], ",", + RowBox[{"mat", "[", "gt", "]"}]}], "]"}], "/", "2"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"palg", "=", + RowBox[{"{", + RowBox[{ + "id", ",", "gx", ",", "gy", ",", "gz", ",", "gt", ",", "g5", ",", "gx5", + ",", "gy5", ",", "gz5", ",", "gt5", ",", "\[Sigma]xy", ",", "\[Sigma]xz", + ",", "\[Sigma]xt", ",", "\[Sigma]yz", ",", "\[Sigma]yt", ",", + "\[Sigma]zt"}], "}"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"malg", "=", + RowBox[{"Table", "[", + RowBox[{ + RowBox[{"-", "i"}], ",", + RowBox[{"{", + RowBox[{"i", ",", "palg"}], "}"}]}], "]"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"alg", "=", + RowBox[{"Union", "[", + RowBox[{"palg", ",", "malg"}], "]"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", + RowBox[{"-", "i"}], "]"}], "=", + RowBox[{"-", + RowBox[{"mat", "[", "i", "]"}]}]}], ",", + RowBox[{"{", + RowBox[{"i", ",", "palg"}], "}"}]}], "]"}]}], "Input", + CellChangeTimes->{{3.694182703426999*^9, 3.694182706401226*^9}, { + 3.6941838790187283`*^9, 3.694184129323387*^9}, {3.694184186220387*^9, + 3.6941842073992023`*^9}, {3.694184241024517*^9, 3.6941843050620823`*^9}, { + 3.694184341303878*^9, 3.694184431096826*^9}, {3.694184469241919*^9, + 3.694184532366125*^9}, {3.694184830238468*^9, 3.694184950533866*^9}, { + 3.694185044355978*^9, 3.694185099415689*^9}, {3.694185502749824*^9, + 3.694185675128971*^9}, {3.694185728773429*^9, 3.694185729056695*^9}, + 3.694185780274218*^9, 3.6941858224264593`*^9, {3.694185941282981*^9, + 3.694185950262871*^9}}], + +Cell["Generation of the abstract algebra:", "Text", + CellChangeTimes->{{3.6942090658330803`*^9, 3.694209076132119*^9}}], + +Cell[BoxData[{ + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"Dot", "[", + RowBox[{"i1", ",", "i2"}], "]"}], "=", + RowBox[{ + RowBox[{"Select", "[", + RowBox[{"alg", ",", + RowBox[{ + RowBox[{ + RowBox[{ + RowBox[{"mat", "[", "i1", "]"}], ".", + RowBox[{"mat", "[", "i2", "]"}]}], "\[Equal]", + RowBox[{"mat", "[", "#", "]"}]}], "&"}]}], "]"}], "[", + RowBox[{"[", "1", "]"}], "]"}]}], ",", + RowBox[{"{", + RowBox[{"i1", ",", "palg"}], "}"}], ",", + RowBox[{"{", + RowBox[{"i2", ",", "palg"}], "}"}]}], "]"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"Dot", "[", + RowBox[{ + RowBox[{"-", "i1_"}], ",", "i2_"}], "]"}], ":=", + RowBox[{"-", + RowBox[{"i1", ".", "i2"}]}]}], ";", + RowBox[{ + RowBox[{"Dot", "[", + RowBox[{"i1_", ",", + RowBox[{"-", "i2_"}]}], "]"}], ":=", + RowBox[{"-", + RowBox[{"i1", ".", "i2"}]}]}], ";", + RowBox[{ + RowBox[{"Dot", "[", + RowBox[{ + RowBox[{"-", "i1_"}], ",", + RowBox[{"-", "i2_"}]}], "]"}], ":=", + RowBox[{"i1", ".", "i2"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"ConjugateTranspose", "[", "i", "]"}], "=", + RowBox[{ + RowBox[{"Select", "[", + RowBox[{"alg", ",", + RowBox[{ + RowBox[{ + RowBox[{"ConjugateTranspose", "[", + RowBox[{"mat", "[", "i", "]"}], "]"}], "\[Equal]", + RowBox[{"mat", "[", "#", "]"}]}], "&"}]}], "]"}], "[", + RowBox[{"[", "1", "]"}], "]"}]}], ",", + RowBox[{"{", + RowBox[{"i", ",", "palg"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"ConjugateTranspose", "[", + RowBox[{"-", "i_"}], "]"}], ":=", + RowBox[{"-", + RowBox[{"ConjugateTranspose", "[", "i", "]"}]}]}]}], "Input", + CellChangeTimes->{{3.6941860329437103`*^9, 3.6941860343133917`*^9}, { + 3.694186163571176*^9, 3.6941862016761427`*^9}, {3.69418700219066*^9, + 3.6941870425469627`*^9}, {3.694297326197534*^9, 3.6942974062629423`*^9}, { + 3.694297634175386*^9, 3.6942976496897383`*^9}}], + +Cell["Check that we can reconstruct the Euclidean metric:", "Text", + CellChangeTimes->{{3.694209080190936*^9, 3.694209096585559*^9}}], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{ + RowBox[{"Table", "[", + RowBox[{ + RowBox[{ + RowBox[{"acom", "[", + RowBox[{"i1", ",", "i2"}], "]"}], "/", "2"}], ",", + RowBox[{"{", + RowBox[{"i1", ",", + RowBox[{"{", + RowBox[{"gx", ",", "gy", ",", "gz", ",", "gt"}], "}"}]}], "}"}], ",", + RowBox[{"{", + RowBox[{"i2", ",", + RowBox[{"{", + RowBox[{"gx", ",", "gy", ",", "gz", ",", "gt"}], "}"}]}], "}"}]}], + "]"}], "//", "MatrixForm"}]], "Input"], + +Cell[BoxData[ + TagBox[ + RowBox[{"(", "\[NoBreak]", GridBox[{ + {"id", "0", "0", "0"}, + {"0", "id", "0", "0"}, + {"0", "0", "id", "0"}, + {"0", "0", "0", "id"} + }, + GridBoxAlignment->{ + "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, + "RowsIndexed" -> {}}, + GridBoxSpacings->{"Columns" -> { + Offset[0.27999999999999997`], { + Offset[0.7]}, + Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { + Offset[0.2], { + Offset[0.4]}, + Offset[0.2]}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}], + Function[BoxForm`e$, + MatrixForm[BoxForm`e$]]]], "Output", + CellChangeTimes->{ + 3.694186559657666*^9, 3.6941870440388947`*^9, 3.694189718434745*^9, { + 3.694207344033985*^9, 3.694207369106125*^9}, 3.694208354345052*^9, + 3.694208423089445*^9, 3.6942087204812307`*^9, 3.6942088876269073`*^9, + 3.694211502659554*^9, 3.6942116750282307`*^9, 3.694211770126875*^9, + 3.6942128326290417`*^9, 3.6942129251958523`*^9, 3.694213478493619*^9, + 3.694214216283064*^9, 3.694214744924881*^9, 3.694214869005068*^9, { + 3.694214931160738*^9, 3.6942149565175247`*^9}, 3.69421520140513*^9, + 3.694215303184371*^9, 3.694215388782826*^9, 3.694215532274271*^9, + 3.694293468120837*^9, 3.69429409699356*^9, 3.694297655587861*^9, + 3.694297827778974*^9, 3.694297902050129*^9, 3.694298417447421*^9, + 3.694894917294997*^9, 3.6948949597758904`*^9, 3.6949627108824663`*^9, + 3.694962851174364*^9, 3.6949634461305313`*^9, 3.694964397971891*^9, { + 3.6949647161810303`*^9, 3.6949647264866943`*^9}, 3.6949650598407507`*^9, + 3.694965165456048*^9}] +}, Open ]], + +Cell["Full multiplication table:", "Text", + CellChangeTimes->{{3.694209113187169*^9, 3.6942091210767593`*^9}}], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{ + RowBox[{"Table", "[", + RowBox[{ + RowBox[{"i1", ".", "i2"}], ",", + RowBox[{"{", + RowBox[{"i1", ",", "palg"}], "}"}], ",", + RowBox[{"{", + RowBox[{"i2", ",", "palg"}], "}"}]}], "]"}], "//", + "MatrixForm"}]], "Input", + CellChangeTimes->{{3.6941862426584797`*^9, 3.694186256858178*^9}, { + 3.694186605271886*^9, 3.694186617894228*^9}, {3.694186972131384*^9, + 3.69418697419895*^9}, {3.694192885918524*^9, 3.694192888888296*^9}}], + +Cell[BoxData[ + TagBox[ + RowBox[{"(", "\[NoBreak]", GridBox[{ + {"id", "gx", "gy", "gz", "gt", "g5", "gx5", "gy5", "gz5", "gt5", + "\[Sigma]xy", "\[Sigma]xz", "\[Sigma]xt", "\[Sigma]yz", "\[Sigma]yt", + "\[Sigma]zt"}, + {"gx", "id", "\[Sigma]xy", "\[Sigma]xz", "\[Sigma]xt", "gx5", "g5", + RowBox[{"-", "\[Sigma]zt"}], "\[Sigma]yt", + RowBox[{"-", "\[Sigma]yz"}], "gy", "gz", "gt", + RowBox[{"-", "gt5"}], "gz5", + RowBox[{"-", "gy5"}]}, + {"gy", + RowBox[{"-", "\[Sigma]xy"}], "id", "\[Sigma]yz", "\[Sigma]yt", "gy5", + "\[Sigma]zt", "g5", + RowBox[{"-", "\[Sigma]xt"}], "\[Sigma]xz", + RowBox[{"-", "gx"}], "gt5", + RowBox[{"-", "gz5"}], "gz", "gt", "gx5"}, + {"gz", + RowBox[{"-", "\[Sigma]xz"}], + RowBox[{"-", "\[Sigma]yz"}], "id", "\[Sigma]zt", "gz5", + RowBox[{"-", "\[Sigma]yt"}], "\[Sigma]xt", "g5", + RowBox[{"-", "\[Sigma]xy"}], + RowBox[{"-", "gt5"}], + RowBox[{"-", "gx"}], "gy5", + RowBox[{"-", "gy"}], + RowBox[{"-", "gx5"}], "gt"}, + {"gt", + RowBox[{"-", "\[Sigma]xt"}], + RowBox[{"-", "\[Sigma]yt"}], + RowBox[{"-", "\[Sigma]zt"}], "id", "gt5", "\[Sigma]yz", + RowBox[{"-", "\[Sigma]xz"}], "\[Sigma]xy", "g5", "gz5", + RowBox[{"-", "gy5"}], + RowBox[{"-", "gx"}], "gx5", + RowBox[{"-", "gy"}], + RowBox[{"-", "gz"}]}, + {"g5", + RowBox[{"-", "gx5"}], + RowBox[{"-", "gy5"}], + RowBox[{"-", "gz5"}], + RowBox[{"-", "gt5"}], "id", + RowBox[{"-", "gx"}], + RowBox[{"-", "gy"}], + RowBox[{"-", "gz"}], + RowBox[{"-", "gt"}], + RowBox[{"-", "\[Sigma]zt"}], "\[Sigma]yt", + RowBox[{"-", "\[Sigma]yz"}], + RowBox[{"-", "\[Sigma]xt"}], "\[Sigma]xz", + RowBox[{"-", "\[Sigma]xy"}]}, + {"gx5", + RowBox[{"-", "g5"}], "\[Sigma]zt", + RowBox[{"-", "\[Sigma]yt"}], "\[Sigma]yz", "gx", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]xy"}], + RowBox[{"-", "\[Sigma]xz"}], + RowBox[{"-", "\[Sigma]xt"}], "gy5", "gz5", "gt5", + RowBox[{"-", "gt"}], "gz", + RowBox[{"-", "gy"}]}, + {"gy5", + RowBox[{"-", "\[Sigma]zt"}], + RowBox[{"-", "g5"}], "\[Sigma]xt", + RowBox[{"-", "\[Sigma]xz"}], "gy", "\[Sigma]xy", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]yz"}], + RowBox[{"-", "\[Sigma]yt"}], + RowBox[{"-", "gx5"}], "gt", + RowBox[{"-", "gz"}], "gz5", "gt5", "gx"}, + {"gz5", "\[Sigma]yt", + RowBox[{"-", "\[Sigma]xt"}], + RowBox[{"-", "g5"}], "\[Sigma]xy", "gz", "\[Sigma]xz", "\[Sigma]yz", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]zt"}], + RowBox[{"-", "gt"}], + RowBox[{"-", "gx5"}], "gy", + RowBox[{"-", "gy5"}], + RowBox[{"-", "gx"}], "gt5"}, + {"gt5", + RowBox[{"-", "\[Sigma]yz"}], "\[Sigma]xz", + RowBox[{"-", "\[Sigma]xy"}], + RowBox[{"-", "g5"}], "gt", "\[Sigma]xt", "\[Sigma]yt", "\[Sigma]zt", + RowBox[{"-", "id"}], "gz", + RowBox[{"-", "gy"}], + RowBox[{"-", "gx5"}], "gx", + RowBox[{"-", "gy5"}], + RowBox[{"-", "gz5"}]}, + {"\[Sigma]xy", + RowBox[{"-", "gy"}], "gx", + RowBox[{"-", "gt5"}], "gz5", + RowBox[{"-", "\[Sigma]zt"}], + RowBox[{"-", "gy5"}], "gx5", + RowBox[{"-", "gt"}], "gz", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]yz"}], + RowBox[{"-", "\[Sigma]yt"}], "\[Sigma]xz", "\[Sigma]xt", "g5"}, + {"\[Sigma]xz", + RowBox[{"-", "gz"}], "gt5", "gx", + RowBox[{"-", "gy5"}], "\[Sigma]yt", + RowBox[{"-", "gz5"}], "gt", "gx5", + RowBox[{"-", "gy"}], "\[Sigma]yz", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]zt"}], + RowBox[{"-", "\[Sigma]xy"}], + RowBox[{"-", "g5"}], "\[Sigma]xt"}, + {"\[Sigma]xt", + RowBox[{"-", "gt"}], + RowBox[{"-", "gz5"}], "gy5", "gx", + RowBox[{"-", "\[Sigma]yz"}], + RowBox[{"-", "gt5"}], + RowBox[{"-", "gz"}], "gy", "gx5", "\[Sigma]yt", "\[Sigma]zt", + RowBox[{"-", "id"}], "g5", + RowBox[{"-", "\[Sigma]xy"}], + RowBox[{"-", "\[Sigma]xz"}]}, + {"\[Sigma]yz", + RowBox[{"-", "gt5"}], + RowBox[{"-", "gz"}], "gy", "gx5", + RowBox[{"-", "\[Sigma]xt"}], + RowBox[{"-", "gt"}], + RowBox[{"-", "gz5"}], "gy5", "gx", + RowBox[{"-", "\[Sigma]xz"}], "\[Sigma]xy", "g5", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]zt"}], "\[Sigma]yt"}, + {"\[Sigma]yt", "gz5", + RowBox[{"-", "gt"}], + RowBox[{"-", "gx5"}], "gy", "\[Sigma]xz", "gz", + RowBox[{"-", "gt5"}], + RowBox[{"-", "gx"}], "gy5", + RowBox[{"-", "\[Sigma]xt"}], + RowBox[{"-", "g5"}], "\[Sigma]xy", "\[Sigma]zt", + RowBox[{"-", "id"}], + RowBox[{"-", "\[Sigma]yz"}]}, + {"\[Sigma]zt", + RowBox[{"-", "gy5"}], "gx5", + RowBox[{"-", "gt"}], "gz", + RowBox[{"-", "\[Sigma]xy"}], + RowBox[{"-", "gy"}], "gx", + RowBox[{"-", "gt5"}], "gz5", "g5", + RowBox[{"-", "\[Sigma]xt"}], "\[Sigma]xz", + RowBox[{"-", "\[Sigma]yt"}], "\[Sigma]yz", + RowBox[{"-", "id"}]} + }, + GridBoxAlignment->{ + "Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Baseline}}, + "RowsIndexed" -> {}}, + GridBoxSpacings->{"Columns" -> { + Offset[0.27999999999999997`], { + Offset[0.7]}, + Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> { + Offset[0.2], { + Offset[0.4]}, + Offset[0.2]}, "RowsIndexed" -> {}}], "\[NoBreak]", ")"}], + Function[BoxForm`e$, + MatrixForm[BoxForm`e$]]]], "Output", + CellChangeTimes->{{3.694186251703266*^9, 3.6941862573246403`*^9}, { + 3.69418660949746*^9, 3.694186618329227*^9}, 3.6941869746472473`*^9, + 3.694187045160287*^9, 3.69418971854458*^9, 3.694192889450261*^9, { + 3.694207344114737*^9, 3.694207369223531*^9}, 3.694208354449048*^9, + 3.694208423183125*^9, 3.6942087205954943`*^9, 3.694208887707542*^9, + 3.694211502726407*^9, 3.694211675104418*^9, 3.694211770202587*^9, + 3.694212832700527*^9, 3.69421292529856*^9, 3.694213478604137*^9, + 3.694214216368701*^9, 3.694214744992138*^9, 3.694214869090289*^9, { + 3.694214931237383*^9, 3.6942149565897913`*^9}, 3.6942152015279818`*^9, + 3.694215303248364*^9, 3.694215388866436*^9, 3.694215532359406*^9, + 3.694293468220346*^9, 3.694294097121203*^9, 3.694297655690278*^9, + 3.694297827858612*^9, 3.694297902125073*^9, 3.694298417530912*^9, + 3.694894917375866*^9, 3.694894959839177*^9, 3.694962710968522*^9, + 3.6949628512863817`*^9, 3.694963446206002*^9, 3.694964398046623*^9, { + 3.6949647162797327`*^9, 3.694964726526013*^9}, 3.6949650599380713`*^9, + 3.694965165531089*^9}] +}, Open ]] +}, Open ]], + +Cell[CellGroupData[{ + +Cell["Header file Gamma.h generation", "Section", + CellChangeTimes->{{3.694208986784461*^9, 3.6942090005062523`*^9}, { + 3.694965123390101*^9, 3.694965123950851*^9}}], + +Cell["File skeleton:", "Text", + CellFrame->{{0, 0}, {0, 0.5}}, + CellChangeTimes->{{3.694209131604498*^9, 3.694209133792495*^9}}], + +Cell[BoxData[ + RowBox[{ + RowBox[{"makeHeaderCode", "[", + RowBox[{"enumCode_", ",", "funcCode_"}], "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", " ", "=", " ", + RowBox[{ + "out", "<>", "\[IndentingNewLine]", + "\"\<#ifndef GRID_QCD_GAMMA_H\n#define GRID_QCD_GAMMA_H\n\n// code \ +generated by the Mathematica notebook gamma-gen/gamma-gen.nb\n\n#include \ +\n\nnamespace Grid {\nnamespace QCD {\n\nclass Gamma {\n public:\n\ +\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"out", " ", "=", " ", + RowBox[{"out", "<>", "enumCode"}]}], ";", "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{ + "out", "<>", + "\"\< static const std::array \ +name;\n static const std::array, nGamma> mul;\n\ + static const std::array adj;\n \ +static const std::array gmu;\n \ +Algebra g;\n public:\n \ + Gamma(Algebra initg): g(initg) {} \n};\n\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "funcCode"}]}], ";", "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\<\n}}\n\n#endif // GRID_QCD_GAMMA_H\n\>\""}]}], + ";", "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}]], "Input", + CellChangeTimes->{{3.69419645529875*^9, 3.694196727399803*^9}, { + 3.694196786125751*^9, 3.694196882528638*^9}, {3.694197240621915*^9, + 3.694197350313327*^9}, {3.694206801774742*^9, 3.6942068152492313`*^9}, { + 3.694206953106125*^9, 3.694206955712624*^9}, 3.694207329784376*^9, { + 3.694207361301278*^9, 3.694207363264554*^9}, {3.694207717624036*^9, + 3.694207756242198*^9}, {3.694208382782*^9, 3.694208417198256*^9}, { + 3.694208503080744*^9, 3.6942086978552227`*^9}, {3.6942113930386953`*^9, + 3.694211409741232*^9}, {3.6942115367346992`*^9, 3.694211695577471*^9}, { + 3.694211732616888*^9, 3.69421173594759*^9}, {3.694212824802087*^9, + 3.69421282832565*^9}, {3.69421325181595*^9, 3.6942133005791903`*^9}, { + 3.694214209845763*^9, 3.6942142108217773`*^9}, {3.694214621189205*^9, + 3.694214647829077*^9}, {3.694214730808668*^9, 3.6942148593149223`*^9}, { + 3.694214900404429*^9, 3.694214905595294*^9}, {3.6942155281289682`*^9, + 3.6942155289376802`*^9}, {3.694297793776082*^9, 3.694297819122456*^9}, { + 3.694297854809973*^9, 3.694297889420939*^9}, {3.694963324045937*^9, + 3.694963343265525*^9}, {3.694964367519239*^9, 3.69496439461199*^9}, { + 3.694964462130747*^9, 3.6949644669959793`*^9}, 3.694964509762739*^9, { + 3.694964705045744*^9, 3.694964723148797*^9}, {3.694964992988984*^9, + 3.6949649968504257`*^9}}], + +Cell["Gamma enum generation:", "Text", + CellFrame->{{0, 0}, {0, 0.5}}, + CellChangeTimes->{{3.694209168488991*^9, 3.6942091715073423`*^9}, + 3.694209215969149*^9}], + +Cell[BoxData[{ + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "id", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gx", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gy", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gz", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gt", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "g5", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gx5", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gy5", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gz5", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "gt5", "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "\[Sigma]xy", "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "\[Sigma]xz", "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "\[Sigma]xt", "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "\[Sigma]yz", "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "\[Sigma]yt", "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", "\[Sigma]zt", "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "id"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gx"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gy"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gz"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gt"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "g5"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gx5"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gy5"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gz5"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "gt5"}], "]"}], "=", "\"\\""}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "\[Sigma]xy"}], "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "\[Sigma]xz"}], "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "\[Sigma]xt"}], "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "\[Sigma]yz"}], "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "\[Sigma]yt"}], "]"}], "=", + "\"\\""}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"enum", "[", + RowBox[{"-", "\[Sigma]zt"}], "]"}], "=", + "\"\\""}], ";"}]}], "Input", + CellChangeTimes->{{3.69418665896658*^9, 3.6941867305497723`*^9}, { + 3.694186782865391*^9, 3.694186840513199*^9}, {3.694186889568404*^9, + 3.694186968177154*^9}, {3.6941870767730503`*^9, 3.69418716300373*^9}, { + 3.694213209628356*^9, 3.6942132459364033`*^9}}], + +Cell[BoxData[ + RowBox[{ + RowBox[{"makeEnumCode", "[", "indent_", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", "out", "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{ + "indent", "<>", "\"\\""}]}], + ";", "\[IndentingNewLine]", + RowBox[{"ind", "=", "0"}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"out", "=", + RowBox[{ + "out", "<>", "\"\<\\n\>\"", "<>", "indent", "<>", " ", + "\"\< \>\"", "<>", + RowBox[{"StringPadRight", "[", + RowBox[{ + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "i", "]"}], ",", "\"\\""}], + "]"}], ",", "17"}], "]"}], "<>", "\"\<, \>\"", "<>", + RowBox[{"ToString", "[", "ind", "]"}]}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", " ", "=", " ", + RowBox[{"out", "<>", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"i", "\[Equal]", + RowBox[{"Last", "[", "alg", "]"}]}], ",", + RowBox[{ + "\"\<);\\n\>\"", "<>", "indent", "<>", + "\"\\"", "<>", + RowBox[{"ToString", "[", + RowBox[{"ind", "+", "1"}], "]"}], "<>", "\"\<;\\n\>\""}], ",", + "\"\<,\>\"", ",", "\"\<,\>\""}], "]"}]}]}], ";", + "\[IndentingNewLine]", + RowBox[{"ind", "=", + RowBox[{"ind", "+", "1"}]}]}], ",", "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"i", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}]], "Input", + CellChangeTimes->{{3.694187393082726*^9, 3.694187405147518*^9}, { + 3.694187542837305*^9, 3.694187612925947*^9}, {3.694187643751446*^9, + 3.694187659177355*^9}, {3.69418773039787*^9, 3.694187848150207*^9}, { + 3.6941879877586403`*^9, 3.6941880928686857`*^9}, {3.694188156471807*^9, + 3.694188204997113*^9}, {3.694188290260517*^9, 3.694188291135356*^9}, { + 3.6941933492591*^9, 3.6941934762397633`*^9}, {3.694206335439877*^9, + 3.694206371730096*^9}, {3.694206667692852*^9, 3.6942066758217916`*^9}, { + 3.694206752732321*^9, 3.694206753090602*^9}, {3.6942071072527027`*^9, + 3.694207214318696*^9}, {3.694211442308366*^9, 3.694211490100521*^9}, { + 3.6942115668101377`*^9, 3.694211571070611*^9}, {3.6942133172135267`*^9, + 3.694213325783718*^9}}], + +Cell["Multiplication functions generation:", "Text", + CellFrame->{{0, 0}, {0, 0.5}}, + CellChangeTimes->{{3.69420919761381*^9, 3.694209206431526*^9}}], + +Cell[BoxData[{ + RowBox[{ + RowBox[{"rhsv", "=", + RowBox[{"{", + RowBox[{ + RowBox[{"rhs", "[", "0", "]"}], ",", + RowBox[{"rhs", "[", "1", "]"}], ",", + RowBox[{"rhs", "[", "2", "]"}], ",", + RowBox[{"rhs", "[", "3", "]"}]}], "}"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"vecCoef", "[", + RowBox[{"v_", "[", "i_", "]"}], "]"}], ":=", + RowBox[{ + RowBox[{"ToString", "[", "v", "]"}], "<>", "\"\<(\>\"", "<>", + RowBox[{"ToString", "[", "i", "]"}], "<>", + "\"\<)\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"lmatCoef", "[", + RowBox[{"v_", "[", "i_", "]"}], "]"}], ":=", + RowBox[{ + RowBox[{"ToString", "[", "v", "]"}], "<>", "\"\<(\>\"", "<>", + RowBox[{"ToString", "[", "i", "]"}], "<>", + "\"\<, i)\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"rmatCoef", "[", + RowBox[{"v_", "[", "i_", "]"}], "]"}], ":=", + RowBox[{ + RowBox[{"ToString", "[", "v", "]"}], "<>", "\"\<(i, \>\"", "<>", + RowBox[{"ToString", "[", "i", "]"}], "<>", + "\"\<)\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"expr", "[", + RowBox[{"ir_", ",", + RowBox[{"rhs", "[", "i_", "]"}], ",", "strFn_"}], "]"}], ":=", + RowBox[{ + RowBox[{"strFn", "[", + RowBox[{"ret", "[", "ir", "]"}], "]"}], "<>", "\"\< = \>\"", "<>", " ", + RowBox[{"strFn", "[", + RowBox[{"rhs", "[", "i", "]"}], "]"}], "<>", + "\"\<;\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"expr", "[", + RowBox[{"ir_", ",", + RowBox[{"Times", "[", + RowBox[{ + RowBox[{"-", "1"}], ",", + RowBox[{"rhs", "[", "i_", "]"}]}], "]"}], ",", "strFn_"}], "]"}], ":=", + + RowBox[{ + RowBox[{"strFn", "[", + RowBox[{"ret", "[", "ir", "]"}], "]"}], "<>", "\"\< = -\>\"", "<>", " ", + RowBox[{"strFn", "[", + RowBox[{"rhs", "[", "i", "]"}], "]"}], "<>", + "\"\<;\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"expr", "[", + RowBox[{"ir_", ",", + RowBox[{"Times", "[", + RowBox[{ + RowBox[{"Complex", " ", "[", + RowBox[{"0", ",", "1"}], "]"}], ",", + RowBox[{"rhs", "[", "i_", "]"}]}], "]"}], ",", "strFn_"}], "]"}], ":=", + + RowBox[{ + RowBox[{"strFn", "[", + RowBox[{"ret", "[", "ir", "]"}], "]"}], "<>", "\"\< = timesI(\>\"", "<>", + " ", + RowBox[{"strFn", "[", + RowBox[{"rhs", "[", "i", "]"}], "]"}], "<>", + "\"\<);\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"expr", "[", + RowBox[{"ir_", ",", + RowBox[{"Times", "[", + RowBox[{ + RowBox[{"Complex", " ", "[", + RowBox[{"0", ",", + RowBox[{"-", "1"}]}], "]"}], ",", + RowBox[{"rhs", "[", "i_", "]"}]}], "]"}], ",", "strFn_"}], "]"}], ":=", + + RowBox[{ + RowBox[{"strFn", "[", + RowBox[{"ret", "[", "ir", "]"}], "]"}], "<>", "\"\< = timesMinusI(\>\"", "<>", + " ", + RowBox[{"strFn", "[", + RowBox[{"rhs", "[", "i", "]"}], "]"}], "<>", + "\"\<);\>\""}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{"vecFunc", "[", "g_", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{ + RowBox[{"out", "=", "\"\<\>\""}], ",", + RowBox[{"ir", "=", "0"}]}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{ + "\"\\ninline void mult\>\"", "<>", + "\[IndentingNewLine]", + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", "\"\\""}], "]"}], + "<>", "\[IndentingNewLine]", + "\"\<(iVector &ret, const iVector \ +&rhs)\\n{\\n\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< \>\"", "<>", + RowBox[{"expr", "[", + RowBox[{"ir", ",", "c", ",", "vecCoef"}], "]"}], "<>", + "\"\<\\n\>\""}]}], ";", + RowBox[{"ir", "=", + RowBox[{"ir", "+", "1"}]}]}], ",", + RowBox[{"{", + RowBox[{"c", ",", + RowBox[{ + RowBox[{"mat", "[", "g", "]"}], ".", "rhsv"}]}], "}"}]}], "]"}], + ";", "\[IndentingNewLine]", + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\<};\\n\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}], + ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"lmatFunc", "[", "g_", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{ + RowBox[{"out", "=", "\"\<\>\""}], ",", + RowBox[{"ir", "=", "0"}]}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{ + "\"\\ninline void lmult\>\"", "<>", + "\[IndentingNewLine]", + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", "\"\\""}], "]"}], "<>", + "\[IndentingNewLine]", + "\"\<(iMatrix &ret, const iMatrix &rhs)\\n{\\n\>\ +\"", "<>", "\[IndentingNewLine]", + "\"\< for(unsigned int i = 0; i < Ns; ++i)\\n {\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< \>\"", "<>", + RowBox[{"expr", "[", + RowBox[{"ir", ",", "c", ",", "lmatCoef"}], "]"}], "<>", + "\"\<\\n\>\""}]}], ";", + RowBox[{"ir", "=", + RowBox[{"ir", "+", "1"}]}]}], ",", + RowBox[{"{", + RowBox[{"c", ",", + RowBox[{ + RowBox[{"mat", "[", "g", "]"}], ".", "rhsv"}]}], "}"}]}], "]"}], + ";", "\[IndentingNewLine]", + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\< }\\n};\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"rmatFunc", "[", "g_", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{ + RowBox[{"out", "=", "\"\<\>\""}], ",", + RowBox[{"ir", "=", "0"}]}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{ + "\"\\ninline void rmult\>\"", "<>", + "\[IndentingNewLine]", + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", "\"\\""}], "]"}], "<>", + "\[IndentingNewLine]", + "\"\<(iMatrix &ret, const iMatrix &rhs)\\n{\\n\>\ +\"", "<>", "\[IndentingNewLine]", + "\"\< for(unsigned int i = 0; i < Ns; ++i)\\n {\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< \>\"", "<>", + RowBox[{"expr", "[", + RowBox[{"ir", ",", "c", ",", "rmatCoef"}], "]"}], "<>", + "\"\<\\n\>\""}]}], ";", + RowBox[{"ir", "=", + RowBox[{"ir", "+", "1"}]}]}], ",", + RowBox[{"{", + RowBox[{"c", ",", + RowBox[{"rhsv", ".", + RowBox[{"mat", "[", "g", "]"}]}]}], "}"}]}], "]"}], ";", + "\[IndentingNewLine]", + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\< }\\n};\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"allFunc", "[", "g_", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"vecFunc", "[", "g", "]"}], "<>", "\"\<\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"lmatFunc", "[", "g", "]"}], "<>", "\"\<\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"rmatFunc", "[", "g", "]"}], "<>", "\"\<\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"vecFinal", "[", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + "out", "=", + "\"\ \ninline auto operator*(const Gamma &G, \ +const iVector &arg)\n->typename \ +std::enable_if, SpinorIndex>::value, \ +iVector>::type\n{\n iVector ret;\n\n switch (G.g) \n \ +{\n\>\""}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\< case Gamma::\>\"", "<>", + RowBox[{"enum", "[", "g", "]"}], "<>", "\"\<:\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< mult\>\"", "<>", + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", "\"\\""}], + "]"}], "<>", "\"\<(ret, arg); break;\\n\>\""}]}]}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{ + "out", "<>", + "\"\< default: assert(0);\n }\n \n return ret;\n}\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"lmatFinal", "[", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + "out", "=", + "\"\ \ninline auto operator*(const Gamma &G, \ +const iMatrix &arg)\n->typename \ +std::enable_if, SpinorIndex>::value, \ +iMatrix>::type\n{\n iMatrix ret;\n\n switch (G.g) \n \ +{\n\>\""}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\< case Gamma::\>\"", "<>", + RowBox[{"enum", "[", "g", "]"}], "<>", "\"\<:\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< lmult\>\"", "<>", + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", "\"\\""}], + "]"}], "<>", "\"\<(ret, arg); break;\\n\>\""}]}]}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{ + "out", "<>", + "\"\< default: assert(0);\n }\n \n return ret;\n}\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"makeFuncCode", "[", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", + RowBox[{ + RowBox[{"Do", "[", + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"allFunc", "[", "g", "]"}]}]}], ",", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"rmatFinal", "[", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + "out", "=", + "\"\ \ninline auto operator*(const iMatrix &arg, const Gamma &G)\n->typename \ +std::enable_if, SpinorIndex>::value, \ +iMatrix>::type\n{\n iMatrix ret;\n\n switch (G.g) \n \ +{\n\>\""}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", + RowBox[{ + RowBox[{ + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\< case Gamma::\>\"", "<>", + RowBox[{"enum", "[", "g", "]"}], "<>", "\"\<:\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< rmult\>\"", "<>", + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", "\"\\""}], + "]"}], "<>", "\"\<(ret, arg); break;\\n\>\""}]}]}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{ + "out", "<>", + "\"\< default: assert(0);\n }\n \n return ret;\n}\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], + "]"}]}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"makeFuncCode", "[", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Do", "[", + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"allFunc", "[", "g", "]"}]}]}], ",", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"vecFinal", "[", "]"}], "<>", "\"\<\\n\>\"", "<>", + RowBox[{"lmatFinal", "[", "]"}], "<>", "\"\<\\n\>\"", "<>", + RowBox[{"rmatFinal", "[", "]"}]}]}], ";", "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}]}], "Input", + CellChangeTimes->{{3.6941903338959*^9, 3.694190334958905*^9}, { + 3.694190447518065*^9, 3.694190478462919*^9}, {3.69419063973578*^9, + 3.694190653669788*^9}, {3.694190716258309*^9, 3.694190763163622*^9}, { + 3.6941907963765583`*^9, 3.694190805046734*^9}, {3.69419084029659*^9, + 3.694190865238916*^9}, {3.694190901904236*^9, 3.694191193971095*^9}, { + 3.694191319457264*^9, 3.694191355674004*^9}, {3.694191450019418*^9, + 3.694191492801243*^9}, {3.694191537908826*^9, 3.6941918755887957`*^9}, { + 3.694191978131227*^9, 3.694191986666445*^9}, {3.694192020425993*^9, + 3.694192167484473*^9}, {3.6941922686760483`*^9, 3.69419237821404*^9}, { + 3.6941924316822777`*^9, 3.694192445274864*^9}, 3.694193521866951*^9, { + 3.694206465375606*^9, 3.6942065075728807`*^9}, {3.694206554520149*^9, + 3.694206587955097*^9}, {3.694206881090027*^9, 3.6942069067224293`*^9}, { + 3.694207497315682*^9, 3.6942076418716516`*^9}, {3.694207790223007*^9, + 3.694207989637043*^9}, {3.694208028110401*^9, 3.694208057057311*^9}, { + 3.694208089863509*^9, 3.6942082975753603`*^9}, {3.694212881031795*^9, + 3.694212885985661*^9}, {3.694213330227892*^9, 3.694213417940996*^9}, { + 3.694214921431739*^9, 3.694214951876449*^9}, {3.6942151046483088`*^9, + 3.694215118335286*^9}, {3.6942151634191313`*^9, 3.694215188429871*^9}, { + 3.6942940839999113`*^9, 3.694294090686364*^9}, {3.69489488486012*^9, + 3.6948948916252403`*^9}}], + +Cell["Header file generation:", "Text", + CellFrame->{{0, 0}, {0, 0.5}}, + CellChangeTimes->{{3.694209229931735*^9, 3.694209240365596*^9}}], + +Cell[BoxData[ + RowBox[{ + RowBox[{"file", "=", + RowBox[{"OpenWrite", "[", "\"\\"", "]"}]}], ";", + RowBox[{"WriteString", "[", + RowBox[{"file", ",", + RowBox[{"makeHeaderCode", "[", + RowBox[{ + RowBox[{"makeEnumCode", "[", "\"\< \>\"", "]"}], ",", + RowBox[{"makeFuncCode", "[", "]"}]}], "]"}]}], "]"}], ";", + RowBox[{"Close", "[", "file", "]"}], ";"}]], "Input", + CellChangeTimes->{{3.694207263508134*^9, 3.694207312537463*^9}, { + 3.6948949122726097`*^9, 3.6948949127609673`*^9}}] +}, Open ]], + +Cell[CellGroupData[{ + +Cell["Gamma.cc source file generation", "Section", + CellChangeTimes->{{3.694209250542284*^9, 3.694209266269907*^9}, { + 3.6949651357846317`*^9, 3.694965136291535*^9}}], + +Cell[BoxData[ + RowBox[{ + RowBox[{"makeSourceCode", "[", "]"}], ":=", + RowBox[{"Module", "[", + RowBox[{ + RowBox[{"{", + RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", " ", "=", " ", + RowBox[{ + "out", "<>", "\[IndentingNewLine]", + "\"\\n\nnamespace Grid {\n\ +namespace QCD {\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"out", " ", "=", " ", + RowBox[{ + "out", " ", "<>", + "\"\<\n\nconst std::array Gamma::gmu = {{\n \ +Gamma(Gamma::Algebra::GammaX),\n Gamma(Gamma::Algebra::GammaY),\n \ +Gamma(Gamma::Algebra::GammaZ),\n Gamma(Gamma::Algebra::GammaT)}};\n\nconst \ +std::array Gamma::name = {{\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"Do", "[", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", " ", "=", " ", + RowBox[{"out", "<>", "\"\< \\\"\>\"", "<>", "\[IndentingNewLine]", + RowBox[{"StringPadRight", "[", + RowBox[{ + RowBox[{"StringTrim", "[", + RowBox[{ + RowBox[{"StringReplace", "[", + RowBox[{ + RowBox[{"enum", "[", "g", "]"}], ",", + RowBox[{"\"\\"", "\[Rule]", "\"\<-\>\""}]}], "]"}], + ",", "\"\\""}], "]"}], ",", "13"}], "]"}], "<>", + "\[IndentingNewLine]", "\"\<\\\"\>\"", "<>", "\[IndentingNewLine]", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"g", "\[Equal]", + RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}};\\n\\n\>\"", + ",", "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"out", " ", "=", " ", + RowBox[{ + "out", "<>", + "\"\ Gamma::adj = \ +{{\\n\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\< Gamma::\>\"", "<>", + RowBox[{"enum", "[", + RowBox[{"g", "\[ConjugateTranspose]"}], "]"}], "<>", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"g", "\[Equal]", + RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}};\\n\\n\>\"", + ",", "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", + RowBox[{"out", " ", "=", " ", + RowBox[{ + "out", " ", "<>", + "\"\, \ +Gamma::nGamma> Gamma::mul = {{\\n\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"Do", "[", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Do", "[", "\[IndentingNewLine]", + RowBox[{ + RowBox[{"out", "=", + RowBox[{"out", "<>", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"g2", "\[Equal]", + RowBox[{"First", "[", "alg", "]"}]}], ",", "\"\< {{\>\"", ",", + "\"\< \>\"", ",", "\"\< \>\""}], "]"}], + "\[IndentingNewLine]", "<>", "\"\\"", "<>", + RowBox[{"enum", "[", + RowBox[{"g1", ".", "g2"}], "]"}], "<>", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"g2", "\[Equal]", + RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}}\>\"", ",", + "\"\<\>\"", ",", "\"\<\>\""}], "]"}], "\[IndentingNewLine]", "<>", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"g2", "\[Equal]", + RowBox[{"Last", "[", "alg", "]"}]}], ",", + RowBox[{"If", "[", + RowBox[{ + RowBox[{"g1", "\[Equal]", + RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<\>\"", ",", + "\"\<\\n ,\\n\>\"", ",", "\"\<\\n ,\\n\>\""}], "]"}], ",", + "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g2", ",", "alg"}], "}"}]}], "]"}], ",", + "\[IndentingNewLine]", + RowBox[{"{", + RowBox[{"g1", ",", "alg"}], "}"}]}], "]"}], ";", + "\[IndentingNewLine]", + RowBox[{"out", "=", + RowBox[{"out", "<>", "\"\<\\n}};\\n\\n\>\""}]}], ";", + "\[IndentingNewLine]", + RowBox[{"out", " ", "=", + RowBox[{"out", "<>", "\"\<}}\\n\>\""}]}], ";", "\[IndentingNewLine]", + RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}]], "Input", + CellChangeTimes->{{3.69421121373662*^9, 3.694211248473432*^9}, { + 3.6942118524105463`*^9, 3.694211892664316*^9}, {3.69421196260581*^9, + 3.69421202215168*^9}, {3.69421216516626*^9, 3.694212368624585*^9}, { + 3.694212488334324*^9, 3.694212500692437*^9}, 3.6942134310746183`*^9, { + 3.694215284859365*^9, 3.694215285515815*^9}, {3.694215368213806*^9, + 3.69421537607312*^9}, {3.694215508990799*^9, 3.694215509814066*^9}, { + 3.69489462883849*^9, 3.694894689512344*^9}, {3.6948947475649767`*^9, + 3.694894811418371*^9}, {3.6949626931212053`*^9, 3.694962703130487*^9}, { + 3.694962897531991*^9, 3.694962897865933*^9}, {3.6949629511775627`*^9, + 3.694963031525289*^9}, {3.694963065828494*^9, 3.694963098327538*^9}, { + 3.6949632020836153`*^9, 3.6949632715940027`*^9}, {3.694963440035037*^9, + 3.6949634418966017`*^9}, {3.6949651447067547`*^9, 3.694965161228381*^9}, { + 3.694967957845581*^9, 3.694967958364184*^9}}], + +Cell[BoxData[ + RowBox[{ + RowBox[{"file", "=", + RowBox[{"OpenWrite", "[", "\"\\"", "]"}]}], ";", + RowBox[{"WriteString", "[", + RowBox[{"file", ",", + RowBox[{"makeSourceCode", "[", "]"}]}], "]"}], ";", + RowBox[{"Close", "[", "file", "]"}], ";"}]], "Input", + CellChangeTimes->{{3.694212294084733*^9, 3.694212304244363*^9}, { + 3.6942124200138683`*^9, 3.694212434840803*^9}, {3.6948947822948923`*^9, + 3.694894782897565*^9}}], + +Cell[BoxData[""], "Input", + CellChangeTimes->{{3.6949630607688303`*^9, 3.694963063131344*^9}}] +}, Open ]] +}, +WindowSize->{1246, 1005}, +WindowMargins->{{64, Automatic}, {Automatic, 0}}, +FrontEndVersion->"11.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (September \ +21, 2016)", +StyleDefinitions->"Default.nb" +] +(* End of Notebook Content *) + +(* Internal cache information *) +(*CellTagsOutline +CellTagsIndex->{} +*) +(*CellTagsIndex +CellTagsIndex->{} +*) +(*NotebookFileOutline +Notebook[{ +Cell[558, 20, 1295, 18, 502, "Text"], +Cell[CellGroupData[{ +Cell[1878, 42, 513, 10, 75, "Input"], +Cell[2394, 54, 1090, 15, 32, "Output"] +}, Open ]], +Cell[CellGroupData[{ +Cell[3521, 74, 114, 1, 64, "Section"], +Cell[3638, 77, 475, 14, 54, "Input"], +Cell[4116, 93, 190, 2, 30, "Text"], +Cell[4309, 97, 5454, 168, 427, "Input"], +Cell[9766, 267, 119, 1, 30, "Text"], +Cell[9888, 270, 2115, 63, 96, "Input"], +Cell[12006, 335, 133, 1, 30, "Text"], +Cell[CellGroupData[{ +Cell[12164, 340, 479, 15, 32, "Input"], +Cell[12646, 357, 1648, 34, 96, "Output"] +}, Open ]], +Cell[14309, 394, 110, 1, 30, "Text"], +Cell[CellGroupData[{ +Cell[14444, 399, 476, 12, 32, "Input"], +Cell[14923, 413, 6697, 166, 312, "Output"] +}, Open ]] +}, Open ]], +Cell[CellGroupData[{ +Cell[21669, 585, 166, 2, 64, "Section"], +Cell[21838, 589, 128, 2, 38, "Text"], +Cell[21969, 593, 2923, 52, 705, "Input"], +Cell[24895, 647, 164, 3, 38, "Text"], +Cell[25062, 652, 4876, 148, 684, "Input"], +Cell[29941, 802, 2588, 55, 201, "Input"], +Cell[32532, 859, 149, 2, 38, "Text"], +Cell[32684, 863, 15249, 396, 2133, "Input"], +Cell[47936, 1261, 137, 2, 38, "Text"], +Cell[48076, 1265, 521, 12, 32, "Input"] +}, Open ]], +Cell[CellGroupData[{ +Cell[48634, 1282, 167, 2, 64, "Section"], +Cell[48804, 1286, 5693, 122, 831, "Input"], +Cell[54500, 1410, 448, 10, 32, "Input"], +Cell[54951, 1422, 94, 1, 32, "Input"] +}, Open ]] +} +] +*) + diff --git a/lib/qcd/utils/LinalgUtils.h b/lib/qcd/utils/LinalgUtils.h index 6555511c..5eaf1c2a 100644 --- a/lib/qcd/utils/LinalgUtils.h +++ b/lib/qcd/utils/LinalgUtils.h @@ -47,7 +47,7 @@ void axpibg5x(Lattice &z,const Lattice &x,Coeff a,Coeff b) GridBase *grid=x._grid; - Gamma G5(Gamma::Gamma5); + Gamma G5(Gamma::Algebra::Gamma5); parallel_for(int ss=0;ssoSites();ss++){ vobj tmp; tmp = a*x._odata[ss]; @@ -78,7 +78,8 @@ void ag5xpby_ssp(Lattice &z,Coeff a,const Lattice &x,Coeff b,const L conformable(x,z); GridBase *grid=x._grid; int Ls = grid->_rdimensions[0]; - Gamma G5(Gamma::Gamma5); + + Gamma G5(Gamma::Algebra::Gamma5); parallel_for(int ss=0;ssoSites();ss+=Ls){ // adds Ls vobj tmp; tmp = G5*x._odata[ss+s]*a; @@ -95,7 +96,7 @@ void axpbg5y_ssp(Lattice &z,Coeff a,const Lattice &x,Coeff b,const L conformable(x,z); GridBase *grid=x._grid; int Ls = grid->_rdimensions[0]; - Gamma G5(Gamma::Gamma5); + Gamma G5(Gamma::Algebra::Gamma5); parallel_for(int ss=0;ssoSites();ss+=Ls){ // adds Ls vobj tmp; tmp = G5*y._odata[ss+sp]*b; @@ -112,7 +113,8 @@ void ag5xpbg5y_ssp(Lattice &z,Coeff a,const Lattice &x,Coeff b,const conformable(x,z); GridBase *grid=x._grid; int Ls = grid->_rdimensions[0]; - Gamma G5(Gamma::Gamma5); + + Gamma G5(Gamma::Algebra::Gamma5); parallel_for(int ss=0;ssoSites();ss+=Ls){ // adds Ls vobj tmp1; vobj tmp2; @@ -161,8 +163,8 @@ void G5R5(Lattice &z,const Lattice &x) z.checkerboard = x.checkerboard; conformable(x,z); int Ls = grid->_rdimensions[0]; - Gamma G5(Gamma::Gamma5); - parallel_for(int ss=0;ssoSites();ss+=Ls){ // adds Ls + Gamma G5(Gamma::Algebra::Gamma5); + parallel_for(int ss=0;ssoSites();ss+=Ls) { vobj tmp; for(int s=0;s #include namespace Grid { + // Vector IO utilities /////////////////////////////////////////////////////// // helper function to read space-separated values template std::vector strToVec(const std::string s) @@ -67,6 +68,77 @@ namespace Grid { return os; } + // Vector element trait ////////////////////////////////////////////////////// + template + struct element + { + typedef T type; + static constexpr bool is_number = false; + }; + + template + struct element> + { + typedef typename element::type type; + static constexpr bool is_number = std::is_arithmetic::value + or is_complex::value + or element::is_number; + }; + + // Vector flatening utility class //////////////////////////////////////////// + // Class to flatten a multidimensional std::vector + template + class Flatten + { + public: + typedef typename element::type Element; + public: + explicit Flatten(const V &vector); + const V & getVector(void); + const std::vector & getFlatVector(void); + const std::vector & getDim(void); + private: + void accumulate(const Element &e); + template + void accumulate(const W &v); + void accumulateDim(const Element &e); + template + void accumulateDim(const W &v); + private: + const V &vector_; + std::vector flatVector_; + std::vector dim_; + }; + + + // Class to reconstruct a multidimensional std::vector + template + class Reconstruct + { + public: + typedef typename element::type Element; + public: + Reconstruct(const std::vector &flatVector, + const std::vector &dim); + const V & getVector(void); + const std::vector & getFlatVector(void); + const std::vector & getDim(void); + private: + void fill(std::vector &v); + template + void fill(W &v); + void resize(std::vector &v, const unsigned int dim); + template + void resize(W &v, const unsigned int dim); + private: + V vector_; + const std::vector &flatVector_; + std::vector dim_; + size_t ind_{0}; + unsigned int dimInd_{0}; + }; + + // Abstract writer/reader classes //////////////////////////////////////////// // static polymorphism implemented using CRTP idiom class Serializable; @@ -83,12 +155,7 @@ namespace Grid { typename std::enable_if::value, void>::type write(const std::string& s, const U &output); template - typename std::enable_if::value, void>::type - write(const std::string& s, const U &output); - template - typename std::enable_if< - !(std::is_base_of::value or std::is_enum::value), - void>::type + typename std::enable_if::value, void>::type write(const std::string& s, const U &output); private: T *upcast; @@ -107,12 +174,7 @@ namespace Grid { typename std::enable_if::value, void>::type read(const std::string& s, U &output); template - typename std::enable_if::value, void>::type - read(const std::string& s, U &output); - template - typename std::enable_if< - !(std::is_base_of::value or std::is_enum::value), - void>::type + typename std::enable_if::value, void>::type read(const std::string& s, U &output); protected: template @@ -142,7 +204,128 @@ namespace Grid { } }; - // Generic writer interface + // Flatten class template implementation ///////////////////////////////////// + template + void Flatten::accumulate(const Element &e) + { + flatVector_.push_back(e); + } + + template + template + void Flatten::accumulate(const W &v) + { + for (auto &e: v) + { + accumulate(e); + } + } + + template + void Flatten::accumulateDim(const Element &e) {}; + + template + template + void Flatten::accumulateDim(const W &v) + { + dim_.push_back(v.size()); + accumulateDim(v[0]); + } + + template + Flatten::Flatten(const V &vector) + : vector_(vector) + { + accumulate(vector_); + accumulateDim(vector_); + } + + template + const V & Flatten::getVector(void) + { + return vector_; + } + + template + const std::vector::Element> & + Flatten::getFlatVector(void) + { + return flatVector_; + } + + template + const std::vector & Flatten::getDim(void) + { + return dim_; + } + + // Reconstruct class template implementation ///////////////////////////////// + template + void Reconstruct::fill(std::vector &v) + { + for (auto &e: v) + { + e = flatVector_[ind_++]; + } + } + + template + template + void Reconstruct::fill(W &v) + { + for (auto &e: v) + { + fill(e); + } + } + + template + void Reconstruct::resize(std::vector &v, const unsigned int dim) + { + v.resize(dim_[dim]); + } + + template + template + void Reconstruct::resize(W &v, const unsigned int dim) + { + v.resize(dim_[dim]); + for (auto &e: v) + { + resize(e, dim + 1); + } + } + + template + Reconstruct::Reconstruct(const std::vector &flatVector, + const std::vector &dim) + : flatVector_(flatVector) + , dim_(dim) + { + resize(vector_, 0); + fill(vector_); + } + + template + const V & Reconstruct::getVector(void) + { + return vector_; + } + + template + const std::vector::Element> & + Reconstruct::getFlatVector(void) + { + return flatVector_; + } + + template + const std::vector & Reconstruct::getDim(void) + { + return dim_; + } + + // Generic writer interface ////////////////////////////////////////////////// template inline void push(Writer &w, const std::string &s) { @@ -221,23 +404,13 @@ namespace Grid { template template - typename std::enable_if::value, void>::type - Writer::write(const std::string &s, const U &output) - { - EnumIO::write(*this, s, output); - } - - template - template - typename std::enable_if< - !(std::is_base_of::value or std::is_enum::value), - void>::type + typename std::enable_if::value, void>::type Writer::write(const std::string &s, const U &output) { upcast->writeDefault(s, output); } - // Reader template implementation //////////////////////////////////////////// + // Reader template implementation template Reader::Reader(void) { @@ -266,17 +439,7 @@ namespace Grid { template template - typename std::enable_if::value, void>::type - Reader::read(const std::string &s, U &output) - { - EnumIO::read(*this, s, output); - } - - template - template - typename std::enable_if< - !(std::is_base_of::value or std::is_enum::value), - void>::type + typename std::enable_if::value, void>::type Reader::read(const std::string &s, U &output) { upcast->readDefault(s, output); @@ -300,7 +463,6 @@ namespace Grid { abort(); } } - } #endif diff --git a/lib/serialisation/BinaryIO.cc b/lib/serialisation/BinaryIO.cc index 0a4f2665..7133adc0 100644 --- a/lib/serialisation/BinaryIO.cc +++ b/lib/serialisation/BinaryIO.cc @@ -26,7 +26,6 @@ Author: paboyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ - #include using namespace Grid; diff --git a/lib/serialisation/Hdf5IO.cc b/lib/serialisation/Hdf5IO.cc new file mode 100644 index 00000000..b9bb0b87 --- /dev/null +++ b/lib/serialisation/Hdf5IO.cc @@ -0,0 +1,103 @@ +#include + +using namespace Grid; +#ifndef H5_NO_NAMESPACE +using namespace H5NS; +#endif + +// Writer implementation /////////////////////////////////////////////////////// +Hdf5Writer::Hdf5Writer(const std::string &fileName) +: fileName_(fileName) +, file_(fileName.c_str(), H5F_ACC_TRUNC) +{ + group_ = file_.openGroup("/"); + writeSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold", + Hdf5Type::type()); +} + +void Hdf5Writer::push(const std::string &s) +{ + group_ = group_.createGroup(s); + path_.push_back(s); +} + +void Hdf5Writer::pop(void) +{ + path_.pop_back(); + if (path_.empty()) + { + group_ = file_.openGroup("/"); + } + else + { + auto binOp = [](const std::string &a, const std::string &b)->std::string + { + return a + "/" + b; + }; + + group_ = group_.openGroup(std::accumulate(path_.begin(), path_.end(), + std::string(""), binOp)); + } +} + +template <> +void Hdf5Writer::writeDefault(const std::string &s, const std::string &x) +{ + StrType strType(PredType::C_S1, x.size()); + + writeSingleAttribute(*(x.data()), s, strType); +} + +void Hdf5Writer::writeDefault(const std::string &s, const char *x) +{ + std::string sx(x); + + writeDefault(s, sx); +} + +// Reader implementation /////////////////////////////////////////////////////// +Hdf5Reader::Hdf5Reader(const std::string &fileName) +: fileName_(fileName) +, file_(fileName.c_str(), H5F_ACC_RDONLY) +{ + group_ = file_.openGroup("/"); + readSingleAttribute(dataSetThres_, HDF5_GRID_GUARD "dataset_threshold", + Hdf5Type::type()); +} + +void Hdf5Reader::push(const std::string &s) +{ + group_ = group_.openGroup(s); + path_.push_back(s); +} + +void Hdf5Reader::pop(void) +{ + path_.pop_back(); + if (path_.empty()) + { + group_ = file_.openGroup("/"); + } + else + { + auto binOp = [](const std::string &a, const std::string &b)->std::string + { + return a + "/" + b; + }; + + group_ = group_.openGroup(std::accumulate(path_.begin(), path_.end(), + std::string(""), binOp)); + } +} + +template <> +void Hdf5Reader::readDefault(const std::string &s, std::string &x) +{ + Attribute attribute; + + attribute = group_.openAttribute(s); + StrType strType = attribute.getStrType(); + + x.resize(strType.getSize()); + attribute.read(strType, &(x[0])); +} diff --git a/lib/serialisation/Hdf5IO.h b/lib/serialisation/Hdf5IO.h new file mode 100644 index 00000000..2f891cd4 --- /dev/null +++ b/lib/serialisation/Hdf5IO.h @@ -0,0 +1,242 @@ +#ifndef GRID_SERIALISATION_HDF5_H +#define GRID_SERIALISATION_HDF5_H + +#include +#include +#include +#include +#include "Hdf5Type.h" + +#ifndef H5_NO_NAMESPACE +#define H5NS H5 +#endif + +// default thresold above which datasets are used instead of attributes +#ifndef HDF5_DEF_DATASET_THRES +#define HDF5_DEF_DATASET_THRES 6u +#endif + +// name guard for Grid metadata +#define HDF5_GRID_GUARD "_Grid_" + +namespace Grid +{ + class Hdf5Writer: public Writer + { + public: + Hdf5Writer(const std::string &fileName); + virtual ~Hdf5Writer(void) = default; + void push(const std::string &s); + void pop(void); + void writeDefault(const std::string &s, const char *x); + template + void writeDefault(const std::string &s, const U &x); + template + typename std::enable_if>::is_number, void>::type + writeDefault(const std::string &s, const std::vector &x); + template + typename std::enable_if>::is_number, void>::type + writeDefault(const std::string &s, const std::vector &x); + private: + template + void writeSingleAttribute(const U &x, const std::string &name, + const H5NS::DataType &type); + private: + std::string fileName_; + std::vector path_; + H5NS::H5File file_; + H5NS::Group group_; + unsigned int dataSetThres_{HDF5_DEF_DATASET_THRES}; + }; + + class Hdf5Reader: public Reader + { + public: + Hdf5Reader(const std::string &fileName); + virtual ~Hdf5Reader(void) = default; + void push(const std::string &s); + void pop(void); + template + void readDefault(const std::string &s, U &output); + template + typename std::enable_if>::is_number, void>::type + readDefault(const std::string &s, std::vector &x); + template + typename std::enable_if>::is_number, void>::type + readDefault(const std::string &s, std::vector &x); + private: + template + void readSingleAttribute(U &x, const std::string &name, + const H5NS::DataType &type); + private: + std::string fileName_; + std::vector path_; + H5NS::H5File file_; + H5NS::Group group_; + unsigned int dataSetThres_; + }; + + // Writer template implementation //////////////////////////////////////////// + template + void Hdf5Writer::writeSingleAttribute(const U &x, const std::string &name, + const H5NS::DataType &type) + { + H5NS::Attribute attribute; + hsize_t attrDim = 1; + H5NS::DataSpace attrSpace(1, &attrDim); + + attribute = group_.createAttribute(name, type, attrSpace); + attribute.write(type, &x); + } + + template + void Hdf5Writer::writeDefault(const std::string &s, const U &x) + { + writeSingleAttribute(x, s, Hdf5Type::type()); + } + + template <> + void Hdf5Writer::writeDefault(const std::string &s, const std::string &x); + + template + typename std::enable_if>::is_number, void>::type + Hdf5Writer::writeDefault(const std::string &s, const std::vector &x) + { + // alias to element type + typedef typename element>::type Element; + + // flatten the vector and getting dimensions + Flatten> flat(x); + std::vector dim; + const auto &flatx = flat.getFlatVector(); + + for (auto &d: flat.getDim()) + { + dim.push_back(d); + } + + // write to file + H5NS::DataSpace dataSpace(dim.size(), dim.data()); + + if (flatx.size() > dataSetThres_) + { + H5NS::DataSet dataSet; + + dataSet = group_.createDataSet(s, Hdf5Type::type(), dataSpace); + dataSet.write(flatx.data(), Hdf5Type::type()); + } + else + { + H5NS::Attribute attribute; + + attribute = group_.createAttribute(s, Hdf5Type::type(), dataSpace); + attribute.write(Hdf5Type::type(), flatx.data()); + } + } + + template + typename std::enable_if>::is_number, void>::type + Hdf5Writer::writeDefault(const std::string &s, const std::vector &x) + { + push(s); + writeSingleAttribute(x.size(), HDF5_GRID_GUARD "vector_size", + Hdf5Type::type()); + for (hsize_t i = 0; i < x.size(); ++i) + { + write(s + "_" + std::to_string(i), x[i]); + } + pop(); + } + + // Reader template implementation //////////////////////////////////////////// + template + void Hdf5Reader::readSingleAttribute(U &x, const std::string &name, + const H5NS::DataType &type) + { + H5NS::Attribute attribute; + + attribute = group_.openAttribute(name); + attribute.read(type, &x); + } + + template + void Hdf5Reader::readDefault(const std::string &s, U &output) + { + readSingleAttribute(output, s, Hdf5Type::type()); + } + + template <> + void Hdf5Reader::readDefault(const std::string &s, std::string &x); + + template + typename std::enable_if>::is_number, void>::type + Hdf5Reader::readDefault(const std::string &s, std::vector &x) + { + // alias to element type + typedef typename element>::type Element; + + // read the dimensions + H5NS::DataSpace dataSpace; + std::vector hdim; + std::vector dim; + hsize_t size = 1; + + if (group_.attrExists(s)) + { + dataSpace = group_.openAttribute(s).getSpace(); + } + else + { + dataSpace = group_.openDataSet(s).getSpace(); + } + hdim.resize(dataSpace.getSimpleExtentNdims()); + dataSpace.getSimpleExtentDims(hdim.data()); + for (auto &d: hdim) + { + dim.push_back(d); + size *= d; + } + + // read the flat vector + std::vector buf(size); + + if (size > dataSetThres_) + { + H5NS::DataSet dataSet; + + dataSet = group_.openDataSet(s); + dataSet.read(buf.data(), Hdf5Type::type()); + } + else + { + H5NS::Attribute attribute; + + attribute = group_.openAttribute(s); + attribute.read(Hdf5Type::type(), buf.data()); + } + + // reconstruct the multidimensional vector + Reconstruct> r(buf, dim); + + x = r.getVector(); + } + + template + typename std::enable_if>::is_number, void>::type + Hdf5Reader::readDefault(const std::string &s, std::vector &x) + { + uint64_t size; + + push(s); + readSingleAttribute(size, HDF5_GRID_GUARD "vector_size", + Hdf5Type::type()); + x.resize(size); + for (hsize_t i = 0; i < x.size(); ++i) + { + read(s + "_" + std::to_string(i), x[i]); + } + pop(); + } +} + +#endif diff --git a/lib/serialisation/Hdf5Type.h b/lib/serialisation/Hdf5Type.h new file mode 100644 index 00000000..8634f35b --- /dev/null +++ b/lib/serialisation/Hdf5Type.h @@ -0,0 +1,77 @@ +#ifndef GRID_SERIALISATION_HDF5_TYPE_H +#define GRID_SERIALISATION_HDF5_TYPE_H + +#include +#include +#include + +#ifndef H5_NO_NAMESPACE +#define H5NS H5 +#endif + +#define HDF5_NATIVE_TYPE(predType, cType)\ +template <>\ +class Hdf5Type\ +{\ +public:\ + static inline const H5NS::DataType & type(void)\ + {\ + return H5NS::PredType::predType;\ + }\ + static constexpr bool isNative = true;\ +}; + +#define DEFINE_HDF5_NATIVE_TYPES \ +HDF5_NATIVE_TYPE(NATIVE_B8, bool);\ +HDF5_NATIVE_TYPE(NATIVE_CHAR, char);\ +HDF5_NATIVE_TYPE(NATIVE_SCHAR, signed char);\ +HDF5_NATIVE_TYPE(NATIVE_UCHAR, unsigned char);\ +HDF5_NATIVE_TYPE(NATIVE_SHORT, short);\ +HDF5_NATIVE_TYPE(NATIVE_USHORT, unsigned short);\ +HDF5_NATIVE_TYPE(NATIVE_INT, int);\ +HDF5_NATIVE_TYPE(NATIVE_UINT, unsigned int);\ +HDF5_NATIVE_TYPE(NATIVE_LONG, long);\ +HDF5_NATIVE_TYPE(NATIVE_ULONG, unsigned long);\ +HDF5_NATIVE_TYPE(NATIVE_LLONG, long long);\ +HDF5_NATIVE_TYPE(NATIVE_ULLONG, unsigned long long);\ +HDF5_NATIVE_TYPE(NATIVE_FLOAT, float);\ +HDF5_NATIVE_TYPE(NATIVE_DOUBLE, double);\ +HDF5_NATIVE_TYPE(NATIVE_LDOUBLE, long double); + +namespace Grid +{ + template class Hdf5Type + { + public: + static constexpr bool isNative = false; + }; + + DEFINE_HDF5_NATIVE_TYPES; + + template + class Hdf5Type> + { + public: + static inline const H5NS::DataType & type(void) + { + if (typePtr_ == nullptr) + { + typePtr_.reset(new H5NS::CompType(sizeof(std::complex))); + typePtr_->insertMember("re", 0, Hdf5Type::type()); + typePtr_->insertMember("im", sizeof(R), Hdf5Type::type()); + } + + return *typePtr_; + } + static constexpr bool isNative = false; + private: + static std::unique_ptr typePtr_; + }; + + template + std::unique_ptr Hdf5Type>::typePtr_ = nullptr; +} + +#undef HDF5_NATIVE_TYPE + +#endif /* GRID_SERIALISATION_HDF5_TYPE_H */ diff --git a/lib/serialisation/MacroMagic.h b/lib/serialisation/MacroMagic.h index c78bba0c..ca789312 100644 --- a/lib/serialisation/MacroMagic.h +++ b/lib/serialisation/MacroMagic.h @@ -109,40 +109,36 @@ THE SOFTWARE. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #define GRID_MACRO_MEMBER(A,B) A B; +#define GRID_MACRO_COMP_MEMBER(A,B) result = (result and (lhs. B == rhs. B)); #define GRID_MACRO_OS_WRITE_MEMBER(A,B) os<< #A <<" "#B <<" = "<< obj. B <<" ; " <\ - static inline void write(Writer &WR,const std::string &s, const cname &obj){ \ - push(WR,s);\ - GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \ - pop(WR);\ - } \ - \ - \ - template \ - static inline void read(Reader &RD,const std::string &s, cname &obj){ \ - push(RD,s);\ - GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \ - pop(RD);\ - } \ - \ - \ - friend inline std::ostream & operator << (std::ostream &os, const cname &obj ) { \ - os<<"class "<<#cname<<" {"<\ +static inline void write(Writer &WR,const std::string &s, const cname &obj){ \ + push(WR,s);\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \ + pop(WR);\ +}\ +template \ +static inline void read(Reader &RD,const std::string &s, cname &obj){ \ + push(RD,s);\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \ + pop(RD);\ +}\ +friend inline std::ostream & operator << (std::ostream &os, const cname &obj ) { \ + os<<"class "<<#cname<<" {"<::type #define GRID_MACRO_ENUMVAL(A,B) A = B, @@ -150,44 +146,61 @@ THE SOFTWARE. #define GRID_MACRO_ENUMTEST(A,B) else if (buf == #A) {obj = GRID_ENUM_TYPE(obj)::A;} #define GRID_MACRO_ENUMCASEIO(A,B) case GRID_ENUM_TYPE(obj)::A: os << #A; break; -namespace Grid { - template - class EnumIO {}; -} - #define GRID_SERIALIZABLE_ENUM(name,undefname,...)\ - enum class name {\ - GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMVAL,__VA_ARGS__))\ - undefname = -1\ +class name: public Grid::Serializable\ +{\ +public:\ + enum\ + {\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMVAL,__VA_ARGS__))\ + undefname = -1\ };\ +public:\ + name(void): value_(undefname) {};\ + name(int value): value_(value) {};\ + template \ + static inline void write(Grid::Writer &WR,const std::string &s, const name &obj)\ + {\ + switch (obj.value_)\ + {\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\ + default: Grid::write(WR,s,#undefname); break;\ + }\ + }\ \ - template<>\ - class EnumIO {\ - public:\ - template \ - static inline void write(Writer &WR,const std::string &s, const name &obj){ \ - switch (obj) {\ - GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASE,__VA_ARGS__))\ - default: Grid::write(WR,s,#undefname); break;\ - }\ - }\ - \ - template \ - static inline void read(Reader &RD,const std::string &s, name &obj){ \ - std::string buf;\ - Grid::read(RD, s, buf);\ - if (buf == #undefname) {obj = name::undefname;}\ - GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\ - else {obj = name::undefname;}\ - }\ - };\ - \ - inline std::ostream & operator << (std::ostream &os, const name &obj ) { \ + template \ + static inline void read(Grid::Reader &RD,const std::string &s, name &obj)\ + {\ + std::string buf;\ + Grid::read(RD, s, buf);\ + if (buf == #undefname) {obj = name::undefname;}\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\ + else {obj = name::undefname;}\ + }\ + inline operator int(void) const\ + {\ + return value_;\ + }\ + inline friend std::ostream & operator<<(std::ostream &os, const name &obj)\ + {\ switch (obj) {\ - GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\ - default: os << #undefname; break;\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMCASEIO,__VA_ARGS__))\ + default: os << #undefname; break;\ }\ return os;\ - }; + }\ + inline friend std::istream & operator>>(std::istream &is, name &obj)\ + {\ + std::string buf;\ + is >> buf;\ + if (buf == #undefname) {obj = name::undefname;}\ + GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\ + else {obj = name::undefname;}\ + return is;\ + }\ +private:\ + int value_;\ +}; + #endif diff --git a/lib/serialisation/Serialisation.h b/lib/serialisation/Serialisation.h index 8f405d73..aa84e989 100644 --- a/lib/serialisation/Serialisation.h +++ b/lib/serialisation/Serialisation.h @@ -36,6 +36,9 @@ Author: Peter Boyle #include "BinaryIO.h" #include "TextIO.h" #include "XmlIO.h" +#ifdef HAVE_HDF5 +#include "Hdf5IO.h" +#endif ////////////////////////////////////////// // Todo: ////////////////////////////////////////// diff --git a/lib/sitmo_rng/sitmo_prng_engine.hpp b/lib/sitmo_rng/sitmo_prng_engine.hpp new file mode 100644 index 00000000..c76a0080 --- /dev/null +++ b/lib/sitmo_rng/sitmo_prng_engine.hpp @@ -0,0 +1,390 @@ +// Copyright (c) 2012-2016 M.A. (Thijs) van den Berg, http://sitmo.com/ +// +// Use, modification and distribution are subject to the MIT Software License. +// +// The MIT License (MIT) +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +// version history: +// version 1, 6 Sep 2012 +// version 2, 10 Dec 2013 +// bug fix in the discard() routine, it was discarding to many elements +// added the version() method +// version 3...5, 13 Dec 2013 +// fixed type-conversion earning +// fixed potential issues with constructor template matching +// version 6, 4 March 2016 +// made min() max() constexpr for C+11 compiler (thanks to James Joseph Balamuta) + +#ifndef SITMO_PRNG_ENGINE_HPP +#define SITMO_PRNG_ENGINE_HPP +#include + +#ifdef __GNUC__ + #include // respecting the C99 standard. +#endif +#ifdef _MSC_VER + typedef unsigned __int64 uint64_t; // Visual Studio 6.0(VC6) and newer.. + typedef unsigned __int32 uint32_t; +#endif + +// Double mixing function +#define MIX2(x0,x1,rx,z0,z1,rz) \ + x0 += x1; \ + z0 += z1; \ + x1 = (x1 << rx) | (x1 >> (64-rx)); \ + z1 = (z1 << rz) | (z1 >> (64-rz)); \ + x1 ^= x0; \ + z1 ^= z0; + + +// Double mixing function with key adition +#define MIXK(x0,x1,rx,z0,z1,rz,k0,k1,l0,l1) \ + x1 += k1; \ + z1 += l1; \ + x0 += x1+k0; \ + z0 += z1+l0; \ + x1 = (x1 << rx) | (x1 >> (64-rx)); \ + z1 = (z1 << rz) | (z1 >> (64-rz)); \ + x1 ^= x0; \ + z1 ^= z0; \ + + +namespace sitmo { + + // enable_if for C__98 compilers + template + struct sitmo_enable_if { typedef T type; }; + + template + struct sitmo_enable_if { }; + + // SFINAE check for the existence of a "void generate(int*,int*)"member function + template + struct has_generate_template + { + typedef char (&Two)[2];; + template struct helper {}; + template static char test(helper >*); + template static Two test(...); + static bool const value = sizeof(test(0)) == sizeof(char); + }; + + +class prng_engine +{ +public: + // "req" are requirements as stated in the C++ 11 draft n3242=11-0012 + // + // req: 26.5.1.3 Uniform random number generator requirements, p.906, table 116, row 1 + typedef uint32_t result_type; + + // req: 26.5.1.3 Uniform random number generator requirements, p.906, table 116, row 3 & 4 +#if __cplusplus <= 199711L + static result_type (min)() { return 0; } + static result_type (max)() { return 0xFFFFFFFF; } +#else + static constexpr result_type (min)() { return 0; } + static constexpr result_type (max)() { return 0xFFFFFFFF; } +#endif + + // ------------------------------------------------- + // Constructors + // ------------------------------------------------- + + // req: 26.5.1.4 Random number engine requirements, p.907 table 117, row 1 + // Creates an engine with the same initial state as all other + // default-constructed engines of type E. + prng_engine() + { + seed(); + } + + // req: 26.5.1.4 Random number engine requirements, p.907 table 117, row 2 + // Creates an engine that compares equal to x. + prng_engine(const prng_engine& x) + { + for (unsigned short i=0; i<4; ++i) { + _s[i] = x._s[i]; + _k[i] = x._k[i]; + _o[i] = x._o[i]; + } + _o_counter = x._o_counter; + } + + + // req: 26.5.1.4 Random number engine requirements, p.907 table 117, row 3 + // Creates an engine with initial O(size of state) state determined by s. + prng_engine(uint32_t s) + { + seed(s); + } + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 4 + // Creates an engine with an initial state that depends on a sequence + // produced by one call to q.generate. + template + prng_engine(Seq& q, typename sitmo_enable_if< has_generate_template::value >::type* = 0 ) + { + seed(q); + } + + // ------------------------------------------------- + // Seeding + // ------------------------------------------------- + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 5 + void seed() + { + for (unsigned short i=0; i<4; ++i) { + _k[i] = 0; + _s[i] = 0; + } + _o_counter = 0; + + _o[0] = 0x09218ebde6c85537; + _o[1] = 0x55941f5266d86105; + _o[2] = 0x4bd25e16282434dc; + _o[3] = 0xee29ec846bd2e40b; + } + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 6 + // s needs to be of return_type, which is uint32_t + void seed(uint32_t s) + { + for (unsigned short i=0; i<4; ++i) { + _k[i] = 0; + _s[i] = 0; + } + _k[0] = s; + _o_counter = 0; + + encrypt_counter(); + } + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 7 + template + void seed(Seq& q, typename sitmo_enable_if< has_generate_template::value >::type* = 0 ) + { + typename Seq::result_type w[8]; + q.generate(&w[0], &w[8]); + + for (unsigned short i=0; i<4; ++i) { + _k[i] = ( static_cast(w[2*i]) << 32) | w[2*i+1]; + _s[i] = 0; + } + _o_counter = 0; + + encrypt_counter(); + } + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 8 + // Advances e’s state ei to ei+1 = TA(ei) and returns GA(ei). + uint32_t operator()() + { + // can we return a value from the current block? + if (_o_counter < 8) { + unsigned short _o_index = _o_counter >> 1; + _o_counter++; + if (_o_counter&1) + return _o[_o_index] & 0xFFFFFFFF; + else + return _o[_o_index] >> 32; + } + + // generate a new block and return the first 32 bits + inc_counter(); + encrypt_counter(); + _o_counter = 1; // the next call + return _o[0] & 0xFFFFFFFF; // this call + } + + // ------------------------------------------------- + // misc + // ------------------------------------------------- + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 9 + // Advances e’s state ei to ei+z by any means equivalent to z + // consecutive calls e(). + void discard(uint64_t z) + { + // check if we stay in the current block + if (z < 8 - _o_counter) { + _o_counter += static_cast(z); + return; + } + + // we will have to generate a new block... + z -= (8 - _o_counter); // discard the remainder of the current blok + _o_counter = z % 8; // set the pointer in the correct element in the new block + z -= _o_counter; // update z + z >>= 3; // the number of buffers is elements/8 + ++z; // and one more because we crossed the buffer line + inc_counter(z); + encrypt_counter(); + } + + // ------------------------------------------------- + // IO + // ------------------------------------------------- + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, const prng_engine& s) { + for (unsigned short i=0; i<4; ++i) + os << s._k[i] << ' ' << s._s[i] << ' ' << s._o[i] << ' '; + os << s._o_counter; + return os; + } + + template + friend std::basic_istream& + operator>>(std::basic_istream& is, prng_engine& s) { + for (unsigned short i=0; i<4; ++i) + is >> s._k[i] >> s._s[i] >> s._o[i]; + is >> s._o_counter; + return is; + } + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 10 + // This operator is an equivalence relation. With Sx and Sy as the infinite + // sequences of values that would be generated by repeated future calls to + // x() and y(), respectively, returns true if Sx = Sy; else returns false. + bool operator==(const prng_engine& y) + { + if (_o_counter != y._o_counter) return false; + for (unsigned short i=0; i<4; ++i) { + if (_s[i] != y._s[i]) return false; + if (_k[i] != y._k[i]) return false; + if (_o[i] != y._o[i]) return false; + } + return true; + } + + // req: 26.5.1.4 Random number engine requirements, p.908 table 117, row 11 + bool operator!=(const prng_engine& y) + { + return !(*this == y); + } + + // Extra function to set the key + void set_key(uint64_t k0=0, uint64_t k1=0, uint64_t k2=0, uint64_t k3=0) + { + _k[0] = k0; _k[1] = k1; _k[2] = k2; _k[3] = k3; + encrypt_counter(); + } + + // set the counter + void set_counter(uint64_t s0=0, uint64_t s1=0, uint64_t s2=0, uint64_t s3=0, unsigned short o_counter=0) + { + _s[0] = s0; + _s[1] = s1; + _s[2] = s2; + _s[3] = s3; + _o_counter = o_counter % 8; + encrypt_counter(); + } + + + // versioning + uint32_t version() + { + return 5; + } + +private: + void encrypt_counter() + { + uint64_t b[4]; + uint64_t k[5]; + + for (unsigned short i=0; i<4; ++i) b[i] = _s[i]; + for (unsigned short i=0; i<4; ++i) k[i] = _k[i]; + + k[4] = 0x1BD11BDAA9FC1A22 ^ k[0] ^ k[1] ^ k[2] ^ k[3]; + + MIXK(b[0], b[1], 14, b[2], b[3], 16, k[0], k[1], k[2], k[3]); + MIX2(b[0], b[3], 52, b[2], b[1], 57); + MIX2(b[0], b[1], 23, b[2], b[3], 40); + MIX2(b[0], b[3], 5, b[2], b[1], 37); + MIXK(b[0], b[1], 25, b[2], b[3], 33, k[1], k[2], k[3], k[4]+1); + MIX2(b[0], b[3], 46, b[2], b[1], 12); + MIX2(b[0], b[1], 58, b[2], b[3], 22); + MIX2(b[0], b[3], 32, b[2], b[1], 32); + + MIXK(b[0], b[1], 14, b[2], b[3], 16, k[2], k[3], k[4], k[0]+2); + MIX2(b[0], b[3], 52, b[2], b[1], 57); + MIX2(b[0], b[1], 23, b[2], b[3], 40); + MIX2(b[0], b[3], 5, b[2], b[1], 37); + MIXK(b[0], b[1], 25, b[2], b[3], 33, k[3], k[4], k[0], k[1]+3); + + MIX2(b[0], b[3], 46, b[2], b[1], 12); + MIX2(b[0], b[1], 58, b[2], b[3], 22); + MIX2(b[0], b[3], 32, b[2], b[1], 32); + + MIXK(b[0], b[1], 14, b[2], b[3], 16, k[4], k[0], k[1], k[2]+4); + MIX2(b[0], b[3], 52, b[2], b[1], 57); + MIX2(b[0], b[1], 23, b[2], b[3], 40); + MIX2(b[0], b[3], 5, b[2], b[1], 37); + + for (unsigned int i=0; i<4; ++i) _o[i] = b[i] + k[i]; + _o[3] += 5; + } + + void inc_counter() + { + ++_s[0]; + if (_s[0] != 0) return; + + ++_s[1]; + if (_s[1] != 0) return; + + ++_s[2]; + if (_s[2] != 0) return; + + ++_s[3]; + } + + void inc_counter(uint64_t z) + { + if (z > 0xFFFFFFFFFFFFFFFF - _s[0]) { // check if we will overflow the first 64 bit int + ++_s[1]; + if (_s[1] == 0) { + ++_s[2]; + if (_s[2] == 0) { + ++_s[3]; + } + } + } + _s[0] += z; + } + +private: + uint64_t _k[4]; // key + uint64_t _s[4]; // state (counter) + uint64_t _o[4]; // cipher output 4 * 64 bit = 256 bit output + unsigned short _o_counter; // output chunk counter, the 256 random bits in _o + // are returned in eight 32 bit chunks +}; + + +} // namespace sitmo + +#undef MIXK +#undef MIX2 + +#endif \ No newline at end of file diff --git a/scripts/filelist b/scripts/filelist index 1ab95c7c..38e8ea94 100755 --- a/scripts/filelist +++ b/scripts/filelist @@ -4,13 +4,16 @@ home=`pwd` # library Make.inc cd $home/lib -HFILES=`find . -type f -name '*.h' -not -path '*/Old/*' -not -path '*/Eigen/*'` +HFILES=`find . -type f -name '*.h' -not -name '*Hdf5*' -not -path '*/gamma-gen/*' -not -path '*/Old/*' -not -path '*/Eigen/*'` HFILES="$HFILES" -CCFILES=`find . -type f -name '*.cc' -not -name '*ommunicator*.cc'` -echo HFILES=$HFILES > Make.inc +CCFILES=`find . -type f -name '*.cc' -not -path '*/gamma-gen/*' -not -name '*Communicator*.cc' -not -name '*Hdf5*'` +HPPFILES=`find . -type f -name '*.hpp'` +echo HFILES=$HFILES $HPPFILES > Make.inc echo >> Make.inc echo CCFILES=$CCFILES >> Make.inc + + # tests Make.inc cd $home/tests dirs=`find . -type d -not -path '*/\.*'` diff --git a/tests/IO/Test_serialisation.cc b/tests/IO/Test_serialisation.cc index e23aa1a3..8204b05b 100644 --- a/tests/IO/Test_serialisation.cc +++ b/tests/IO/Test_serialisation.cc @@ -28,130 +28,152 @@ Author: Peter Boyle /* END LEGAL */ #include -namespace Grid { - - GRID_SERIALIZABLE_ENUM(myenum, undef, red, 1, blue, 2, green, 3); - - class myclass: Serializable { - public: - - GRID_SERIALIZABLE_CLASS_MEMBERS(myclass, - myenum, e, - std::vector, ve, - std::string, name, - int, x, - double, y, - bool , b, - std::vector, array, - std::vector>, twodimarray, - ); - - myclass() {} - myclass(int i) - : array(4,5.1), twodimarray(3,std::vector(2,1.23456)), ve(2, myenum::blue) - { - e=myenum::red; - x=i; - y=2*i; - b=true; - name="bother said pooh"; - } - }; - -} - using namespace Grid; -int16_t i16 = 1; +GRID_SERIALIZABLE_ENUM(myenum, undef, red, 1, blue, 2, green, 3); + +class myclass: Serializable { +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(myclass, + myenum, e, + std::vector, ve, + std::string, name, + int, x, + double, y, + bool , b, + std::vector, array, + std::vector>, twodimarray, + std::vector>>, cmplx3darray + ); + myclass() {} + myclass(int i) + : array(4,5.1) + , twodimarray(3,std::vector(5, 1.23456)) + , cmplx3darray(3,std::vector>(5, std::vector(7, Complex(1.2, 3.4)))) + , ve(2, myenum::blue) + { + e=myenum::red; + x=i; + y=2*i; + b=true; + name="bother said pooh"; + } +}; + +int16_t i16 = 1; uint16_t u16 = 2; -int32_t i32 = 3; +int32_t i32 = 3; uint32_t u32 = 4; -int64_t i64 = 5; +int64_t i64 = 5; uint64_t u64 = 6; -float f = M_PI; -double d = 2*M_PI; -bool b = false; +float f = M_PI; +double d = 2*M_PI; +bool b = false; + +template +void ioTest(const std::string &filename, const O &object, const std::string &name) +{ + // writer needs to be destroyed so that writing physically happens + { + W writer(filename); + + write(writer, "testobject", object); + } + + R reader(filename); + O buf; + bool good; + + read(reader, "testobject", buf); + good = (object == buf); + std::cout << name << " IO test: " << (good ? "success" : "failure"); + std::cout << std::endl; + if (!good) exit(EXIT_FAILURE); +} int main(int argc,char **argv) { - { - XmlWriter WR("bother.xml"); - - // test basic type writing - push(WR,"BasicTypes"); - write(WR,std::string("i16"),i16); - write(WR,"u16",u16); - write(WR,"i32",i32); - write(WR,"u32",u32); - write(WR,"i64",i64); - write(WR,"u64",u64); - write(WR,"f",f); - write(WR,"d",d); - write(WR,"b",b); - pop(WR); - - // test serializable class writing - myclass obj(1234); // non-trivial constructor - write(WR,"obj",obj); - WR.write("obj2", obj); - std::cout << obj << std::endl; - - std::vector vec; - vec.push_back(myclass(1234)); - vec.push_back(myclass(5678)); - vec.push_back(myclass(3838)); - write(WR, "objvec", vec); - }; + std::cout << "==== basic IO" << std::endl; + XmlWriter WR("bother.xml"); + + // test basic type writing + std::cout << "-- basic writing to 'bother.xml'..." << std::endl; + push(WR,"BasicTypes"); + write(WR,std::string("i16"),i16); + write(WR,"u16",u16); + write(WR,"i32",i32); + write(WR,"u32",u32); + write(WR,"i64",i64); + write(WR,"u64",u64); + write(WR,"f",f); + write(WR,"d",d); + write(WR,"b",b); + pop(WR); + + // test serializable class writing + myclass obj(1234); // non-trivial constructor + std::vector vec; + + std::cout << "-- serialisable class writing to 'bother.xml'..." << std::endl; + write(WR,"obj",obj); + WR.write("obj2", obj); + vec.push_back(myclass(1234)); + vec.push_back(myclass(5678)); + vec.push_back(myclass(3838)); + write(WR, "objvec", vec); + std::cout << "-- serialisable class writing to std::cout:" << std::endl; + std::cout << obj << std::endl; + std::cout << "-- serialisable class comparison:" << std::endl; + std::cout << "vec[0] == obj: " << ((vec[0] == obj) ? "true" : "false") << std::endl; + std::cout << "vec[1] == obj: " << ((vec[1] == obj) ? "true" : "false") << std::endl; // read tests - myclass copy1, copy2, copy3; - std::vector veccopy1, veccopy2, veccopy3; + std::cout << "\n==== IO self-consistency tests" << std::endl; //// XML - { - XmlReader RD("bother.xml"); - read(RD,"obj",copy1); - read(RD,"objvec", veccopy1); - std::cout << "Loaded (XML) -----------------" << std::endl; - std::cout << copy1 << std::endl << veccopy1 << std::endl; - } + ioTest("iotest.xml", obj, "XML (object) "); + ioTest("iotest.xml", vec, "XML (vector of objects)"); //// binary - { - BinaryWriter BWR("bother.bin"); - write(BWR,"discard",copy1 ); - write(BWR,"discard",veccopy1 ); - } - { - BinaryReader BRD("bother.bin"); - read (BRD,"discard",copy2 ); - read (BRD,"discard",veccopy2 ); - std::cout << "Loaded (bin) -----------------" << std::endl; - std::cout << copy2 << std::endl << veccopy2 << std::endl; - } + ioTest("iotest.bin", obj, "binary (object) "); + ioTest("iotest.bin", vec, "binary (vector of objects)"); //// text - { - TextWriter TWR("bother.txt"); - write(TWR,"discard",copy1 ); - write(TWR,"discard",veccopy1 ); - } - { - TextReader TRD("bother.txt"); - read (TRD,"discard",copy3 ); - read (TRD,"discard",veccopy3 ); - std::cout << "Loaded (txt) -----------------" << std::endl; - std::cout << copy3 << std::endl << veccopy3 << std::endl; - } + ioTest("iotest.dat", obj, "text (object) "); + ioTest("iotest.dat", vec, "text (vector of objects)"); + //// HDF5 +#ifdef HAVE_HDF5 + ioTest("iotest.h5", obj, "HDF5 (object) "); + ioTest("iotest.h5", vec, "HDF5 (vector of objects)"); +#endif - std::vector iv = strToVec("1 2 2 4"); - std::vector sv = strToVec("bli bla blu"); + std::cout << "\n==== vector flattening/reconstruction" << std::endl; + typedef std::vector>> vec3d; - for (auto &e: iv) + vec3d dv, buf; + double d = 0.; + + dv.resize(4); + for (auto &v1: dv) { - std::cout << e << " "; + v1.resize(3); + for (auto &v2: v1) + { + v2.resize(5); + for (auto &x: v2) + { + x = d++; + } + } } - std::cout << std::endl; - for (auto &e: sv) - { - std::cout << e << " "; - } - std::cout << std::endl; + std::cout << "original 3D vector:" << std::endl; + std::cout << dv << std::endl; + + Flatten flatdv(dv); + + std::cout << "\ndimensions:" << std::endl; + std::cout << flatdv.getDim() << std::endl; + std::cout << "\nflattened vector:" << std::endl; + std::cout << flatdv.getFlatVector() << std::endl; + + Reconstruct rec(flatdv.getFlatVector(), flatdv.getDim()); + std::cout << "\nreconstructed vector:" << std::endl; + std::cout << flatdv.getVector() << std::endl; } diff --git a/tests/Test_cayley_even_odd_vec.cc b/tests/Test_cayley_even_odd_vec.cc index e7f85b4e..fc271001 100644 --- a/tests/Test_cayley_even_odd_vec.cc +++ b/tests/Test_cayley_even_odd_vec.cc @@ -36,12 +36,12 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT - }; + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT + }; typedef DomainWallFermion DomainWallVecFermionR; typedef ZMobiusFermion ZMobiusVecFermionR; @@ -340,7 +340,7 @@ void TestMoo(This & Dw, That &sDw) LatticeFermion ndiff(ngrid); LatticeFermion sdiff(sgrid); - Gamma g5( Gamma::Gamma5 ); + Gamma g5( Gamma::Algebra::Gamma5 ); std::vector seeds({1,2,3,4,5,7,8}); GridParallelRNG RNG5(ngrid); diff --git a/tests/Test_dwf_mixedcg_prec.cc b/tests/Test_dwf_mixedcg_prec.cc index 56394a5e..2601b76c 100644 --- a/tests/Test_dwf_mixedcg_prec.cc +++ b/tests/Test_dwf_mixedcg_prec.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/core/Test_cf_coarsen_support.cc b/tests/core/Test_cf_coarsen_support.cc index 325cc3a5..fab8c97c 100644 --- a/tests/core/Test_cf_coarsen_support.cc +++ b/tests/core/Test_cf_coarsen_support.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/core/Test_checker.cc b/tests/core/Test_checker.cc index a974965b..56b0eb60 100644 --- a/tests/core/Test_checker.cc +++ b/tests/core/Test_checker.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int toint(const char* str){ diff --git a/tests/core/Test_contfrac_even_odd.cc b/tests/core/Test_contfrac_even_odd.cc index 28f56797..4698f2b9 100644 --- a/tests/core/Test_contfrac_even_odd.cc +++ b/tests/core/Test_contfrac_even_odd.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; diff --git a/tests/core/Test_dwf_even_odd.cc b/tests/core/Test_dwf_even_odd.cc index 5c60d84b..8fa3f1d1 100644 --- a/tests/core/Test_dwf_even_odd.cc +++ b/tests/core/Test_dwf_even_odd.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; diff --git a/tests/core/Test_dwf_rb5d.cc b/tests/core/Test_dwf_rb5d.cc index ab9e4d6e..a3099c7c 100644 --- a/tests/core/Test_dwf_rb5d.cc +++ b/tests/core/Test_dwf_rb5d.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; typedef WilsonFermion5D WilsonFermion5DR; diff --git a/tests/core/Test_fft.cc b/tests/core/Test_fft.cc index 03c8bc52..877683f0 100644 --- a/tests/core/Test_fft.cc +++ b/tests/core/Test_fft.cc @@ -177,7 +177,7 @@ int main (int argc, char ** argv) const int sdir=0; RealD mass=0.01; RealD M5 =1.0; - Gamma G5(Gamma::Gamma5); + Gamma G5(Gamma::Algebra::Gamma5); GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,&GRID); GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,&GRID); @@ -218,12 +218,12 @@ int main (int argc, char ** argv) ///////////////////////////////////////////////////////////////// // work out the predicted from Fourier ///////////////////////////////////////////////////////////////// - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT, - Gamma::Gamma5 + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT, + Gamma::Algebra::Gamma5 }; LatticeFermionD Kinetic(FGrid); Kinetic = zero; LatticeComplexD kmu(FGrid); @@ -311,7 +311,7 @@ int main (int argc, char ** argv) std::cout << " Solving by FFT and Feynman rules" < Author: Peter Boyle +Author: Antonin Portelli - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - See the full license in the file "LICENSE" in the top level distribution directory - *************************************************************************************/ +See the full license in the file "LICENSE" in the top level distribution directory +*************************************************************************************/ /* END LEGAL */ #include using namespace std; using namespace Grid; -using namespace Grid::QCD; +using namespace QCD; -//template class is_pod< iScalar > -//{ -// -//}; +static constexpr double tolerance = 1.0e-6; +static std::array testAlgebra; -int main (int argc, char ** argv) +void print(const SpinMatrix &g) +{ + for(int i = 0; i < Ns; i++) + { + std::cout << GridLogMessage << "("; + for(int j=0;j testg; + SpinMatrix testg5; + const Complex I(0., 1.), mI(0., -1.); + + testg[0] = zero; + testg[0]()(0, 3) = I; + testg[0]()(1, 2) = I; + testg[0]()(2, 1) = mI; + testg[0]()(3, 0) = mI; + std::cout << GridLogMessage << "test GammaX= " << std::endl; + print(testg[0]); + testg[1] = zero; + testg[1]()(0, 3) = -1.; + testg[1]()(1, 2) = 1.; + testg[1]()(2, 1) = 1.; + testg[1]()(3, 0) = -1.; + std::cout << GridLogMessage << "test GammaY= " << std::endl; + print(testg[1]); + testg[2] = zero; + testg[2]()(0, 2) = I; + testg[2]()(1, 3) = mI; + testg[2]()(2, 0) = mI; + testg[2]()(3, 1) = I; + std::cout << GridLogMessage << "test GammaZ= " << std::endl; + print(testg[2]); + testg[3] = zero; + testg[3]()(0, 2) = 1.; + testg[3]()(1, 3) = 1.; + testg[3]()(2, 0) = 1.; + testg[3]()(3, 1) = 1.; + std::cout << GridLogMessage << "test GammaT= " << std::endl; + print(testg[3]); + testg5 = testg[0]*testg[1]*testg[2]*testg[3]; + +#define DEFINE_TEST_G(g, exp)\ +testAlgebra[Gamma::Algebra::g] = exp;\ +testAlgebra[Gamma::Algebra::Minus##g] = -exp;\ + + DEFINE_TEST_G(Identity , 1.); + DEFINE_TEST_G(Gamma5 , testg5); + DEFINE_TEST_G(GammaX , testg[0]); + DEFINE_TEST_G(GammaY , testg[1]); + DEFINE_TEST_G(GammaZ , testg[2]); + DEFINE_TEST_G(GammaT , testg[3]); + DEFINE_TEST_G(GammaXGamma5, testg[0]*testg5); + DEFINE_TEST_G(GammaYGamma5, testg[1]*testg5); + DEFINE_TEST_G(GammaZGamma5, testg[2]*testg5); + DEFINE_TEST_G(GammaTGamma5, testg[3]*testg5); + DEFINE_TEST_G(SigmaXY , .5*(testg[0]*testg[1] - testg[1]*testg[0])); + DEFINE_TEST_G(SigmaXZ , .5*(testg[0]*testg[2] - testg[2]*testg[0])); + DEFINE_TEST_G(SigmaXT , .5*(testg[0]*testg[3] - testg[3]*testg[0])); + DEFINE_TEST_G(SigmaYZ , .5*(testg[1]*testg[2] - testg[2]*testg[1])); + DEFINE_TEST_G(SigmaYT , .5*(testg[1]*testg[3] - testg[3]*testg[1])); + DEFINE_TEST_G(SigmaZT , .5*(testg[2]*testg[3] - testg[3]*testg[2])); + +#undef DEFINE_TEST_G +} + +template +void test(const Expr &a, const Expr &b) +{ + if (norm2(a - b) < tolerance) + { + std::cout << "[OK] "; + } + else + { + std::cout << "[fail]" << std::endl; + std::cout << GridLogError << "a= " << a << std::endl; + std::cout << GridLogError << "is different (tolerance= " << tolerance << ") from " << std::endl; + std::cout << GridLogError << "b= " << b << std::endl; + exit(EXIT_FAILURE); + } +} + +void checkGamma(const Gamma::Algebra a, GridSerialRNG &rng) +{ + SpinVector v; + SpinMatrix m, &testg = testAlgebra[a]; + Gamma g(a); + bool pass = true; + + random(rng, v); + random(rng, m); + + std::cout << GridLogMessage << "Checking " << Gamma::name[a] << ": "; + std::cout << "vecmul "; + test(g*v, testg*v); + std::cout << "matlmul "; + test(g*m, testg*m); + std::cout << "matrmul "; + test(m*g, m*testg); + std::cout << std::endl; +} + +void checkProd(const Gamma::Algebra a, const Gamma::Algebra b) +{ + SpinMatrix gm, testg = testAlgebra[a]*testAlgebra[b]; + Gamma g = Gamma(a)*Gamma(b); + bool pass = true; + + std::cout << GridLogMessage << "Checking " << Gamma::name[a] << " * " + << Gamma::name[b] << ": "; + gm = 1.0; + gm = g*gm; + test(gm, testg); + std::cout << "(= " << Gamma::name[g.g] << ")" << std::endl; +} + +void checkAdj(const Gamma::Algebra a) +{ + SpinMatrix gm, testg = adj(testAlgebra[a]); + Gamma g(adj(Gamma(a))); + bool pass = true; + + std::cout << GridLogMessage << "Checking adj(" << Gamma::name[a] << "): "; + gm = 1.0; + gm = g*gm; + test(gm, testg); + std::cout << "(= " << Gamma::name[g.g] << ")" << std::endl; +} + +void checkProject(GridSerialRNG &rng) +{ + SpinVector rv, recon, full; + HalfSpinVector hsp, hsm; + + random(rng, rv); + +#define CHECK_PROJ(dir, gamma)\ +std::cout << GridLogMessage << "Checking " << #dir << " projector: ";\ +spProj##dir(hsm,rv);\ +spRecon##dir(recon,hsm);\ +test(recon, rv + Gamma(Gamma::Algebra::gamma)*rv);\ +std::cout << std::endl; + + CHECK_PROJ(Xp, GammaX); + CHECK_PROJ(Yp, GammaY); + CHECK_PROJ(Zp, GammaZ); + CHECK_PROJ(Tp, GammaT); + CHECK_PROJ(5p, Gamma5); + CHECK_PROJ(Xm, MinusGammaX); + CHECK_PROJ(Ym, MinusGammaY); + CHECK_PROJ(Zm, MinusGammaZ); + CHECK_PROJ(Tm, MinusGammaT); + CHECK_PROJ(5m, MinusGamma5); + +#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); - + std::vector latt_size = GridDefaultLatt(); std::vector simd_layout = GridDefaultSimd(4,vComplex::Nsimd()); std::vector mpi_layout = GridDefaultMpi(); - - GridCartesian Grid(latt_size,simd_layout,mpi_layout); - - GridParallelRNG pRNG(&Grid); - pRNG.SeedRandomDevice(); - - GridSerialRNG sRNG; + + GridCartesian Grid(latt_size,simd_layout,mpi_layout); + GridSerialRNG sRNG; + sRNG.SeedRandomDevice(); - - SpinMatrix ident; ident=zero; - SpinMatrix rnd ; random(sRNG,rnd); - - SpinMatrix ll; ll=zero; - SpinMatrix rr; rr=zero; - SpinMatrix result; - - SpinVector lv; random(sRNG,lv); - SpinVector rv; random(sRNG,rv); - - // std::cout<::value << std::endl; - // std::cout<::value << std::endl; - // std::cout<::value << std::endl; - // std::cout<::value << std::endl; - // std::cout<::value << std::endl; - // std::cout< " << std::is_pod >::value << std::endl; - // std::cout< " << std::is_pod >::value << std::endl; - // std::cout< " << std::is_pod >::value << std::endl; - // std::cout< " << std::is_pod >::value << std::endl; - // std::cout< " << std::is_pod >::value << std::endl; - // std::cout< " << std::is_pod >::value << std::endl; - // std::cout< " < >::value << std::endl; - // std::cout< "< >::value << std::endl; - - for(int a=0;a diff --git a/tests/debug/Test_cayley_coarsen_support.cc b/tests/debug/Test_cayley_coarsen_support.cc index 9c740b8b..2d503df8 100644 --- a/tests/debug/Test_cayley_coarsen_support.cc +++ b/tests/debug/Test_cayley_coarsen_support.cc @@ -38,11 +38,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/debug/Test_cayley_even_odd.cc b/tests/debug/Test_cayley_even_odd.cc index 5c15450c..7d8d2a12 100644 --- a/tests/debug/Test_cayley_even_odd.cc +++ b/tests/debug/Test_cayley_even_odd.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; diff --git a/tests/hadrons/Makefile.am b/tests/hadrons/Makefile.am index fae0d212..c8ec1612 100644 --- a/tests/hadrons/Makefile.am +++ b/tests/hadrons/Makefile.am @@ -1,3 +1,3 @@ -AM_LDFLAGS += -L../../extras/hadrons +AM_LDFLAGS += -L../../extras/Hadrons include Make.inc diff --git a/tests/hadrons/Test_hadrons_meson_3pt.cc b/tests/hadrons/Test_hadrons_meson_3pt.cc index 56d0efa7..da7ddb84 100644 --- a/tests/hadrons/Test_hadrons_meson_3pt.cc +++ b/tests/hadrons/Test_hadrons_meson_3pt.cc @@ -30,6 +30,14 @@ using namespace Grid; using namespace Hadrons; +static Gamma::Algebra gmu[4] = +{ + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT +}; + int main(int argc, char *argv[]) { // initialization ////////////////////////////////////////////////////////// @@ -102,7 +110,7 @@ int main(int argc, char *argv[]) seqName.push_back(std::vector(Nd)); for (unsigned int mu = 0; mu < Nd; ++mu) { - seqPar.gamma = 0x1 << mu; + seqPar.gamma = gmu[mu]; seqName[i][mu] = "G" + std::to_string(seqPar.gamma) + "_" + std::to_string(seqPar.tA) + "-" + qName[i]; @@ -127,9 +135,11 @@ int main(int argc, char *argv[]) for (unsigned int i = 0; i < flavour.size(); ++i) for (unsigned int j = i; j < flavour.size(); ++j) { - mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j]; - mesPar.q1 = qName[i]; - mesPar.q2 = qName[j]; + mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j]; + mesPar.q1 = qName[i]; + mesPar.q2 = qName[j]; + mesPar.gammaSource = Gamma::Algebra::Gamma5; + mesPar.gammaSink = Gamma::Algebra::Gamma5; application.createModule("meson_Z2_" + std::to_string(t) + "_" diff --git a/tests/qdpxx/Test_qdpxx_loops_staples.cc b/tests/qdpxx/Test_qdpxx_loops_staples.cc index c5999065..cf2e0796 100644 --- a/tests/qdpxx/Test_qdpxx_loops_staples.cc +++ b/tests/qdpxx/Test_qdpxx_loops_staples.cc @@ -25,7 +25,7 @@ Author: Azusa Yamaguchi See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#include +#include double calc_grid_p (Grid::QCD::LatticeGaugeField & lat); double calc_chroma_p (Grid::QCD::LatticeGaugeField & lat); diff --git a/tests/qdpxx/Test_qdpxx_munprec.cc b/tests/qdpxx/Test_qdpxx_munprec.cc index 2f847702..fd60566d 100644 --- a/tests/qdpxx/Test_qdpxx_munprec.cc +++ b/tests/qdpxx/Test_qdpxx_munprec.cc @@ -26,7 +26,7 @@ Author: paboyle See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#include +#include int Ls=8; double M5=1.6; diff --git a/tests/solver/Test_cf_cr_unprec.cc b/tests/solver/Test_cf_cr_unprec.cc index 59031ba8..d7d8f51a 100644 --- a/tests/solver/Test_cf_cr_unprec.cc +++ b/tests/solver/Test_cf_cr_unprec.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_contfrac_cg.cc b/tests/solver/Test_contfrac_cg.cc index 5e495071..13f80f69 100644 --- a/tests/solver/Test_contfrac_cg.cc +++ b/tests/solver/Test_contfrac_cg.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; diff --git a/tests/solver/Test_dwf_cg_prec.cc b/tests/solver/Test_dwf_cg_prec.cc index d248c560..30436e36 100644 --- a/tests/solver/Test_dwf_cg_prec.cc +++ b/tests/solver/Test_dwf_cg_prec.cc @@ -37,8 +37,8 @@ struct scal { d internal; }; -Gamma::GammaMatrix Gmu[] = {Gamma::GammaX, Gamma::GammaY, Gamma::GammaZ, - Gamma::GammaT}; +Gamma::Algebra Gmu[] = {Gamma::Algebra::GammaX, Gamma::Algebra::GammaY, Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT}; int main(int argc, char** argv) { Grid_init(&argc, &argv); diff --git a/tests/solver/Test_dwf_cg_schur.cc b/tests/solver/Test_dwf_cg_schur.cc index 75ca3521..62a95235 100644 --- a/tests/solver/Test_dwf_cg_schur.cc +++ b/tests/solver/Test_dwf_cg_schur.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_dwf_cg_unprec.cc b/tests/solver/Test_dwf_cg_unprec.cc index 41a05042..89e9088e 100644 --- a/tests/solver/Test_dwf_cg_unprec.cc +++ b/tests/solver/Test_dwf_cg_unprec.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_dwf_cr_unprec.cc b/tests/solver/Test_dwf_cr_unprec.cc index 9ee38d35..7549137a 100644 --- a/tests/solver/Test_dwf_cr_unprec.cc +++ b/tests/solver/Test_dwf_cr_unprec.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_dwf_fpgcr.cc b/tests/solver/Test_dwf_fpgcr.cc index 3b0f99d0..aaf622b9 100644 --- a/tests/solver/Test_dwf_fpgcr.cc +++ b/tests/solver/Test_dwf_fpgcr.cc @@ -38,11 +38,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_dwf_hdcr.cc b/tests/solver/Test_dwf_hdcr.cc index 313b2077..64ca0b33 100644 --- a/tests/solver/Test_dwf_hdcr.cc +++ b/tests/solver/Test_dwf_hdcr.cc @@ -504,7 +504,7 @@ int main (int argc, char ** argv) GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4); GridParallelRNG CRNG(Coarse5d);CRNG.SeedFixedIntegers(cseeds); - Gamma g5(Gamma::Gamma5); + Gamma g5(Gamma::Algebra::Gamma5); LatticeFermion src(FGrid); gaussian(RNG5,src);// src=src+g5*src; LatticeFermion result(FGrid); result=zero; diff --git a/tests/solver/Test_wilson_cg_prec.cc b/tests/solver/Test_wilson_cg_prec.cc index 7cc9d574..e336161f 100644 --- a/tests/solver/Test_wilson_cg_prec.cc +++ b/tests/solver/Test_wilson_cg_prec.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_wilson_cg_schur.cc b/tests/solver/Test_wilson_cg_schur.cc index 1ea6a07c..8b62b040 100644 --- a/tests/solver/Test_wilson_cg_schur.cc +++ b/tests/solver/Test_wilson_cg_schur.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_wilson_cg_unprec.cc b/tests/solver/Test_wilson_cg_unprec.cc index 34b0a687..bb429468 100644 --- a/tests/solver/Test_wilson_cg_unprec.cc +++ b/tests/solver/Test_wilson_cg_unprec.cc @@ -37,11 +37,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv) diff --git a/tests/solver/Test_wilson_cr_unprec.cc b/tests/solver/Test_wilson_cr_unprec.cc index 4a517461..add5c2ba 100644 --- a/tests/solver/Test_wilson_cr_unprec.cc +++ b/tests/solver/Test_wilson_cr_unprec.cc @@ -36,11 +36,11 @@ struct scal { d internal; }; - Gamma::GammaMatrix Gmu [] = { - Gamma::GammaX, - Gamma::GammaY, - Gamma::GammaZ, - Gamma::GammaT + Gamma::Algebra Gmu [] = { + Gamma::Algebra::GammaX, + Gamma::Algebra::GammaY, + Gamma::Algebra::GammaZ, + Gamma::Algebra::GammaT }; int main (int argc, char ** argv)