6#include "datatypes/sun.h"
8#include "plumbing/random.h"
9#include "datatypes/compoundvector.h"
11#if (NDIM == 5 || NDIM == 4)
14enum class GammaMatrix :
int { g0 = 0, g1, g2, g3, g5 };
16constexpr GammaMatrix gamma0 = GammaMatrix::g0;
17constexpr GammaMatrix gamma1 = GammaMatrix::g1;
18constexpr GammaMatrix gamma2 = GammaMatrix::g2;
19constexpr GammaMatrix gamma3 = GammaMatrix::g3;
20constexpr GammaMatrix gamma5 = GammaMatrix::g5;
23GammaMatrix gamma_matrix[5] = {gamma1, gamma2, gamma3, gamma0, gamma5};
25#elif (NDIM == 3 || NDIM == 2)
28enum class GammaMatrix :
unsigned { g0 = 0, g1, g2 };
30constexpr GammaMatrix gamma0 = GammaMatrix::g0;
31constexpr GammaMatrix gamma1 = GammaMatrix::g1;
32constexpr GammaMatrix gamma2 = GammaMatrix::g2;
35GammaMatrix gamma_matrix[3] = {gamma0, gamma1, gamma2};
38static_assert(
false,
"Wilson fermions only implemented for 1 < NDIM < 6");
56template <
int Nvectors,
int N,
typename T>
71 for (
int i = 0; i < Nvectors; i++)
78 for (
int i = 0; i < Nvectors; i++) {
84 static constexpr int rows()
const {
87 static constexpr int columns()
const {
94 for (
int i = 0; i < Nvectors; i++) {
107 for (
int i = 0; i < Nvectors; i++) {
114 template <
typename S>
116 for (
int i = 0; i < Nvectors; i++) {
123 template <
typename S>
125 for (
int i = 0; i < Nvectors; i++) {
132 template <
typename S>
134 for (
int i = 0; i < Nvectors; i++) {
141 template <typename S, std::enable_if_t<hila::is_complex_or_arithmetic<S>::value> = 0>
143 for (
int i = 0; i < Nvectors; i++) {
150 template <typename S, std::enable_if_t<hila::is_complex_or_arithmetic<S>::value> = 0>
152 for (
int i = 0; i < Nvectors; i++) {
159 template <typename S, std::enable_if_t<hila::is_complex_or_arithmetic<S>::value> = 0>
161 for (
int i = 0; i < Nvectors; i++) {
184 for (
int i = 0; i < Nvectors; i++) {
185 res.c[i] = c[i].
conj();
197 for (
int i = 0; i < Nvectors; i++) {
205 for (
int i = 0; i < Nvectors; i++) {
211 inline T norm()
const {
216 template <
typename S>
217 inline auto dot(
const Wilson_vector_t<Nvectors, N, S> &rhs)
const {
218 auto r = c[0].
dot(rhs.c[0]);
219 for (
int i = 1; i < Nvectors; i++) {
220 r += c[i].
dot(rhs.c[i]);
228 template <
typename S>
229 inline auto outer_product(
const Wilson_vector_t<Nvectors, N, S> &rhs)
const {
231 for (
int i = 1; i < Nvectors; i++) {
237 std::string str()
const {
238 std::string text =
"";
239 for (
int i = 0; i < Nvectors; i++) {
240 text += c[i].
str() +
"\n";
249template <
int N,
typename T>
252template <
int N,
typename T>
260template <
int Nv,
int N,
typename T,
typename M,
typename R = hila::type_mul<M, T>>
262 for (
int i = 0; i < Nv; i++) {
263 rhs.c[i] = lhs * rhs.c[i];
269template <
int Nv,
int N,
typename T,
typename M,
270 std::enable_if_t<hila::is_complex_or_arithmetic<M>::value,
int> = 0>
277template <
int Nv,
int N,
typename T,
typename M,
278 std::enable_if_t<hila::is_complex_or_arithmetic<M>::value,
int> = 0>
285template <
int Nv,
int N,
typename T,
typename M,
typename R = hila::type_plus<T, M>>
289 for (
int i = 0; i < Nv; i++) {
290 r.c[i] = lhs.c[i] + rhs.c[i];
296template <
int Nv,
int N,
typename T,
typename M,
typename R = hila::type_minus<T, M>>
300 for (
int i = 0; i < Nv; i++) {
301 r.c[i] = lhs.c[i] - rhs.c[i];
311template <
int N,
typename T>
322 r.c[0] =
I * rhs.c[3];
323 r.c[1] =
I * rhs.c[2];
324 r.c[2] = -
I * rhs.c[1];
325 r.c[3] = -
I * rhs.c[0];
334 r.c[0] =
I * rhs.c[2];
335 r.c[1] = -
I * rhs.c[3];
336 r.c[2] = -
I * rhs.c[0];
337 r.c[3] =
I * rhs.c[1];
351template <
int N,
typename T>
425template <
int N,
typename T>
443 c[0] = w.c[0] +
I * w.c[3];
444 c[1] = w.c[1] +
I * w.c[2];
446 c[0] = w.c[0] -
I * w.c[3];
447 c[1] = w.c[1] -
I * w.c[2];
452 c[0] = w.c[0] - w.c[3];
453 c[1] = w.c[1] + w.c[2];
455 c[0] = w.c[0] + w.c[3];
456 c[1] = w.c[1] - w.c[2];
461 c[0] = w.c[0] +
I * w.c[2];
462 c[1] = w.c[1] -
I * w.c[3];
464 c[0] = w.c[0] -
I * w.c[2];
465 c[1] = w.c[1] +
I * w.c[3];
470 c[0] = w.c[0] + w.c[2];
471 c[1] = w.c[1] + w.c[3];
473 c[0] = w.c[0] - w.c[2];
474 c[1] = w.c[1] - w.c[3];
480 c[0] =
sqrt(2.0) * w.c[0];
481 c[1] =
sqrt(2.0) * w.c[1];
483 c[0] =
sqrt(2.0) * w.c[2];
484 c[1] =
sqrt(2.0) * w.c[3];
489 assert(
false &&
"ERROR: Half Wilson vector projection called incorrectly \n");
551 r.c[0] =
sqrt(2.0) * c[0];
552 r.c[1] =
sqrt(2.0) * c[1];
558 r.c[2] =
sqrt(2.0) * c[0];
559 r.c[3] =
sqrt(2.0) * c[1];
564 assert(
false &&
"ERROR: Half Wilson vector projection called incorrectly \n");
588 c[0] = w.c[0] + w.c[1];
590 c[0] = w.c[0] - w.c[1];
595 c[0] = w.c[0] -
I * w.c[1];
597 c[0] = w.c[0] +
I * w.c[1];
603 c[0] =
sqrt(2.0) * w.c[0];
605 c[0] =
sqrt(2.0) * w.c[1];
610 assert(
false &&
"ERROR: Half Wilson vector projection called incorrectly \n");
638 r.c[0] =
sqrt(2.0) * c[0];
642 r.c[1] =
sqrt(2.0) * c[0];
647 assert(
false &&
"ERROR: Half Wilson vector projection called incorrectly \n");
658 for (
int i = 0; i < Gammadim / 2; i++) {
665 for (
int i = 0; i < Gammadim / 2; i++) {
672 for (
int i = 0; i < Gammadim / 2; i++) {
680 for (
int i = 0; i < Gammadim / 2; i++) {
686 std::string str()
const {
687 std::string text =
"";
688 for (
int i = 0; i < Gammadim / 2; i++) {
689 text += c[i].
str() +
"\n";
696template <
int N,
typename S,
typename T>
698 for (
int i = 0; i < Gammadim / 2; i++) {
704template <
int N,
typename T,
typename S>
706 for (
int i = 0; i < Gammadim / 2; i++) {
712template <
int N,
typename T,
typename S>
714 for (
int i = 0; i < Gammadim / 2; i++) {
721template <
int N,
typename T,
typename P,
typename R = hila::type_plus<T, P>>
725 for (
int i = 0; i < Gammadim / 2; i++) {
726 r.c[i] = lhs.c[i] + rhs.c[i];
731template <
int N,
typename T,
typename P,
typename R = hila::type_plus<T, P>>
735 for (
int i = 0; i < Gammadim / 2; i++) {
736 r.c[i] = lhs.c[i] - rhs.c[i];
auto operator/(const Array< n, m, A > &a, const Array< n, m, B > &b)
Division operator.
auto operator-(const Array< n, m, A > &a, const Array< n, m, B > &b)
Subtraction operator.
auto operator+(const Array< n, m, A > &a, const Array< n, m, B > &b)
Addition operator.
Array< n, m, T > sqrt(Array< n, m, T > a)
Square root.
Array< n, m, T > operator*(Array< n, m, T > a, const Array< n, m, T > &b)
Multiplication operator.
const auto & fill(const S rhs)
Matrix fill.
Mtype conj() const
Returns complex conjugate of Matrix.
Matrix< n, p, R > outer_product(const Matrix< p, q, S > &rhs) const
Outer product.
T c[n *m]
The data as a one dimensional array.
Mtype & gaussian_random(base_type width=1.0)
Fills Matrix with gaussian random elements.
R dot(const Matrix< p, q, S > &rhs) const
Dot product.
std::string str(int prec=8, char separator=' ') const
hila::arithmetic_type< T > squarenorm() const
Calculate square norm - sum of squared elements.
Matrix class which defines matrix operations.
void gaussian_random(T width=1.0)
gaussian random
const WilsonVector_t & operator+() const
unary +
auto outer_product(const Wilson_vector_t< Nvectors, N, S > &rhs) const
WilsonVector_t conj() const
complex conjugate
WilsonVector_t & fill(const S rhs)
fill method
WilsonVector_t & operator*=(const S rhs)
Mul assign by scalar.
T squarenorm() const
norms
Array< N *Nvectors, 1, T > & asArray()
cast to Array
WilsonVector_t & operator-=(const WilsonVector_t< Nvectors, N, S > &rhs)
Sub assign from Wvec.
WilsonVector_t & operator+=(const WilsonVector_t< Nvectors, N, S > &rhs)
Add assign from Wvec.
WilsonVector_t & operator=(const std::nullptr_t &z)
assign from 0
WilsonVector_t operator-() const
unary -
WilsonVector_t & operator=(const WilsonVector_t< Nvectors, N, S > &rhs)
Assign from WilsonVector.
WilsonVector_t & operator/=(const S rhs)
Div assign by scalar.
Definition of Complex types.
constexpr Imaginary_t< double > I(1.0)
Imaginary unit I - global variable.
This header file defines:
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
Definition of Matrix types.