3#ifndef SUN_MAX_STAPLE_SUM_ROT_H
4#define SUN_MAX_STAPLE_SUM_ROT_H
8#include "plumbing/shuffle.h"
20template <
typename T,
int N>
27 std::array<int, N> tperm;
28 std::iota(tperm.begin(), tperm.end(), 0);
33 int niter = 15 * (N - 1) * N;
37 int iter, tt1, tt2, t1, t2,ic1;
38 Complex<T> tvnn11, tvnn12, tvnn21, tvnn22, ttl01, ttl02;
39 T tu1, tu2, tu3, tu4, k, ki, lnorm, dlnorm, dilnorm;
40 for (iter = 0; iter < niter; ++iter) {
41 for (tt1 = 0; tt1 < N - 1; ++tt1) {
43 for (tt2 = tt1 + 1; tt2 < N; ++tt2) {
46 tvnn11 = tl0.
e(t1, t1);
47 tvnn12 = tl0.
e(t1, t2);
48 tvnn21 = tl0.
e(t2, t1);
49 tvnn22 = tl0.
e(t2, t2);
54 tu1 = 0.5 * (tvnn11.
real() + tvnn22.
real());
55 tu2 = 0.5 * (tvnn12.
imag() + tvnn21.
imag());
56 tu3 = 0.5 * (tvnn12.
real() - tvnn21.
real());
57 tu4 = 0.5 * (tvnn11.
imag() - tvnn22.
imag());
58 ki = 1.0 / sqrt(tu1 * tu1 + tu2 * tu2 + tu3 * tu3 + tu4 * tu4);
77 for (ic1 = 0; ic1 < N; ++ic1) {
78 ttl01 = tl0.
e(t1, ic1);
79 ttl02 = tl0.
e(t2, ic1);
80 tl0.
e(t1, ic1) = tvnn11 * ttl01 + tvnn12 * ttl02;
81 tl0.
e(t2, ic1) = tvnn21 * ttl01 + tvnn22 * ttl02;
85 for (ic1 = 0; ic1 < N; ++ic1) {
88 U.
e(t1, ic1) = tvnn11 * ttl01 + tvnn12 * ttl02;
89 U.
e(t2, ic1) = tvnn21 * ttl01 + tvnn22 * ttl02;
96 ttl01 = tl0.
e(N - 1, N - 1);
99 dilnorm = ttl01.
imag();
100 for (t1 = 0; t1 < N - 1; ++t1) {
101 ttl01 = tl0.
e(t1, t1);
104 for (t2 = t1 + 1; t2 < N; ++t2) {
105 dlnorm += 0.5 *
::squarenorm(tl0.
e(t1, t2) - tl0.
e(t2, t1).conj());
108 lnorm = ::sqrt(lnorm);
109 dlnorm = ::sqrt(dlnorm);
110 if (dlnorm < fp<T>::epsilon * (lnorm + (T)N) * (T)N) {
129template <
typename T,
int N,
typename Btype>
137 tU = tU * U.
dagger() * tU;
hila::arithmetic_type< T > squarenorm(const Array< n, m, T > &rhs)
Return square norm of Array.
Array< n, m, hila::arithmetic_type< T > > real(const Array< n, m, T > &arg)
Return real part of Array.
T real() const
Real part of Complex number.
T squarenorm() const
Compute square norm of Complex number.
T imag() const
Imaginary part of Complex number.
Rtype dagger() const
Hermitian conjugate of matrix.
T e(const int i, const int j) const
Standard array indexing operation for matrices.
auto mul_trace(const Mtype1 &a, const Mtype2 &b)
Returns trace of product of two matrices.
double random()
Real valued uniform random number generator.
SU(N) Matrix definitions.
int suN_overrelax(SU< N, T > &U, const SU< N, T > &staple, Btype beta)
overrelaxation using matrix obtained from max_staple_sum_rot() routine
SU< N, T > suN_max_staple_sum_rot(const SU< N, T > &staple)
Find matrix U that maximizes ReTr(U*staple) for given staple.