mirror of
https://github.com/paboyle/Grid.git
synced 2025-06-17 23:37:06 +01:00
Added HMC utitities for the higher representations
TODO: Inherit types for the pseudofermions, Debugging, testing
This commit is contained in:
@ -21,14 +21,15 @@ class AdjointRep {
|
||||
public:
|
||||
// typdef to be used by the Representations class in HMC to get the
|
||||
// types for the higher representation fields
|
||||
typedef typename SU_Adjoint<ncolour>::LatticeAdjMatrix LatticeField;
|
||||
typedef typename SU_Adjoint<ncolour>::LatticeAdjMatrix LatticeMatrix;
|
||||
typedef typename SU_Adjoint<ncolour>::LatticeAdjField LatticeField;
|
||||
const int Dimension = ncolour * ncolour - 1;
|
||||
|
||||
LatticeField U;
|
||||
|
||||
|
||||
explicit AdjointRep(GridBase* grid) : U(grid) {}
|
||||
LatticeField update_representation(const LatticeGaugeField& Uin) {
|
||||
void update_representation(const LatticeGaugeField& Uin) {
|
||||
// Uin is in the fundamental representation
|
||||
// get the U in AdjointRep
|
||||
// (U_adj)_B = tr[e^a U e^b U^dag]
|
||||
|
@ -22,7 +22,8 @@ class FundamentalRep {
|
||||
|
||||
// typdef to be used by the Representations class in HMC to get the
|
||||
// types for the higher representation fields
|
||||
typedef typename SU<ncolour>::LatticeMatrix LatticeField;
|
||||
typedef typename SU<ncolour>::LatticeMatrix LatticeMatrix;
|
||||
typedef LatticeGaugeField LatticeField;
|
||||
|
||||
explicit FundamentalRep(GridBase* grid) {} //do nothing
|
||||
void update_representation(const LatticeGaugeField& Uin) {} // do nothing
|
||||
|
@ -1,61 +1,90 @@
|
||||
#ifndef HMC_TYPES_H
|
||||
#define HMC_TYPES_H
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <qcd/representations/adjoint.h>
|
||||
#include <qcd/representations/fundamental.h>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
|
||||
// Supported types
|
||||
//enum {Fundamental, Adjoint} repr_type;
|
||||
// enum {Fundamental, Adjoint} repr_type;
|
||||
|
||||
// Utility to add support to the HMC for representations other than the fundamental
|
||||
template<class... Reptypes>
|
||||
class Representations{
|
||||
public:
|
||||
// Utility to add support to the HMC for representations other than the
|
||||
// fundamental
|
||||
template <class... Reptypes>
|
||||
class Representations {
|
||||
public:
|
||||
typedef std::tuple<Reptypes...> Representation_type;
|
||||
|
||||
// Size of the tuple, known at compile time
|
||||
static const int tuple_size = sizeof...(Reptypes);
|
||||
// The collection of types for the gauge fields
|
||||
typedef std::tuple<typename Reptypes::LatticeField...> Representation_Fields;
|
||||
|
||||
// To access the Reptypes (FundamentalRepresentation, AdjointRepresentation)
|
||||
template <std::size_t N>
|
||||
using repr_type = typename std::tuple_element<N, Representation_type >::type;
|
||||
using repr_type = typename std::tuple_element<N, Representation_type>::type;
|
||||
// in order to get the typename of the field use
|
||||
// type repr_type::LatticeField
|
||||
|
||||
Representation_type rep;
|
||||
|
||||
// Multiple types constructor
|
||||
explicit Representations(GridBase *grid):rep(Reptypes(grid)...){};
|
||||
explicit Representations(GridBase* grid) : rep(Reptypes(grid)...){};
|
||||
|
||||
int size(){
|
||||
return std::tuple_size< Representation_type >::value;
|
||||
}
|
||||
int size() { return tuple_size; }
|
||||
|
||||
// update the fields
|
||||
template <std::size_t I = 0>
|
||||
inline typename std::enable_if< I == sizeof...(Reptypes), void >::type update(LatticeGaugeField& U) {}
|
||||
inline typename std::enable_if<(I == tuple_size), void>::type update(
|
||||
LatticeGaugeField& U) {}
|
||||
|
||||
template <std::size_t I = 0>
|
||||
inline typename std::enable_if <
|
||||
I<sizeof...(Reptypes), void>::type update(LatticeGaugeField& U) {
|
||||
inline typename std::enable_if<(I < tuple_size), void>::type update(
|
||||
LatticeGaugeField& U) {
|
||||
std::get<I>(rep).update_representation(U);
|
||||
update<I + 1>(U);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef Representations<FundamentalRepresentation> NoHirep;
|
||||
|
||||
typedef Representations<FundamentalRepresentation> JustTheFundamental;
|
||||
// Helper classes to access the elements
|
||||
// Strips the first N parameters from the tuple
|
||||
// sequence of classes to obtain the S sequence
|
||||
// Creates a type that is a tuple of vectors of the template type A
|
||||
template <template <typename> class A, class TupleClass,
|
||||
size_t N = TupleClass::tuple_size, size_t... S>
|
||||
struct AccessTypes : AccessTypes<A, TupleClass, N - 1, N - 1, S...> {};
|
||||
|
||||
template <template <typename> class A, class TupleClass, size_t... S>
|
||||
struct AccessTypes<A, TupleClass, 0, S...> {
|
||||
public:
|
||||
typedef typename TupleClass::Representation_Fields Rfields;
|
||||
|
||||
template <std::size_t N>
|
||||
using elem = typename std::tuple_element<N, Rfields>::type; // fields types
|
||||
|
||||
typedef std::tuple<std::vector< A< elem<S> >* > ... > VectorCollection;
|
||||
typedef std::tuple< A< elem<S> >* ... > ClassCollection;
|
||||
|
||||
// Debug
|
||||
void return_size() {
|
||||
std::cout << GridLogMessage
|
||||
<< "Access:" << std::tuple_size<std::tuple<elem<S>...> >::value
|
||||
<< "\n";
|
||||
std::cout << GridLogMessage
|
||||
<< "Access vectors:" << std::tuple_size<VectorCollection>::value
|
||||
<< "\n";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user