17 template<
typename Float,
typename T>
struct colorspinor_wrapper;
18 template<
typename Float,
typename T>
struct colorspinor_ghost_wrapper;
23 template <
typename Float,
int Nc,
int Ns>
26 static constexpr
int size = Nc * Ns;
32 for (
int i = 0; i <
size; i++) {
data[i] = 0; }
65 for (
int i = 0; i <
size; i++) {
data[i] *= a; }
73 for (
int i = 0; i < Nc * Ns; i++) {
data[i] -= a.
data[i]; }
123 __device__ __host__
void print()
const
125 for (
int s=0; s<Ns; s++) {
126 for (
int c=0; c<Nc; c++) {
127 printf(
"s=%d c=%d %e %e\n", s, c,
data[s*Nc+c].real(),
data[s*Nc+c].imag());
138 static constexpr
int Ns = 4;
139 static constexpr
int size = Nc * Ns;
145 for (
int i = 0; i <
size; i++) {
data[i] = 0; }
163 for (
int i = 0; i <
size; i++) {
data[i] += a.
data[i]; }
170 for (
int i = 0; i <
size; i++) {
data[i] *= a; }
181 const auto &t = *
this;
186 for (
int i=0; i<Nc; i++) {
187 a(0, i) =
i_(t(3, i));
188 a(1, i) =
i_(t(2, i));
189 a(2, i) = -
i_(t(1, i));
190 a(3, i) = -
i_(t(0, i));
195 for (
int i=0; i<Nc; i++) {
204 for (
int i=0; i<Nc; i++) {
205 a(0, i) =
i_(t(2, i));
206 a(1, i) = -
i_(t(3, i));
207 a(2, i) = -
i_(t(0, i));
208 a(3, i) =
i_(t(1, i));
213 for (
int i=0; i<Nc; i++) {
222 for (
int i=0; i<Nc; i++) {
241 const auto &t = *
this;
246 for (
int i=0; i<Nc; i++) {
255 for (
int i=0; i<Nc; i++) {
256 a(0, i) =
i_(t(3, i));
257 a(1, i) = -
i_(t(2, i));
258 a(2, i) = -
i_(t(1, i));
259 a(3, i) =
i_(t(0, i));
264 for (
int i=0; i<Nc; i++) {
273 for (
int i=0; i<Nc; i++) {
274 a(0, i) =
i_(t(0, i));
275 a(1, i) =
i_(t(1, i));
276 a(2, i) = -
i_(t(2, i));
277 a(3, i) = -
i_(t(3, i));
282 for (
int i=0; i<Nc; i++) {
283 a(0, i) =
i_(t(2, i));
284 a(1, i) =
i_(t(3, i));
285 a(2, i) =
i_(t(0, i));
286 a(3, i) =
i_(t(1, i));
301 for (
int s=0; s<Ns/2; s++) {
303 for (
int c=0; c<Nc; c++) {
304 proj(s,c) = (*this)(chirality*Ns/2+s,c);
319 const auto &t = *
this;
325 for (
int i=0; i<Nc; i++) {
326 proj(0, i) = t(0, i) +
i_(t(3, i));
327 proj(1, i) = t(1, i) +
i_(t(2, i));
332 for (
int i=0; i<Nc; i++) {
333 proj(0, i) = t(0, i) -
i_(t(3, i));
334 proj(1, i) = t(1, i) -
i_(t(2, i));
343 for (
int i=0; i<Nc; i++) {
344 proj(0, i) = t(0, i) + t(3, i);
345 proj(1, i) = t(1, i) - t(2, i);
350 for (
int i=0; i<Nc; i++) {
351 proj(0, i) = t(0, i) - t(3, i);
352 proj(1, i) = t(1, i) + t(2, i);
361 for (
int i=0; i<Nc; i++) {
362 proj(0, i) = t(0, i) +
i_(t(2, i));
363 proj(1, i) = t(1, i) -
i_(t(3, i));
368 for (
int i=0; i<Nc; i++) {
369 proj(0, i) = t(0, i) -
i_(t(2, i));
370 proj(1, i) = t(1, i) +
i_(t(3, i));
379 for (
int i=0; i<Nc; i++) {
380 proj(0, i) = 2 * t(0, i);
381 proj(1, i) = 2 * t(1, i);
386 for (
int i=0; i<Nc; i++) {
387 proj(0, i) = 2 * t(2, i);
388 proj(1, i) = 2 * t(3, i);
397 for (
int i = 0; i < Nc; i++) {
398 proj(0, i) = t(0, i) + t(2, i);
399 proj(1, i) = t(1, i) + t(3, i);
404 for (
int i = 0; i < Nc; i++) {
405 proj(0, i) = t(0, i) - t(2, i);
406 proj(1, i) = t(1, i) - t(3, i);
461 for (
int i=0; i<Nc; i++) {
470 for (
int i=0; i<Nc; i++) {
479 for (
int i=0; i<Nc; i++) {
492 for (
int i=0; i<Nc; i++) {
501 for (
int i=0; i<Nc; i++) {
510 for (
int i=0; i<Nc; i++) {
523 for (
int i=0; i<Nc; i++) {
532 for (
int i=0; i<Nc; i++) {
541 for (
int i=0; i<Nc; i++) {
554 for (
int i=0; i<Nc; i++) {
563 for (
int i=0; i<Nc; i++) {
572 for (
int i=0; i<Nc; i++) {
635 for (
int c=0; c<Nc; c++) {
636 a(0,c) = (*this)(1,c)+(*
this)(3,c);
637 a(1,c) = -(*this)(2,c)-(*
this)(0,c);
638 a(2,c) = -(*this)(3,c)+(*
this)(1,c);
639 a(3,c) = -(*this)(0,c)+(*
this)(2,c);
647 __device__ __host__
inline void toRel() {
650 for (
int c=0; c<Nc; c++) {
651 a(0,c) = -(*this)(1,c)-(*
this)(3,c);
652 a(1,c) = (*this)(2,c)+(*
this)(0,c);
653 a(2,c) = (*this)(3,c)-(*
this)(1,c);
654 a(3,c) = (*this)(0,c)-(*
this)(2,c);
659 __device__ __host__
void print()
const
661 for (
int s=0; s<Ns; s++) {
662 for (
int c=0; c<Nc; c++) {
663 printf(
"s=%d c=%d %e %e\n", s, c,
data[s*Nc+c].real(),
data[s*Nc+c].imag());
673 template <
typename Float,
int Nc>
675 static constexpr
int Ns = 2;
676 static constexpr
int size = Ns * Nc;
681 for (
int i = 0; i <
size; i++) {
data[i] = 0; }
700 for (
int i = 0; i <
size; i++) {
data[i] += a.
data[i]; }
707 for (
int i = 0; i <
size; i++) {
data[i] *= a; }
718 for (
int s=0; s<Ns; s++) {
720 for (
int c=0; c<Nc; c++) {
721 recon(chirality*Ns+s,c) = (*this)(s,c);
736 const auto t = *
this;
743 for (
int i=0; i<Nc; i++) {
744 recon(0, i) = t(0, i);
745 recon(1, i) = t(1, i);
746 recon(2, i) = -
i_(t(1, i));
747 recon(3, i) = -
i_(t(0, i));
752 for (
int i=0; i<Nc; i++) {
753 recon(0, i) = t(0, i);
754 recon(1, i) = t(1, i);
755 recon(2, i) =
i_(t(1, i));
756 recon(3, i) =
i_(t(0, i));
765 for (
int i=0; i<Nc; i++) {
766 recon(0, i) = t(0, i);
767 recon(1, i) = t(1, i);
768 recon(2, i) = -t(1, i);
769 recon(3, i) = t(0, i);
774 for (
int i=0; i<Nc; i++) {
775 recon(0, i) = t(0, i);
776 recon(1, i) = t(1, i);
777 recon(2, i) = t(1, i);
778 recon(3, i) = -t(0, i);
787 for (
int i=0; i<Nc; i++) {
788 recon(0, i) = t(0, i);
789 recon(1, i) = t(1, i);
790 recon(2, i) = -
i_(t(0, i));
791 recon(3, i) =
i_(t(1, i));
796 for (
int i=0; i<Nc; i++) {
797 recon(0, i) = t(0, i);
798 recon(1, i) = t(1, i);
799 recon(2, i) =
i_(t(0, i));
800 recon(3, i) = -
i_(t(1, i));
809 for (
int i=0; i<Nc; i++) {
810 recon(0, i) = t(0, i);
811 recon(1, i) = t(1, i);
818 for (
int i=0; i<Nc; i++) {
821 recon(2, i) = t(0, i);
822 recon(3, i) = t(1, i);
831 for (
int i = 0; i < Nc; i++) {
832 recon(0, i) = t(0, i);
833 recon(1, i) = t(1, i);
834 recon(2, i) = t(0, i);
835 recon(3, i) = t(1, i);
840 for (
int i = 0; i < Nc; i++) {
841 recon(0, i) = t(0, i);
842 recon(1, i) = t(1, i);
843 recon(2, i) = -t(0, i);
844 recon(3, i) = -t(1, i);
895 __device__ __host__
void print()
const
897 for (
int s=0; s<Ns; s++) {
898 for (
int c=0; c<Nc; c++) {
899 printf(
"s=%d c=%d %e %e\n", s, c,
data[s*Nc+c].real(),
data[s*Nc+c].imag());
912 template <
typename Float,
int Nc,
int Ns>
918 for (
int s = 0; s < Ns; s++) { dot +=
innerProduct(a, b, s, s); }
929 template <
typename Float,
int Nc,
int Ns>
934 for (
int c = 0; c < Nc; c++) {
935 dot.
real(dot.
real() + a(sa, c).real() * b(sb, c).real());
936 dot.
real(dot.
real() - a(sa, c).imag() * b(sb, c).imag());
937 dot.
imag(dot.
imag() + a(sa, c).real() * b(sb, c).imag());
938 dot.
imag(dot.
imag() + a(sa, c).imag() * b(sb, c).real());
952 template <
typename Float,
int Nc,
int Ns>
968 template <
typename Float,
int Nc,
int Ns>
974 for (
int c = 0; c < Nc; c++) {
975 dot.
real(dot.
real() + a(sa, c).real() * b(sb, c).real());
976 dot.
real(dot.
real() + a(sa, c).imag() * b(sb, c).imag());
977 dot.
imag(dot.
imag() + a(sa, c).real() * b(sb, c).imag());
978 dot.
imag(dot.
imag() - a(sa, c).imag() * b(sb, c).real());
991 template <
typename Float,
int Nc,
int Nsa,
int Nsb>
997 for (
int c = 0; c < Nc; c++) {
998 dot.
real(dot.
real() + a(sa, c).real() * b(sb, c).real());
999 dot.
real(dot.
real() + a(sa, c).imag() * b(sb, c).imag());
1000 dot.
imag(dot.
imag() + a(sa, c).real() * b(sb, c).imag());
1001 dot.
imag(dot.
imag() - a(sa, c).imag() * b(sb, c).real());
1016 template <
typename Float,
int Ns>
1021 res(0, 0) = a(sa, 1) * b(sb, 2) - a(sa, 2) * b(sb, 1);
1022 res(0, 1) = a(sa, 2) * b(sb, 0) - a(sa, 0) * b(sb, 2);
1023 res(0, 2) = a(sa, 0) * b(sb, 1) - a(sa, 1) * b(sb, 0);
1034 template <
typename Float,
int Nc,
int Ns>
1042 for (
int i = 0; i < Nc; i++) {
1044 for (
int j = 0; j < Nc; j++) {
1046 out(j, i).real(a(0, j).real() * b(0, i).real());
1047 out(j, i).real(out(j, i).real() + a(0, j).imag() * b(0, i).imag());
1048 out(j, i).imag(a(0, j).imag() * b(0, i).real());
1049 out(j, i).imag(out(j, i).imag() - a(0, j).real() * b(0, i).imag());
1053 for (
int s=1; s<Ns; s++) {
1054 out(j,i).real( out(j,i).real() + a(s,j).real() * b(s,i).real() );
1055 out(j,i).real( out(j,i).real() + a(s,j).imag() * b(s,i).imag() );
1056 out(j,i).imag( out(j,i).imag() + a(s,j).imag() * b(s,i).real() );
1057 out(j,i).imag( out(j,i).imag() - a(s,j).real() * b(s,i).imag() );
1072 template <
typename Float,
int Nc>
1080 for (
int i = 0; i < Nc; i++) {
1082 for (
int j = 0; j < Nc; j++) {
1084 out(j, i).real(a(0, j).real() * b(0, i).real());
1085 out(j, i).real(out(j, i).real() + a(0, j).imag() * b(0, i).imag());
1086 out(j, i).imag(a(0, j).imag() * b(0, i).real());
1087 out(j, i).imag(out(j, i).imag() - a(0, j).real() * b(0, i).imag());
1100 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline
1106 for (
int i=0; i<Nc; i++) {
1108 for (
int s=0; s<Ns; s++) {
1109 z.
data[s*Nc + i] = x.
data[s*Nc + i] + y.
data[s*Nc + i];
1122 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline
1128 for (
int i=0; i<Nc; i++) {
1130 for (
int s=0; s<Ns; s++) {
1131 z.
data[s*Nc + i] = x.
data[s*Nc + i] - y.
data[s*Nc + i];
1144 template<
typename Float,
int Nc,
int Ns,
typename S> __device__ __host__
inline
1150 for (
int i=0; i<Nc; i++) {
1152 for (
int s=0; s<Ns; s++) {
1153 y.
data[s*Nc + i] = a * x.
data[s*Nc + i];
1166 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline
1172 for (
int i=0; i<Nc; i++) {
1174 for (
int s=0; s<Ns; s++) {
1181 for (
int j=1; j<Nc; j++) {
1183 for (
int s=0; s<Ns; s++) {
1202 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline
1208 for (
int i=0; i<Nc; i++) {
1210 for (
int s=0; s<Ns; s++) {
1217 for (
int j=1; j<Nc; j++) {
1219 for (
int s=0; s<Ns; s++) {
1237 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline
1241 constexpr
int N = Ns * Nc;
1244 for (
int i=0; i<N; i++) {
1255 for (
int j=1; j<N; j++) {
Specialized container for Hermitian matrices (e.g., used for wrapping clover matrices)
__device__ __host__ Matrix< complex< Float >, Nc > outerProduct(const ColorSpinor< Float, Nc, 1 > &a, const ColorSpinor< Float, Nc, 1 > &b)
__device__ __host__ ColorSpinor< Float, Nc, Ns > operator*(const S &a, const ColorSpinor< Float, Nc, Ns > &x)
Compute the scalar-vector product y = a * x.
__device__ __host__ ColorSpinor< Float, Nc, Ns > mv_add(const Matrix< complex< Float >, Nc > &A, const ColorSpinor< Float, Nc, Ns > &x, const ColorSpinor< Float, Nc, Ns > &y)
Compute the matrix-vector product z = A * x + y.
__device__ __host__ complex< Float > innerProduct(const ColorSpinor< Float, Nc, Ns > &a, const ColorSpinor< Float, Nc, Ns > &b)
Compute the inner product over color and spin dot = \sum_s,c conj(a(s,c)) * b(s,c)
__device__ __host__ complex< Float > colorContract(const ColorSpinor< Float, Nc, Ns > &a, const ColorSpinor< Float, Nc, Ns > &b, int sa, int sb)
Compute the color contraction over color at spin s dot = \sum_s,c a(s,c) * b(s,c)
__device__ __host__ ColorSpinor< Float, Nc, Ns > operator+(const ColorSpinor< Float, Nc, Ns > &x, const ColorSpinor< Float, Nc, Ns > &y)
ColorSpinor addition operator.
__device__ __host__ ColorSpinor< Float, 3, 1 > crossProduct(const ColorSpinor< Float, 3, Ns > &a, const ColorSpinor< Float, 3, Ns > &b, int sa, int sb)
__host__ __device__ complex< real > i_(const complex< real > &a)
__device__ __host__ Matrix< complex< Float >, Nc > outerProdSpinTrace(const ColorSpinor< Float, Nc, Ns > &a, const ColorSpinor< Float, Nc, Ns > &b)
__device__ __host__ ColorSpinor< Float, Nc, Ns > operator-(const ColorSpinor< Float, Nc, Ns > &x, const ColorSpinor< Float, Nc, Ns > &y)
ColorSpinor subtraction operator.
FloatingPoint< float > Float
__device__ __host__ complex< Float > & operator()(int idx)
1-d accessor functor
__device__ __host__ const complex< Float > & operator()(int s, int c) const
2-d accessor functor
__device__ __host__ void print() const
__device__ __host__ void operator=(const colorspinor_ghost_wrapper< Float, S > &s)
__device__ __host__ ColorSpinor< Float, Nc, 2 > & operator+=(const ColorSpinor< Float, Nc, 2 > &a)
__device__ __host__ void operator=(const colorspinor_wrapper< Float, S > &s)
__device__ __host__ const complex< Float > & operator()(int idx) const
1-d accessor functor
__device__ __host__ ColorSpinor< Float, Nc, 4 > chiral_reconstruct(int chirality) const
Reconstruct two-component spinor to a four-component spinor.
__device__ __host__ ColorSpinor< Float, Nc, 2 > & operator*=(const T &a)
__device__ __host__ ColorSpinor< Float, Nc, 4 > reconstruct(int dim, int sign) const
Spin reconstruct the full Spinor from the projected spinor.
__device__ __host__ ColorSpinor< Float, Nc, 2 > & operator=(const ColorSpinor< Float, Nc, 2 > &a)
__device__ __host__ complex< Float > & operator()(int s, int c)
2-d accessor functor
complex< Float > data[size]
__device__ __host__ ColorSpinor< Float, Nc, 4 > igamma(int dim)
__device__ __host__ void operator=(const colorspinor_ghost_wrapper< Float, S > &s)
__device__ __host__ ColorSpinor< Float, Nc, 4 > & operator+=(const ColorSpinor< Float, Nc, 4 > &a)
complex< Float > data[size]
__device__ __host__ void toRel()
Transform from non-relativistic into relavisitic basis.
__device__ __host__ complex< Float > & operator()(int s, int c)
2-d accessor functor
__device__ __host__ const complex< Float > & operator()(int s, int c) const
2-d accessor functor
__device__ __host__ ColorSpinor< Float, Nc, 4 > sigma(int mu, int nu)
__device__ __host__ ColorSpinor< Float, Nc, 4 > & operator=(const ColorSpinor< Float, Nc, 4 > &a)
__device__ __host__ ColorSpinor< Float, Nc, 2 > chiral_project(int chirality) const
Project four-component spinor to either chirality.
__device__ __host__ void operator=(const colorspinor_wrapper< Float, S > &s)
__device__ __host__ const complex< Float > & operator()(int idx) const
1-d accessor functor
__device__ __host__ void toNonRel()
Transform from relativistic into non-relavisitic basis Required normalization factor of 1/2 included ...
__device__ __host__ ColorSpinor< Float, Nc, 2 > project(int dim, int sign) const
__device__ __host__ ColorSpinor< Float, Nc, 4 > gamma(int dim)
__device__ __host__ complex< Float > & operator()(int idx)
1-d accessor functor
__device__ __host__ void print() const
__device__ __host__ ColorSpinor< Float, Nc, 4 > & operator*=(const T &a)
__device__ __host__ void operator=(const colorspinor_wrapper< Float, S > &s)
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator=(const ColorSpinor< Float, Nc, Ns > &a)
__device__ __host__ const complex< Float > & operator()(int s, int c) const
2-d accessor functor
__device__ __host__ complex< Float > & operator()(int idx)
1-d accessor functor
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator+=(const ColorSpinor< Float, Nc, Ns > &a)
__device__ __host__ const complex< Float > & operator()(int idx) const
1-d accessor functor
__device__ __host__ void operator=(const colorspinor_ghost_wrapper< Float, S > &s)
complex< Float > data[size]
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator-=(const ColorSpinor< Float, Nc, Ns > &a)
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator*=(const T &a)
__device__ __host__ complex< Float > & operator()(int s, int c)
2-d accessor functor
__device__ __host__ void print() const
Prints the NsxNc complex elements of the color spinor.
__device__ __host__ ColorSpinor< Float, Nc, Ns > operator-() const
static constexpr int size
colorspinor_ghost_wrapper is an internal class that is used to wrap instances of colorspinor accessor...
colorspinor_wrapper is an internal class that is used to wrap instances of colorspinor accessors,...
__host__ __device__ ValueType imag() const volatile
__host__ __device__ ValueType real() const volatile