HILA
Loading...
Searching...
No Matches
representations.h
1#ifndef REPRESENTATIONS_H_
2#define REPRESENTATIONS_H_
3
4#include "sun.h"
5
6/// A matrix in the adjoint representation of the SU(N) group
7///
8/// Members
9/// adjoint.represent(sun m): projects the sU(N) matrix to the
10/// adjoint representation and replaces this
11///
12/// Class functions:
13/// adjoint::generator(int i): returns generators of SU(N)
14/// in the fundamental representation
15/// adjoint::represented_generator_I(int i): returns the
16/// generator (times I) in the adjoint representation
17/// adjoint::project_force(squarematrix): projects a square
18/// matrix the size of an adjoint matrix to the SU(N)
19/// algebra. This is used to calculate the force of an
20/// adjoint action term to a derivative of the underlying
21/// su(N) group
22///
23template <int N, typename radix>
24class adjointRep : public SquareMatrix<N * N - 1, radix> {
25 public:
26 static_assert(hila::is_arithmetic<radix>::value, "adjointRep<type>: type has to be real");
27
28 /// The underlying arithmetic type of the matrix
29 using base_type = hila::arithmetic_type<radix>;
30 using argument_type = radix;
31 /// The SU(N) type the adjoint matrix is constructed of
33
34 /// Matrix size
35 constexpr static int size = N * N - 1;
36 /// Info on group generators
37 static sun generator(int i) { return sun::generator(i); }
38
39 /// std ops required for triviality
40 adjointRep() = default;
41 /// std ops required for triviality
42 ~adjointRep() = default;
43 /// std ops required for triviality
44 adjointRep(const adjointRep &a) = default;
45
46 /// Use square matrix constructor from radix
47 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
48 adjointRep(const scalart m) : SquareMatrix<size, radix>(m) {}
49
50 /// Copy constructor
51 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
53
54 /// Automatic conversion from SquareMatrix is needed!
56
57
58 /// Return a SU(N) generator in the adjoint representation,
59 /// multiplied by I
61 static bool initialize = true;
62 static adjointRep r_generators[size];
63 if (initialize)
64 for (int g = 0; g < size; g++) {
65 r_generators[g] = 0;
66 sun tg = sun::generator(g);
67 for (int j = 0; j < size; j++) {
68 sun tj = generator(j);
69 for (int k = 0; k < size; k++) {
70 sun tk = generator(k);
71 Complex<radix> tr1 = (tg * tj * tk).trace();
72 Complex<radix> tr2 = (tj * tg * tk).trace();
73 r_generators[g].e(j, k) = 2 * (tr1.im - tr2.im);
74 }
75 }
76 initialize = false;
77 }
78 return r_generators[i];
79 }
80
81 /// Project a matrix into the adjoint representation
82 void represent(sun &m) {
83 for (int i = 0; i < size; i++)
84 for (int j = 0; j < size; j++) {
85 (*this).e(i, j) =
86 2 * (m.adjoint() * generator(i) * m * generator(j)).trace().re;
87 }
88 }
89
90 /// Project a complex adjoint matrix into the algebra and
91 /// represent as a complex NxN (momentum) matrix
95 for (int g = 0; g < size; g++) {
97 radix C = (rg.transpose() * rforce).trace().re;
98 fforce += C * sun::generator(g);
99 }
100 Complex<radix> ct(0, 2.0);
101 fforce = fforce * ct;
102 project_antihermitean(fforce);
103 return fforce;
104 }
105};
106
107/// A matrix in the antisymmetric representation of the SU(N) group
108///
109/// Members
110/// antisymmetric.represent(sun m): projects the sU(N) matrix to the
111/// antisymmetric representation and replaces this
112///
113/// Class functions:
114/// antisymmetric::generator(int i): returns antisymmetric matrices
115/// in the fundamental representation
116/// antisymmetric::represented_generator_I(int i): returns
117/// antisymmetric SU(N) matrices (times I) in the antisymmetric
118/// representation
119/// antisymmetric::project_force(squarematrix): projects a square
120/// matrix the size of an antisymmetric matrix to the SU(N)
121/// algebra. This is used to calculate the force of an
122/// antisymmetric action term to a derivative of the underlying
123/// su(N) group
124///
125template <int N, typename radix>
126class antisymmetric : public SquareMatrix<N *(N - 1) / 2, Complex<radix>> {
127 public:
128 /// The underlying arithmetic type of the matrix
129 using base_type = hila::arithmetic_type<radix>;
130 using argument_type = radix;
131 /// The SU(N) type the adjoint matrix is constructed of
133
134 /// Matrix size
135 constexpr static int size = N * (N - 1) / 2;
136
137 /// Use square matrix constructors
139 /// Use square matrix constructors
140 using SquareMatrix<size, Complex<radix>>::operator=;
141
142 /// default constructor
143 antisymmetric() = default;
144
145 /// Square matrix constructor from scalar
146 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
147 antisymmetric(const scalart m) : SquareMatrix<size, Complex<radix>>(m) {}
148
149 /// Copy constructor
150 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
152 for (int j = 0; j < size; j++)
153 for (int i = 0; i < size; i++) {
154 this->e(i, j) = m.e(i, j);
155 }
156 }
157
158 /// automatic conversion from SquareMatrix -- needed for methods!
160
161 /// Needs assignment as well
162 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
164 for (int j = 0; j < size; j++)
165 for (int i = 0; i < size; i++) {
166 this->e(i, j) = m.e(i, j);
167 }
168 return *this;
169 }
170
171 /// The antisymmetric generator
172 static sun generator(int ng) {
173 static bool initialize = true;
174 static sun generators[size];
175 if (initialize)
176 for (int g = 0; g < size; g++) {
177 generators[g] = 0;
178 int k = 0;
179 for (int m1 = 0; m1 < N; m1++)
180 for (int m2 = m1 + 1; m2 < N; m2++) {
181 if (g == k) {
182 generators[g].e(m1, m2).re = 0.5;
183 generators[g].e(m2, m1).re = -0.5;
184 }
185 k++;
186 }
187 initialize = false;
188 }
189 return generators[ng];
190 }
191
192 /// Return a SU(N) generator (times I) in the antisymmetric representation
194 static bool initialize = true;
195 static antisymmetric r_generators[size];
196 if (initialize)
197 for (int g = 0; g < size; g++) {
198 r_generators[g] = 0;
199 sun tg = sun::generator(g);
200 for (int j = 0; j < N * (N - 1) / 2; j++) {
201 sun tj = generator(j);
202 for (int k = 0; k < N * (N - 1) / 2; k++) {
203 sun tk = generator(k);
204
205 Complex<radix> tr = (tj * tg * tk).trace();
206 r_generators[g].e(j, k) = Complex<radix>(0, 4) * tr;
207 }
208 }
209 initialize = false;
210 }
211 return r_generators[i];
212 }
213
214 /// Project a matrix into the antisymmetric representation
215 void represent(sun &m) {
216 for (int i = 0; i < size; i++)
217 for (int j = 0; j < size; j++) {
218 (*this).e(i, j) =
219 2 *
220 (generator(i) * m * generator(j).adjoint() * m.transpose()).trace();
221 }
222 }
223
224 /// Project a complex antisymmetric matrix into the algebra and
225 /// represent as a complex NxN (momentum) matrix
229 for (int g = 0; g < size; g++) {
231 radix C = (rg.adjoint() * rforce).trace().re;
232 fforce += C * sun::generator(g);
233 }
234 Complex<radix> ct(0, -2.0);
235 fforce = fforce * ct;
236 project_antihermitean(fforce);
237 return fforce;
238 }
239};
240
241/// A matrix in the symmetric representation of the SU(N) group
242///
243/// Members
244/// symmetric.represent(sun m): projects the sU(N) matrix to the
245/// symmetric representation and replaces this
246///
247/// Class functions:
248/// symmetric::generator(int i): returns symmetric matrices
249/// in the fundamental representation
250/// symmetric::represented_generator_I(int i): returns
251/// symmetric SU(N) matrices (times I) in the symmetric
252/// representation
253/// symmetric::project_force(squarematrix): projects a square
254/// matrix the size of an symmetric matrix to the SU(N)
255/// algebra. This is used to calculate the force of an
256/// symmetric action term to a derivative of the underlying
257/// su(N) group
258///
259template <int N, typename radix>
260class symmetric : public SquareMatrix<N *(N + 1) / 2, Complex<radix>> {
261 public:
262 /// The underlying arithmetic type of the matrix
263 using base_type = hila::arithmetic_type<radix>;
264 using argument_type = radix;
265 /// The SU(N) type the adjoint matrix is constructed of
267
268 /// Use square matrix constructors
269 using SquareMatrix<N *(N + 1) / 2, Complex<radix>>::SquareMatrix;
270 /// Use square matrix constructors
271 using SquareMatrix<N *(N + 1) / 2, Complex<radix>>::operator=;
272
273 /// Matrix size
274 constexpr static int size = N * (N + 1) / 2;
275
276 /// Use default constructor
277 symmetric() = default;
278
279 /// Constructor from scalar
280 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
281 symmetric(const scalart m) {
282 for (int j = 0; j < size; j++) {
283 for (int i = 0; i < size; i++) {
284 this->e(i, j) = 0;
285 }
286 this->c[j][j] = m;
287 }
288 }
289
290 /// Constructor from a symmetric matrix
291 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
293 for (int j = 0; j < size; j++)
294 for (int i = 0; i < size; i++) {
295 this->e(i, j) = m.e(i, j);
296 }
297 }
298
299 /// Needs assignment as well
300 template <typename scalart, std::enable_if_t<hila::is_arithmetic<scalart>::value, int> = 0>
302 for (int j = 0; j < size; j++)
303 for (int i = 0; i < size; i++) {
304 this->e(i, j) = m.e(i, j);
305 }
306 return *this;
307 }
308
309 /// Symmetric generators as SU(N) matrices
310 static sun generator(int ng) {
311 static bool initialize = true;
312 static sun generators[size];
313 if (initialize)
314 for (int g = 0; g < size; g++) {
315 generators[g] = 0;
316 if (g < N) {
317 generators[g].e(g, g).re = sqrt(0.5);
318 }
319 int k = N;
320 for (int m1 = 0; m1 < N; m1++)
321 for (int m2 = m1 + 1; m2 < N; m2++) {
322 if (g == k) {
323 generators[g].e(m1, m2).re = 0.5;
324 generators[g].e(m2, m1).re = 0.5;
325 }
326 k++;
327 }
328 initialize = false;
329 }
330 return generators[ng];
331 }
332
333 /// Return a symmetric generators (times I) in the symmetric representation
335 static bool initialize = true;
336 static symmetric r_generators[size];
337 if (initialize)
338 for (int g = 0; g < size; g++) {
339 r_generators[g] = 0;
340 sun tg = sun::generator(g);
341 for (int j = 0; j < N * (N + 1) / 2; j++) {
342 sun tj = generator(j);
343 for (int k = 0; k < N * (N + 1) / 2; k++) {
344 sun tk = generator(k);
345
346 Complex<radix> tr = (tj * tg * tk).trace();
347 r_generators[g].e(j, k) = Complex<radix>(0, 4) * tr;
348 }
349 }
350 initialize = false;
351 }
352 return r_generators[i];
353 }
354
355 /// Project a matrix into the symmetric representation
356 void represent(sun &m) {
357 for (int i = 0; i < size; i++)
358 for (int j = 0; j < size; j++) {
359 (*this).e(i, j) =
360 2 * (generator(i) * m * generator(j) * m.transpose()).trace();
361 }
362 }
363
364 /// Project a complex symmetric matrix into the algebra and
365 /// represent as a complex NxN (momentum) matrix
369 for (int g = 0; g < size; g++) {
371 radix C = (rg * rforce).trace().re;
372 fforce += C * sun::generator(g);
373 }
374 Complex<radix> ct(0, -2.0);
375 fforce = fforce * ct;
376 project_antihermitean(fforce);
377 return fforce;
378 }
379};
380
381#endif
Array< n, m, T > sqrt(Array< n, m, T > a)
Square root.
Definition array.h:1039
Complex definition.
Definition cmplx.h:56
T trace() const
Computes Trace for Matrix.
Definition matrix.h:1079
T c[n *m]
The data as a one dimensional array.
Definition matrix.h:110
T e(const int i, const int j) const
Standard array indexing operation for matrices and vectors.
Definition matrix.h:286
Rtype transpose() const
Transpose of matrix.
Definition matrix.h:954
Rtype adjoint() const
Adjoint of matrix.
Definition matrix.h:1019
Matrix class which defines matrix operations.
Definition matrix.h:1620
Class for SU(N) matrix.
Definition sun_matrix.h:110
static sun generator(int i)
Info on group generators.
adjointRep(const adjointRep< N, scalart > m)
Copy constructor.
adjointRep(const adjointRep &a)=default
std ops required for triviality
~adjointRep()=default
std ops required for triviality
adjointRep(const scalart m)
Use square matrix constructor from radix.
static constexpr int size
Matrix size.
hila::arithmetic_type< radix > base_type
The underlying arithmetic type of the matrix.
void represent(sun &m)
Project a matrix into the adjoint representation.
adjointRep()=default
std ops required for triviality
adjointRep(const SquareMatrix< size, radix > m)
Automatic conversion from SquareMatrix is needed!
static SquareMatrix< N, Complex< radix > > project_force(SquareMatrix< size, Complex< radix > > rforce)
static adjointRep represented_generator_I(int i)
antisymmetric(const antisymmetric< N, scalart > m)
Copy constructor.
static SquareMatrix< N, Complex< radix > > project_force(SquareMatrix< size, Complex< radix > > rforce)
antisymmetric()=default
default constructor
static sun generator(int ng)
The antisymmetric generator.
void represent(sun &m)
Project a matrix into the antisymmetric representation.
static antisymmetric represented_generator_I(int i)
Return a SU(N) generator (times I) in the antisymmetric representation.
static constexpr int size
Matrix size.
hila::arithmetic_type< radix > base_type
The underlying arithmetic type of the matrix.
antisymmetric(const scalart m)
Square matrix constructor from scalar.
antisymmetric & operator=(const antisymmetric< N, scalart > m)
Needs assignment as well.
antisymmetric(const SquareMatrix< size, Complex< radix > > m)
automatic conversion from SquareMatrix – needed for methods!
static constexpr int size
Matrix size.
symmetric & operator=(const symmetric< N, scalart > m)
Needs assignment as well.
symmetric(const scalart m)
Constructor from scalar.
static sun generator(int ng)
Symmetric generators as SU(N) matrices.
symmetric(const symmetric< N, scalart > m)
Constructor from a symmetric matrix.
symmetric()=default
Use default constructor.
hila::arithmetic_type< radix > base_type
The underlying arithmetic type of the matrix.
static SquareMatrix< N, Complex< radix > > project_force(SquareMatrix< size, Complex< radix > > rforce)
void represent(sun &m)
Project a matrix into the symmetric representation.
static symmetric represented_generator_I(int i)
Return a symmetric generators (times I) in the symmetric representation.
Matrix< n, n, T > SquareMatrix
Square matrix is defined as alias with special case of Matrix<n,n,T>
Definition matrix.h:47