#ifndef _MODE_MAPPING_H #define _MODE_MAPPING_H CPS_START_NAMESPACE //As we dilute we unpack in the following order: spincolor , flavor, time. We assign these indices spincolor=3, flavor=2, time=1 template struct IndexConvention{}; template<> struct IndexConvention<3>{ static int getNidx(){ return 12; } static std::string getStr(){ return "spin-color"; } static void set(modeIndexSet &into, const int &val){ into.spin_color = val; } static const int & get(const modeIndexSet &from){ return from.spin_color; } }; template<> struct IndexConvention<2>{ static int getNidx(){ return GJP.Gparity() ? 2:1; } static std::string getStr(){ return "flavor"; } static void set(modeIndexSet &into, const int &val){ into.flavor = val; } static const int & get(const modeIndexSet &from){ return from.flavor; } }; template<> struct IndexConvention<1>{ static int getNidx(){ return GJP.Tnodes()*GJP.TnodeSites(); } static std::string getStr(){ return "time"; } static void set(modeIndexSet &into, const int &val){ into.time = val; } static const int & get(const modeIndexSet &from){ return from.time; } }; //To store an index mapping we need a large number of matrices typedef std::vector > ModeMapType; //Unmapping a single index template struct IndexVector{ typedef typename IndexVector::Type SubType; typedef std::vector Type; }; template<> struct IndexVector<0>{ typedef std::pair< std::vector, std::vector > Type; }; //We want a big set of nested vectors where the first Ldepth vectors are associated with the unmappings for the left index, and the remaining Rdepth with the right index template struct IndexTensor{ typedef typename IndexTensor::Type SubType; typedef std::vector Type; }; template struct IndexTensor<0,Rdepth>{ typedef typename IndexTensor<0,Rdepth-1>::Type SubType; typedef std::vector Type; }; template<> struct IndexTensor<0,0>{ typedef ModeMapType Type; //mode * mode }; template class ModeMapping{ public: enum { DepthPacked = PackedType::UndilutedIndices }; enum { DepthUnpacked = UnpackedType::UndilutedIndices }; typedef typename IndexVector::Type VectorTypePacked; typedef typename IndexVector::Type VectorTypeUnpacked; typedef typename IndexTensor::Type TensorType; static void compute(TensorType &idx_map, const A2Aparams &p); }; #include CPS_END_NAMESPACE #endif