Grid 0.7.0
Sp2n.impl.h
Go to the documentation of this file.
1// This file is #included into the body of the class template definition of
2// GaugeGroup. So, image there to be
3//
4// template <int ncolour, class group_name>
5// class GaugeGroup {
6//
7// around it.
8//
9// Please note that the unconventional file extension makes sure that it
10// doesn't get found by the scripts/filelist during bootstrapping.
11
12private:
13template <ONLY_IF_Sp>
14static int su2subgroups(GroupName::Sp) { return (ncolour/2 * (ncolour/2 - 1)) / 2; }
15
16// Sp(2N) has N(2N+1) = 2N^2+N generators
17//
18// normalise the generators such that
19// Trace ( Ta Tb) = 1/2 delta_ab
20//
21// N generators in the cartan, 2N^2 off
22// off diagonal:
23// there are 6 types named a,b,c,d and w,z
24// abcd are N(N-1)/2 each while wz are N each
25
26template <class cplx, ONLY_IF_Sp>
27static void generator(int lieIndex, iGroupMatrix<cplx> &ta, GroupName::Sp) {
28 // map lie index into type of generators: diagonal, abcd type, wz type
29
30 const int nsp = ncolour/2;
31 int diagIndex;
32 int aIndex, bIndex, cIndex, dIndex;
33 int wIndex, zIndex; // a,b,c,d are N(N-1)/2 and w,z are N
34 const int mod = nsp * (nsp - 1) * 0.5;
35 const int offdiag =
36 2 * nsp * nsp; // number of generators not in the cartan subalgebra
37 const int wmod = 4 * mod;
38 const int zmod = wmod + nsp;
39 if (lieIndex >= offdiag) {
40 diagIndex = lieIndex - offdiag; // 0, ... ,N-1
41 // std::cout << GridLogMessage << "diag type " << std::endl;
42 generatorDiagtype(diagIndex, ta);
43 return;
44 }
45 if ((lieIndex >= wmod) && (lieIndex < zmod)) {
46 // std::cout << GridLogMessage << "w type " << std::endl;
47 wIndex = lieIndex - wmod; // 0, ... ,N-1
48 generatorWtype(wIndex, ta);
49 return;
50 }
51 if ((lieIndex >= zmod) && (lieIndex < offdiag)) {
52 // std::cout << GridLogMessage << "z type " << std::endl;
53 // std::cout << GridLogMessage << "lie index " << lieIndex << std::endl;
54 // std::cout << GridLogMessage << "z mod " << zmod << std::endl;
55 zIndex = lieIndex - zmod; // 0, ... ,N-1
56 generatorZtype(zIndex, ta);
57 return;
58 }
59 if (lieIndex < mod) { // atype 0, ... , N(N-1)/2=mod
60 // std::cout << GridLogMessage << "a type " << std::endl;
61 aIndex = lieIndex;
62 // std::cout << GridLogMessage << "a indx " << aIndex << std::endl;
63 generatorAtype(aIndex, ta);
64 return;
65 }
66 if ((lieIndex >= mod) && lieIndex < 2 * mod) { // btype mod, ... , 2mod-1
67 // std::cout << GridLogMessage << "b type " << std::endl;
68 bIndex = lieIndex - mod;
69 generatorBtype(bIndex, ta);
70 return;
71 }
72 if ((lieIndex >= 2 * mod) &&
73 lieIndex < 3 * mod) { // ctype 2mod, ... , 3mod-1
74 // std::cout << GridLogMessage << "c type " << std::endl;
75 cIndex = lieIndex - 2 * mod;
76 generatorCtype(cIndex, ta);
77 return;
78 }
79 if ((lieIndex >= 3 * mod) &&
80 lieIndex < wmod) { // ctype 3mod, ... , 4mod-1 = wmod-1
81 // std::cout << GridLogMessage << "d type " << std::endl;
82 dIndex = lieIndex - 3 * mod;
83 generatorDtype(dIndex, ta);
84 return;
85 }
86
87} // end of generator
88
89template <class cplx, ONLY_IF_Sp>
90static void generatorDiagtype(int diagIndex, iGroupMatrix<cplx> &ta) {
91 // ta(i,i) = - ta(i+N,i+N) = 1/2 for each i index of the cartan subalgebra
92
93 const int nsp=ncolour/2;
94 ta = Zero();
95 RealD nrm = 1.0 / 2;
96
97 ta()()(diagIndex, diagIndex) = nrm;
98 ta()()(diagIndex + nsp, diagIndex + nsp) = -nrm;
99}
100
101template <class cplx, ONLY_IF_Sp>
102static void generatorAtype(int aIndex, iGroupMatrix<cplx> &ta) {
103 // ta(i,j) = ta(j,i) = -ta(i+N,j+N) = -ta(j+N,i+N) = 1 / 2 sqrt(2)
104 // with i<j and i=0,...,N-2
105 // follows that j=i+1, ... , N
106 int i1, i2;
107 const int nsp=ncolour/2;
108 ta = Zero();
109 RealD nrm = 1 / (2 * std::sqrt(2));
110
111 su2SubGroupIndex(i1, i2, aIndex);
112 ta()()(i1, i2) = 1;
113 ta()()(i2, i1) = 1;
114 ta()()(i1 + nsp, i2 + nsp) = -1;
115 ta()()(i2 + nsp, i1 + nsp) = -1;
116
117 ta = ta * nrm;
118}
119
120template <class cplx, ONLY_IF_Sp>
121static void generatorBtype(int bIndex, iGroupMatrix<cplx> &ta) {
122 // ta(i,j) = -ta(j,i) = ta(i+N,j+N) = -ta(j+N,i+N) = i / 1/ 2 sqrt(2)
123 // with i<j and i=0,...,N-2
124 // follows that j=i+1, ... , N-1
125
126 const int nsp=ncolour/2;
127 int i1, i2;
128 ta = Zero();
129 cplx i(0.0, 1.0);
130 RealD nrm = 1 / (2 * std::sqrt(2));
131 su2SubGroupIndex(i1, i2, bIndex);
132
133 ta()()(i1, i2) = i;
134 ta()()(i2, i1) = -i;
135 ta()()(i1 + nsp, i2 + nsp) = i;
136 ta()()(i2 + nsp, i1 + nsp) = -i;
137
138 ta = ta * nrm;
139}
140
141template <class cplx, ONLY_IF_Sp>
142static void generatorCtype(int cIndex, iGroupMatrix<cplx> &ta) {
143 // ta(i,j+N) = ta(j,i+N) = ta(i+N,j) = ta(j+N,i) = 1 / 2 sqrt(2)
144
145 const int nsp=ncolour/2;
146 int i1, i2;
147 ta = Zero();
148 RealD nrm = 1 / (2 * std::sqrt(2));
149 su2SubGroupIndex(i1, i2, cIndex);
150
151 ta()()(i1, i2 + nsp) = 1;
152 ta()()(i2, i1 + nsp) = 1;
153 ta()()(i1 + nsp, i2) = 1;
154 ta()()(i2 + nsp, i1) = 1;
155
156 ta = ta * nrm;
157}
158
159template <class cplx, ONLY_IF_Sp>
160static void generatorDtype(int dIndex, iGroupMatrix<cplx> &ta) {
161 // ta(i,j+N) = ta(j,i+N) = -ta(i+N,j) = -ta(j+N,i) = i / 2 sqrt(2)
162
163 const int nsp=ncolour/2;
164 int i1, i2;
165 ta = Zero();
166 cplx i(0.0, 1.0);
167 RealD nrm = 1 / (2 * std::sqrt(2));
168 su2SubGroupIndex(i1, i2, dIndex);
169
170 ta()()(i1, i2 + nsp) = i;
171 ta()()(i2, i1 + nsp) = i;
172 ta()()(i1 + nsp, i2) = -i;
173 ta()()(i2 + nsp, i1) = -i;
174
175 ta = ta * nrm;
176}
177
178template <class cplx, ONLY_IF_Sp>
179static void generatorWtype(int wIndex, iGroupMatrix<cplx> &ta) {
180 // ta(i,i+N) = ta(i+N,i) = 1/2
181
182 const int nsp=ncolour/2;
183 ta = Zero();
184 RealD nrm = 1.0 / 2; // check
185
186 ta()()(wIndex, wIndex + nsp) = 1;
187 ta()()(wIndex + nsp, wIndex) = 1;
188
189 ta = ta * nrm;
190}
191
192template <class cplx, ONLY_IF_Sp>
193static void generatorZtype(int zIndex, iGroupMatrix<cplx> &ta) {
194 // ta(i,i+N) = - ta(i+N,i) = i/2
195
196 const int nsp=ncolour/2;
197 ta = Zero();
198 RealD nrm = 1.0 / 2; // check
199 cplx i(0.0, 1.0);
200 ta()()(zIndex, zIndex + nsp) = i;
201 ta()()(zIndex + nsp, zIndex) = -i;
202
203 ta = ta * nrm;
204}
205
207// Map a su2 subgroup number to the pair of rows that are non zero
209template <ONLY_IF_Sp>
210static accelerator_inline void su2SubGroupIndex(int &i1, int &i2, int su2_index, GroupName::Sp) {
211 const int nsp=ncolour/2;
212 assert((su2_index >= 0) && (su2_index < (nsp * (nsp - 1)) / 2));
213
214 int spare = su2_index;
215 for (i1 = 0; spare >= (nsp - 1 - i1); i1++) {
216 spare = spare - (nsp - 1 - i1); // remove the Nc-1-i1 terms
217 }
218 i2 = i1 + 1 + spare;
219}
220
222 Matrix ta;
223 Matrix tb;
224 std::cout << GridLogMessage
225 << "Fundamental - Checking trace ta tb is 0.5 delta_ab "
226 << std::endl;
227 for (int a = 0; a < AlgebraDimension; a++) {
228 for (int b = 0; b < AlgebraDimension; b++) {
229 generator(a, ta);
230 generator(b, tb);
231 Complex tr = TensorRemove(trace(ta * tb));
232 std::cout << GridLogMessage << "(" << a << "," << b << ") = " << tr
233 << std::endl;
234 if (a == b) assert(abs(tr - Complex(0.5)) < 1.0e-6);
235 if (a != b) assert(abs(tr) < 1.0e-6);
236 }
237 }
238 std::cout << GridLogMessage << std::endl;
239 std::cout << GridLogMessage << "Fundamental - Checking if hermitian"
240 << std::endl;
241 for (int a = 0; a < AlgebraDimension; a++) {
242 generator(a, ta);
243 std::cout << GridLogMessage << a << std::endl;
244 assert(norm2(ta - adj(ta)) < 1.0e-6);
245 }
246 std::cout << GridLogMessage << std::endl;
247 std::cout << GridLogMessage << "Fundamental - Checking if traceless"
248 << std::endl;
249 for (int a = 0; a < AlgebraDimension; a++) {
250 generator(a, ta);
251 Complex tr = TensorRemove(trace(ta));
252 std::cout << GridLogMessage << a << std::endl;
253 assert(abs(tr) < 1.0e-6);
254 }
255}
256
257template <int N>
262
263template <class vtype>
267
268template <class vtype, int N>
272
273template <class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
277
278template <typename LatticeMatrixType>
279static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out, GroupName::Sp) {
280 out = SpTa(in);
281}
282
283public:
284
285template <ONLY_IF_Sp>
286static void Omega(LatticeColourMatrixD &in) {
287 const int nsp=ncolour/2;
288 LatticeColourMatrixD OmegaLatt(in.Grid());
289 LatticeColourMatrixD identity(in.Grid());
291
292 OmegaLatt = Zero();
293 Omega = Zero();
294 identity = 1.;
295
296 for (int i = 0; i < nsp; i++) {
297 Omega()()(i, nsp + i) = 1.;
298 Omega()()(nsp + i, i) = -1;
299 }
300 OmegaLatt = OmegaLatt + (identity * Omega);
301 in = OmegaLatt;
302}
303
304template <ONLY_IF_Sp, class vtype, int N>
306 const int nsp=ncolour/2;
307
309 Omega = Zero();
310
311 for (int i = 0; i < nsp; i++) {
312 Omega()()(i, nsp + i) = 1.;
313 Omega()()(nsp + i, i) = -1;
314 }
315
316 in = Omega;
317}
318
#define accelerator_inline
accelerator_inline Grid_simd2< S, V > trace(const Grid_simd2< S, V > &arg)
accelerator_inline Grid_simd< S, V > abs(const Grid_simd< S, V > &r)
Lattice< vobj > adj(const Lattice< vobj > &lhs)
RealD norm2(const Lattice< vobj > &arg)
Lattice< obj > mod(const Lattice< obj > &rhs_i, Integer y)
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
iColourMatrix< Complex > ColourMatrix
Definition QCD.h:133
Lattice< vColourMatrixD > LatticeColourMatrixD
Definition QCD.h:297
std::complex< Real > Complex
Definition Simd.h:80
double RealD
Definition Simd.h:61
static int su2subgroups(GroupName::Sp)
Definition Sp2n.impl.h:14
static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out, GroupName::Sp)
Definition Sp2n.impl.h:279
static void generator(int lieIndex, iGroupMatrix< cplx > &ta, GroupName::Sp)
Definition Sp2n.impl.h:27
static void generatorDiagtype(int diagIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:90
static void Omega(LatticeColourMatrixD &in)
Definition Sp2n.impl.h:286
static void generatorAtype(int aIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:102
static void generatorDtype(int dIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:160
static void testGenerators(GroupName::Sp)
Definition Sp2n.impl.h:221
static Lattice< iScalar< iScalar< iMatrix< vComplexD, N > > > > ProjectOnGeneralGroup(const Lattice< iScalar< iScalar< iMatrix< vComplexD, N > > > > &Umu, GroupName::Sp)
Definition Sp2n.impl.h:259
static void generatorBtype(int bIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:121
static void generatorCtype(int cIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:142
static void generatorWtype(int wIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:179
static void generatorZtype(int zIndex, iGroupMatrix< cplx > &ta)
Definition Sp2n.impl.h:193
static accelerator_inline void su2SubGroupIndex(int &i1, int &i2, int su2_index, GroupName::Sp)
Definition Sp2n.impl.h:210
accelerator_inline iScalar< vtype > ProjectOnSpGroup(const iScalar< vtype > &r)
Definition Tensor_Ta.h:193
accelerator_inline iScalar< vtype > SpTa(const iScalar< vtype > &r)
Definition Tensor_Ta.h:69
accelerator_inline std::enable_if<!isGridTensor< T >::value, T >::type TensorRemove(T arg)
GridBase * Grid(void) const
Definition Simd.h:194