1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-08-03 21:27:07 +01:00

Modified the Dirac Kernel class to compile with different number of colours

Added the general push_back functionality to accomodate for all defined representations

Compiles, not tested
This commit is contained in:
Guido Cossu
2016-07-18 16:36:28 +01:00
parent 9c77bb69a5
commit b93e18ed50
12 changed files with 579 additions and 425 deletions

View File

@@ -66,6 +66,20 @@ Phi(&_Grid), pRNG(_pRNG) {
};
*/
// Indexing of tuple types
template <class T, class Tuple>
struct Index;
template <class T, class... Types>
struct Index<T, std::tuple<T, Types...>> {
static const std::size_t value = 0;
};
template <class T, class U, class... Types>
struct Index<T, std::tuple<U, Types...>> {
static const std::size_t value = 1 + Index<T, std::tuple<Types...>>::value;
};
template <class GaugeField>
struct ActionLevel {
public:
@@ -99,38 +113,39 @@ struct ActionLevelHirep {
// representation fields
typedef typename AccessTypes<Action, Repr>::VectorCollection action_collection;
action_collection actions_hirep;
typedef typename AccessTypes<Action, Repr>::ClassCollection actions_hirep_ptrs_type;
typedef typename AccessTypes<Action, Repr>::FieldTypeCollection action_hirep_types;
std::vector<ActPtr>& actions;
// Temporary conversion between ActionLevel and ActionLevelHirep
ActionLevelHirep(ActionLevel<GaugeField>& AL ):actions(AL.actions), multiplier(AL.multiplier){}
ActionLevelHirep(unsigned int mul = 1) : actions(std::get<0>(actions_hirep)), multiplier(mul) {
// initialize the hirep vectors to zero.
//apply(this->resize, actions_hirep, 0); //need a working resize
assert(mul >= 1);
};
void push_back(ActPtr ptr) { actions.push_back(ptr); }
//void push_back(ActPtr ptr) { actions.push_back(ptr); }
// SFINAE construct, check
template <class actionpointer, size_t N>
void push_back(actionpointer ptr, decltype(std::tuple_element<N, actions_hirep_ptrs_type>::value)* = 0) {
//insert only in the correct vector
std::get<N>(actions_hirep).push_back(ptr);
template < class Field >
void push_back(Action<Field>* ptr) {
// insert only in the correct vector
std::get< Index < Field, action_hirep_types>::value >(actions_hirep).push_back(ptr);
};
template < class ActPtr>
static void resize(ActPtr ap, unsigned int n){
ap->resize(n);
}
template <std::size_t I>
auto getRepresentation(Repr& R)->decltype(std::get<I>(R).U) {return std::get<I>(R).U;}
//template <std::size_t I>
//auto getRepresentation(Repr& R)->decltype(std::get<I>(R).U) {return std::get<I>(R).U;}
// Loop on tuple for a callable function
template <std::size_t I = 1, typename Callable, typename ...Args>