-
Notifications
You must be signed in to change notification settings - Fork 0
/
wilson.hpp
56 lines (48 loc) · 1.23 KB
/
wilson.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include <complex>
#include <tr1/tuple>
#include "misc.hpp"
using namespace std;
using namespace tr1;
template<class Lattice>
inline double wilsonLoop( Lattice& lat, Site<Lattice::ndim> const& x, int mu, int nu, int w, int h ) {
Site<Lattice::ndim> y = x;
typename Lattice::Elem u = one( typename Lattice::Elem() );
for( int i = 0; i < w; ++i ) {
u = u * lat( y, mu );
y = y + mu;
}
for( int i = 0; i < h; ++i ) {
u = u * lat( y, nu );
y = y + nu;
}
Site<Lattice::ndim> z = x;
typename Lattice::Elem v = one( typename Lattice::Elem() );
for( int i = 0; i < h; ++i ) {
v = v * lat( z, nu );
z = z + nu;
}
for( int i = 0; i < w; ++i ) {
v = v * lat( z, mu );
z = z + mu;
}
return real( ntrace( u * inv( v ) ) );
}
template<class Lattice>
tuple<double, double> avgWilsonLoop( Lattice& lat, int w, int h ) {
double s1 = 0.0;
double s2 = 0.0;
Site<Lattice::ndim> x;
x.assign( 0 );
do {
for( int mu = 0; mu < Lattice::ndim; ++mu ) {
for( int nu = 0; nu < mu; ++nu ) {
double v = wilsonLoop( lat, x, mu, nu, w, h );
s1 += v;
s2 += v * v;
}
}
} while( lat.next( x ) );
int const n = lat.nSites() * (Lattice::ndim * (Lattice::ndim - 1) / 2);
return make_tuple( s1 / n, s2 / n );
}