Grid 0.7.0
hmc_types.h
Go to the documentation of this file.
1#ifndef HMC_TYPES_H
2#define HMC_TYPES_H
3
8
9#include <tuple>
10#include <utility>
11
13
14// Supported types
15// enum {Fundamental, Adjoint} repr_type;
16// Utility to add support to the HMC for representations other than the
17// fundamental
18template <class... Reptypes>
20public:
21 typedef std::tuple<Reptypes...> Representation_type;
22
23 // Size of the tuple, known at compile time
24 static const int tuple_size = sizeof...(Reptypes);
25 // The collection of types for the gauge fields
26 typedef std::tuple<typename Reptypes::LatticeField...> Representation_Fields;
27
28 // To access the Reptypes (FundamentalRepresentation, AdjointRepresentation)
29 template <std::size_t N>
30 using repr_type = typename std::tuple_element<N, Representation_type>::type;
31 // in order to get the typename of the field use
32 // type repr_type<I>::LatticeField
33
35
36 // Multiple types constructor
37 explicit Representations(GridBase* grid) : rep(Reptypes(grid)...){};
38
39 int size() { return tuple_size; }
40
41 // update the fields
42 // fields in the main representation always the first in the list
43 // get the field type
44 typedef typename std::tuple_element<0,Representation_Fields>::type LatticeSourceField;
45
46 template <std::size_t I = 0>
47 inline typename std::enable_if<(I == tuple_size), void>::type update(
49
50 template <std::size_t I = 0>
51 inline typename std::enable_if<(I < tuple_size), void>::type update(
53 std::get<I>(rep).update_representation(U);
55 }
56
57
58
59};
60
64
65template < int Colours>
67
68// Helper classes to access the elements
69// Strips the first N parameters from the tuple
70// sequence of classes to obtain the S sequence
71// Creates a type that is a tuple of vectors of the template type A
72template <template <typename> class A, class TupleClass,
73 size_t N = TupleClass::tuple_size, size_t... S>
74struct AccessTypes : AccessTypes<A, TupleClass, N - 1, N - 1, S...> {};
75
76template <template <typename> class A, class TupleClass, size_t... S>
77struct AccessTypes<A, TupleClass, 0, S...> {
78public:
79 typedef typename TupleClass::Representation_Fields Rfields;
80
81 template <std::size_t N>
82 using elem = typename std::tuple_element<N, Rfields>::type; // fields types
83
84 typedef std::tuple<std::vector< A< elem<S> >* > ... > VectorCollection;
85 typedef std::tuple< elem<S> ... > FieldTypeCollection;
86
87 // Debug
88 void return_size() {
89 std::cout << GridLogMessage
90 << "Access:" << std::tuple_size<std::tuple<elem<S>...> >::value
91 << "\n";
92 std::cout << GridLogMessage
93 << "Access vectors:" << std::tuple_size<VectorCollection>::value
94 << "\n";
95 }
96};
97
99
100#endif
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
typename std::tuple_element< N, Representation_type >::type repr_type
Definition hmc_types.h:30
std::enable_if<(I==tuple_size), void >::type update(LatticeSourceField &U)
Definition hmc_types.h:47
std::tuple< typename Reptypes::LatticeField... > Representation_Fields
Definition hmc_types.h:26
std::tuple< Reptypes... > Representation_type
Definition hmc_types.h:21
std::enable_if<(I< tuple_size), void >::type update(LatticeSourceField &U)
Definition hmc_types.h:51
std::tuple_element< 0, Representation_Fields >::type LatticeSourceField
Definition hmc_types.h:44
Representations(GridBase *grid)
Definition hmc_types.h:37
Representations< FundamentalRepresentation > NoHirep
Definition hmc_types.h:61
Representations< EmptyRep< typename ScalarImplR::Field > > ScalarFields
Definition hmc_types.h:62
Representations< EmptyRep< typename ScalarAdjImplR::Field > > ScalarMatrixFields
Definition hmc_types.h:63
Representations< EmptyRep< typename ScalarNxNAdjImplR< Colours >::Field > > ScalarNxNMatrixFields
Definition hmc_types.h:66
std::tuple< elem< S > ... > FieldTypeCollection
Definition hmc_types.h:85
typename std::tuple_element< N, Rfields >::type elem
Definition hmc_types.h:82
TupleClass::Representation_Fields Rfields
Definition hmc_types.h:79
std::tuple< std::vector< A< elem< S > > * > ... > VectorCollection
Definition hmc_types.h:84