HILA
Loading...
Searching...
No Matches
staples.h
Go to the documentation of this file.
1/** @file staples.h */
2
3#ifndef STAPLESUM_H_
4#define STAPLESUM_H_
5
6#include "hila.h"
7
8/**
9 * @brief Sum the staples of link matrices to direction dir
10 *
11 * Naive method is to compute:
12 *
13 * \code {.cpp}
14 * foralldir(d2) if (d2 != d1)
15 * stapes[par] += U[d2][X]*U[d1][X+d2]*U[d2][X+d1].dagger() +
16 * U[d2][X-d2].dagger()*U[d1][X-d2]*U[d2][X-d2+d1]
17 * \endcode
18 *
19 * But the method is computed in a slightly more optimized way
20 *
21 * @tparam T
22 * @param U GaugeField to compute staples for
23 * @param staples Filed to compute staplesum into at each lattice point
24 * @param d1 Direction to compute staplesum for
25 * @param par Parity to compute staplesum for
26 */
27template <typename T>
28void staplesum(const GaugeField<T> &U, Field<T> &staples, Direction d1, Parity par = ALL) {
29
30 Field<T> lower;
31
32 bool first = true;
33 foralldir(d2) if (d2 != d1) {
34
35 // anticipate that these are needed
36 // not really necessary, but may be faster
37 U[d2].start_gather(d1, ALL);
38 U[d1].start_gather(d2, par);
39
40 // calculate first lower 'U' of the staple sum
41 // do it on opp parity
42 onsites(opp_parity(par)) {
43 lower[X] = U[d2][X].dagger() * U[d1][X] * U[d2][X + d1];
44 }
45
46 // calculate then the upper 'n', and add the lower
47 // lower could also be added on a separate loop
48 if (first) {
49 onsites(par) {
50 staples[X] = U[d2][X] * U[d1][X + d2] * U[d2][X + d1].dagger() + lower[X - d2];
51 }
52 first = false;
53 } else {
54 onsites(par) {
55 staples[X] += U[d2][X] * U[d1][X + d2] * U[d2][X + d1].dagger() + lower[X - d2];
56 }
57 }
58 }
59}
60
61#endif
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
Definition field.h:61
Gauge field class.
Definition gaugefield.h:22
Parity
Parity enum with values EVEN, ODD, ALL; refers to parity of the site. Parity of site (x,...
#define foralldir(d)
Macro to loop over (all) Direction(s)
Definition coordinates.h:78
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
Definition coordinates.h:34
constexpr Parity ALL
bit pattern: 011
void staplesum(const GaugeField< T > &U, Field< T > &staples, Direction d1, Parity par=ALL)
Sum the staples of link matrices to direction dir.
Definition staples.h:28