QDP++
qdp_subset.cc
Go to the documentation of this file.
1
4
5#include "qdp.h"
6#include "qdp_util.h"
7
8namespace QDP
9{
10
11 //---------------------------------------------------------------------
14
17
20
23
26
29
32
33
35 class SetAllFunc : public SetFunc
36 {
37 public:
38 int operator() (const multi1d<int>& coordinate) const {return 0;}
39 int numSubsets() const {return 1;}
40 };
41
42
44 class SetRBFunc : public SetFunc
45 {
46 public:
47 int operator() (const multi1d<int>& coordinate) const
48 {
49 int sum = 0;
50 for(int m=0; m < coordinate.size(); ++m)
51 sum += coordinate[m];
52
53 return sum & 1;
54 }
55
56 int numSubsets() const {return 2;}
57 };
58
60 class SetRB3Func : public SetFunc
61 {
62 public:
63 int operator() (const multi1d<int>& coordinate) const
64 {
65 if (coordinate.size() < 3) {
66 QDPIO::cerr << "Need at least 3d for 3d checkerboarding" << std::endl;
67 QDP_abort(1);
68 }
69 int sum = 0;
70 for(int m=0; m < 3; ++m)
71 sum += coordinate[m];
72
73 return sum & 1;
74 }
75
76 int numSubsets() const {return 2;}
77 };
78
79
81 class Set32CBFunc : public SetFunc
82 {
83 public:
84 int operator() (const multi1d<int>& coordinate) const
85 {
86 int initial_color = 0;
87 for(int m=Nd-1; m >= 0; --m)
88 initial_color = (initial_color << 1) + (coordinate[m] & 1);
89
90 int cb = 0;
91 for(int m=0; m < Nd; ++m)
92 cb += coordinate[m] >> 1;
93
94 cb &= 1;
95 return initial_color + (cb << Nd);
96 }
97
98 int numSubsets() const {return 1 << (Nd+1);}
99 };
100
101
104 {
105 // Initialize the red/black checkerboard
106 rb.make(SetRBFunc());
107
108 // Initialize the 3d red/black checkerboard.
109 rb3.make(SetRB3Func());
110
111 // Initialize the 32-style checkerboard
112 mcb.make(Set32CBFunc());
113
114 // The all set
115 set_all.make(SetAllFunc());
116
117 // The all subset
118 all.make(set_all[0]);
119
120 // COPY the rb[0] to the even subset
121 even = rb[0];
122
123 // COPY the rb[1] to the odd subset
124 odd = rb[1];
125 }
126
127
128 //-----------------------------------------------------------------------------
130 void Subset::make(bool _rep, int _start, int _end, multi1d<int>* ind, int cb, Set* _set)
131 {
132 ordRep = _rep;
133 startSite = _start;
134 endSite = _end;
135 sub_index = cb;
136 sitetable = ind;
137 set = _set;
138 }
139
141 void Subset::make(const Subset& s)
142 {
143 ordRep = s.ordRep;
144 startSite = s.startSite;
145 endSite = s.endSite;
146 sub_index = s.sub_index;
147 sitetable = s.sitetable;
148 set = s.set;
149 }
150
153 {
154 make(s);
155 return *this;
156 }
157
158 //-----------------------------------------------------------------------------
159 // = operator
161 {
162 sub = s.sub;
165 return *this;
166 }
167
168 //-----------------------------------------------------------------------------
169
170} // namespace QDP;
Function object used for constructing 32 checkerboard. *‍/.
Definition qdp_subset.cc:82
int operator()(const multi1d< int > &coordinate) const
Definition qdp_subset.cc:84
int numSubsets() const
Definition qdp_subset.cc:98
Function object used for constructing the all subset.
Definition qdp_subset.cc:36
int numSubsets() const
Definition qdp_subset.cc:39
int operator()(const multi1d< int > &coordinate) const
Definition qdp_subset.cc:38
SetMap.
Definition qdp_subset.h:24
Function object used for constructing red-black (2) checkerboard in 3d.
Definition qdp_subset.cc:61
int numSubsets() const
Definition qdp_subset.cc:76
int operator()(const multi1d< int > &coordinate) const
Definition qdp_subset.cc:63
Function object used for constructing red-black (2) checkerboard *‍/.
Definition qdp_subset.cc:45
int numSubsets() const
Definition qdp_subset.cc:56
int operator()(const multi1d< int > &coordinate) const
Definition qdp_subset.cc:47
Set - collection of subsets controlling which sites are involved in an operation.
Definition qdp_subset.h:96
multi1d< int > lat_color
Index or color array of lattice.
Definition qdp_subset.h:124
Set & operator=(const Set &s)
The = operator.
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
Set()
There can be an empty constructor.
Definition qdp_subset.h:99
Subsets - controls how lattices are looped.
Definition qdp_subset.h:39
Subset()
There can be an empty constructor.
Definition qdp_subset.h:42
Subset & operator=(const Subset &s)
The = operator.
void make(const Subset &s)
Simple constructor called to produce a Subset from inside a Set.
friend class Set
Definition qdp_subset.h:89
Container for a multi-dimensional 1D array.
Definition qdp_multi.h:25
int size() const
Size of array.
Definition qdp_multi.h:60
UnaryReturn< C, FnSum >::Type_t sum(const QDPType< T, C > &s1)
OScalar = sum(source).
const int Nd
Definition qdp_params.h:24
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
StandardOutputStream cerr
Definition qdp_stdio.cc:22
Yet another random number generator.
Set set_all
Default all set.
Definition qdp_subset.cc:13
void initDefaultSets()
Initializer for sets.
void QDP_abort(int status)
Panic button.
Primary include file for QDP.