QDP++
qdp_subset.h
Go to the documentation of this file.
1// -*- C++ -*-
5
6#ifndef QDP_SUBSET_H
7#define QDP_SUBSET_H
8
9namespace QDP {
10
20
21//-----------------------------------------------------------------------
24{
25public:
26 // Virtual destructor to stop compiler warnings - no cleanup needed
27 virtual ~SetFunc() {}
28 virtual int operator() (const multi1d<int>& coordinate) const = 0;
29 virtual int numSubsets() const = 0;
30};
31
32//-----------------------------------------------------------------------
33// Forward declaration
34class Set;
35
36//-----------------------------------------------------------------------
38class Subset
39{
40public:
42 Subset() {}
43
45 Subset(const Subset& s):
46 ordRep(s.ordRep), startSite(s.startSite), endSite(s.endSite),
47 sub_index(s.sub_index), sitetable(s.sitetable), set(s.set)
48 {}
49
50 // Simple constructor
51 void make(const Subset& s);
52
54 virtual ~Subset() {}
55
57 Subset& operator=(const Subset& s);
58
60 int color() const {return sub_index;}
61
62protected:
63 // Simple constructor
64 void make(bool rep, int start, int end, multi1d<int>* ind, int cb, Set* set);
65
66private:
67 bool ordRep;
68 int startSite;
69 int endSite;
70 int sub_index;
71
73 multi1d<int>* sitetable;
74
76 Set *set;
77
78public:
79 inline bool hasOrderedRep() const {return ordRep;}
80 inline int start() const {return startSite;}
81 inline int end() const {return endSite;}
82
83 const multi1d<int>& siteTable() const {return *sitetable;}
84 inline int numSiteTable() const {return sitetable->size();}
85
87 const Set& getSet() const { return *set; }
88
89 friend class Set;
90};
91
92
93//-----------------------------------------------------------------------
95class Set
96{
97public:
99 Set() {}
100
102 Set(const SetFunc& fn) {make(fn);}
103
105 void make(const SetFunc& fn);
106
108 const Subset& operator[](int subset_index) const {return sub[subset_index];}
109
111 int numSubsets() const {return sub.size();}
112
114 virtual ~Set() {}
115
117 Set& operator=(const Set& s);
118
119protected:
122
125
128
129public:
131 const multi1d<int>& latticeColoring() const {return lat_color;}
132};
133
134
135
136//-----------------------------------------------------------------------
138extern Subset all;
139
140
142extern Set rb3;
143
145extern Set rb;
146
148extern Set mcb;
149
151extern Subset even;
152
154extern Subset odd;
155
156 // end of group subsetss
158
159} // namespace QDP
160
161#endif
SetMap.
Definition qdp_subset.h:24
virtual ~SetFunc()
Definition qdp_subset.h:27
virtual int numSubsets() const =0
virtual int operator()(const multi1d< int > &coordinate) const =0
Set - collection of subsets controlling which sites are involved in an operation.
Definition qdp_subset.h:96
virtual ~Set()
Destructor for a set.
Definition qdp_subset.h:114
multi1d< int > lat_color
Index or color array of lattice.
Definition qdp_subset.h:124
Set & operator=(const Set &s)
The = operator.
void make(const SetFunc &fn)
Constructor from a function object.
int numSubsets() const
Return number of subsets.
Definition qdp_subset.h:111
multi1d< multi1d< int > > sitetables
Array of sitetable arrays.
Definition qdp_subset.h:127
multi1d< Subset > sub
A set is composed of an array of subsets.
Definition qdp_subset.h:121
const Subset & operator[](int subset_index) const
Index operator selects a subset from a set.
Definition qdp_subset.h:108
Set()
There can be an empty constructor.
Definition qdp_subset.h:99
const multi1d< int > & latticeColoring() const
The coloring of the lattice sites.
Definition qdp_subset.h:131
Set(const SetFunc &fn)
Constructor from a function object.
Definition qdp_subset.h:102
Subsets - controls how lattices are looped.
Definition qdp_subset.h:39
int end() const
Definition qdp_subset.h:81
Subset()
There can be an empty constructor.
Definition qdp_subset.h:42
Subset & operator=(const Subset &s)
The = operator.
int color() const
Access the coloring for this subset.
Definition qdp_subset.h:60
Subset(const Subset &s)
Copy constructor.
Definition qdp_subset.h:45
const multi1d< int > & siteTable() const
Definition qdp_subset.h:83
void make(const Subset &s)
Simple constructor called to produce a Subset from inside a Set.
virtual ~Subset()
Destructor for a subset.
Definition qdp_subset.h:54
int numSiteTable() const
Definition qdp_subset.h:84
friend class Set
Definition qdp_subset.h:89
bool hasOrderedRep() const
Definition qdp_subset.h:79
const Set & getSet() const
The super-set of this subset.
Definition qdp_subset.h:87
int start() const
Definition qdp_subset.h:80
Container for a multi-dimensional 1D array.
Definition qdp_multi.h:25
Set rb
Default 2-checkerboard (red/black) set.
Definition qdp_subset.cc:22
Set mcb
Default 2^{Nd+1}-checkerboard set. Useful for pure gauge updating.
Definition qdp_subset.cc:25
Set rb3
Default rb3 subset – Always unordered.
Definition qdp_subset.cc:19
Subset odd
Odd subset.
Definition qdp_subset.cc:31
Subset even
Even subset.
Definition qdp_subset.cc:28
Subset all
Default all subset.
Definition qdp_subset.cc:16
Yet another random number generator.