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; }
37 for (
int i = 0; i <
size; i++) { data[i] = a.
data[i]; }
43 for (
int i = 0; i <
size; i++) { data[i] = a.
data[i]; }
52 for (
int i = 0; i <
size; i++) { a.
data[i] = -data[i]; }
58 for (
int i = 0; i <
size; i++) { data[i] += a.
data[i]; }
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]; }
96 __device__ __host__
inline complex<Float>&
operator()(
int s,
int c) {
return data[s*Nc + c]; }
104 __device__ __host__
inline const complex<Float>&
operator()(
int s,
int c)
const {
return data[s*Nc + c]; }
111 __device__ __host__
inline complex<Float>&
operator()(
int idx) {
return data[idx]; }
118 __device__ __host__
inline const complex<Float>&
operator()(
int idx)
const {
return data[idx]; }
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());
137 template <
typename Float,
int Nc>
struct ColorSpinor<Float, Nc, 4> {
138 static constexpr
int Ns = 4;
139 static constexpr
int size = Nc * Ns;
145 for (
int i = 0; i <
size; i++) { data[i] = 0; }
150 for (
int i = 0; i <
size; i++) { data[i] = a.
data[i]; }
156 for (
int i = 0; i <
size; i++) { data[i] = a.
data[i]; }
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 complex<Float> j(0.0,1.0);
186 for (
int i=0; i<Nc; i++) {
187 a(0,i) = j*(*this)(3,i);
188 a(1,i) = j*(*this)(2,i);
189 a(2,i) = -j*(*this)(1,i);
190 a(3,i) = -j*(*this)(0,i);
195 for (
int i=0; i<Nc; i++) {
196 a(0,i) = (*this)(3,i);
197 a(1,i) = -(*this)(2,i);
198 a(2,i) = -(*this)(1,i);
199 a(3,i) = (*this)(0,i);
204 for (
int i=0; i<Nc; i++) {
205 a(0,i) = j*(*this)(2,i);
206 a(1,i) = -j*(*this)(3,i);
207 a(2,i) = -j*(*this)(0,i);
208 a(3,i) = j*(*this)(1,i);
213 for (
int i=0; i<Nc; i++) {
214 a(0,i) = (*this)(0,i);
215 a(1,i) = (*this)(1,i);
216 a(2,i) = -(*this)(2,i);
217 a(3,i) = -(*this)(3,i);
222 for (
int i=0; i<Nc; i++) {
223 a(0,i) = (*this)(2,i);
224 a(1,i) = (*this)(3,i);
225 a(2,i) = (*this)(0,i);
226 a(3,i) = (*this)(1,i);
241 complex<Float> j(0.0,1.0);
246 for (
int i=0; i<Nc; i++) {
247 a(0,i) = -(*this)(3,i);
248 a(1,i) = -(*this)(2,i);
249 a(2,i) = (*this)(1,i);
250 a(3,i) = (*this)(0,i);
255 for (
int i=0; i<Nc; i++) {
256 a(0,i) = j*(*this)(3,i);
257 a(1,i) = -j*(*this)(2,i);
258 a(2,i) = -j*(*this)(1,i);
259 a(3,i) = j*(*this)(0,i);
264 for (
int i=0; i<Nc; i++) {
265 a(0,i) = -(*this)(2,i);
266 a(1,i) = (*this)(3,i);
267 a(2,i) = (*this)(0,i);
268 a(3,i) = -(*this)(1,i);
273 for (
int i=0; i<Nc; i++) {
274 a(0,i) = j*(*this)(0,i);
275 a(1,i) = j*(*this)(1,i);
276 a(2,i) = -j*(*this)(2,i);
277 a(3,i) = -j*(*this)(3,i);
282 for (
int i=0; i<Nc; i++) {
283 a(0,i) = complex<Float>(-(*this)(2,i).imag(), (*this)(2,i).real());
284 a(1,i) = complex<Float>(-(*this)(3,i).imag(), (*this)(3,i).real());
285 a(2,i) = complex<Float>(-(*this)(0,i).imag(), (*this)(0,i).real());
286 a(3,i) = complex<Float>(-(*this)(1,i).imag(), (*this)(1,i).real());
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 complex<Float> j(0.0,1.0);
326 for (
int i=0; i<Nc; i++) {
327 proj(0,i) = (*this)(0,i) + j * (*
this)(3,i);
328 proj(1,i) = (*this)(1,i) + j * (*
this)(2,i);
333 for (
int i=0; i<Nc; i++) {
334 proj(0,i) = (*this)(0,i) - j * (*
this)(3,i);
335 proj(1,i) = (*this)(1,i) - j * (*
this)(2,i);
344 for (
int i=0; i<Nc; i++) {
345 proj(0,i) = (*this)(0,i) + (*
this)(3,i);
346 proj(1,i) = (*this)(1,i) - (*
this)(2,i);
351 for (
int i=0; i<Nc; i++) {
352 proj(0,i) = (*this)(0,i) - (*
this)(3,i);
353 proj(1,i) = (*this)(1,i) + (*
this)(2,i);
362 for (
int i=0; i<Nc; i++) {
363 proj(0,i) = (*this)(0,i) + j * (*
this)(2,i);
364 proj(1,i) = (*this)(1,i) - j * (*
this)(3,i);
369 for (
int i=0; i<Nc; i++) {
370 proj(0,i) = (*this)(0,i) - j * (*
this)(2,i);
371 proj(1,i) = (*this)(1,i) + j * (*
this)(3,i);
380 for (
int i=0; i<Nc; i++) {
381 proj(0,i) = 2*(*this)(0,i);
382 proj(1,i) = 2*(*this)(1,i);
387 for (
int i=0; i<Nc; i++) {
388 proj(0,i) = 2*(*this)(2,i);
389 proj(1,i) = 2*(*this)(3,i);
398 for (
int i = 0; i < Nc; i++) {
399 proj(0, i) = (*this)(0, i) + (*
this)(2, i);
400 proj(1, i) = (*this)(1, i) + (*
this)(3, i);
405 for (
int i = 0; i < Nc; i++) {
406 proj(0, i) = (*this)(0, i) - (*
this)(2, i);
407 proj(1, i) = (*this)(1, i) - (*
this)(3, i);
455 complex<Float> j(0.0,1.0);
462 for (
int i=0; i<Nc; i++) {
471 for (
int i=0; i<Nc; i++) {
480 for (
int i=0; i<Nc; i++) {
493 for (
int i=0; i<Nc; i++) {
502 for (
int i=0; i<Nc; i++) {
511 for (
int i=0; i<Nc; i++) {
524 for (
int i=0; i<Nc; i++) {
533 for (
int i=0; i<Nc; i++) {
542 for (
int i=0; i<Nc; i++) {
555 for (
int i=0; i<Nc; i++) {
564 for (
int i=0; i<Nc; i++) {
573 for (
int i=0; i<Nc; i++) {
593 __device__ __host__
inline complex<Float>&
operator()(
int s,
int c) {
return data[s*Nc + c]; }
601 __device__ __host__
inline const complex<Float>&
operator()(
int s,
int c)
const {
return data[s*Nc + c]; }
608 __device__ __host__
inline complex<Float>&
operator()(
int idx) {
return data[idx]; }
615 __device__ __host__
inline const complex<Float>&
operator()(
int idx)
const {
return data[idx]; }
636 for (
int c=0; c<Nc; c++) {
637 a(0,c) = (*this)(1,c)+(*
this)(3,c);
638 a(1,c) = -(*this)(2,c)-(*
this)(0,c);
639 a(2,c) = -(*this)(3,c)+(*
this)(1,c);
640 a(3,c) = -(*this)(0,c)+(*
this)(2,c);
648 __device__ __host__
inline void toRel() {
651 for (
int c=0; c<Nc; c++) {
652 a(0,c) = -(*this)(1,c)-(*
this)(3,c);
653 a(1,c) = (*this)(2,c)+(*
this)(0,c);
654 a(2,c) = (*this)(3,c)-(*
this)(1,c);
655 a(3,c) = (*this)(0,c)-(*
this)(2,c);
660 __device__ __host__
void print()
const 662 for (
int s=0; s<Ns; s++) {
663 for (
int c=0; c<Nc; c++) {
664 printf(
"s=%d c=%d %e %e\n", s, c, data[s*Nc+c].real(), data[s*Nc+c].imag());
674 template <
typename Float,
int Nc>
676 static constexpr
int Ns = 2;
677 static constexpr
int size = Ns * Nc;
682 for (
int i = 0; i <
size; i++) { data[i] = 0; }
687 for (
int i = 0; i <
size; i++) { data[i] = a.
data[i]; }
694 for (
int i = 0; i <
size; i++) { data[i] = a.
data[i]; }
701 for (
int i = 0; i <
size; i++) { data[i] += a.
data[i]; }
708 for (
int i = 0; i <
size; i++) { data[i] *= a; }
719 for (
int s=0;
s<Ns;
s++) {
721 for (
int c=0; c<Nc; c++) {
722 recon(chirality*Ns+
s,c) = (*this)(
s,c);
737 complex<Float> j(0.0,1.0);
744 for (
int i=0; i<Nc; i++) {
745 recon(0,i) = (*this)(0,i);
746 recon(1,i) = (*this)(1,i);
747 recon(2,i) = -j*(*this)(1,i);
748 recon(3,i) = -j*(*this)(0,i);
753 for (
int i=0; i<Nc; i++) {
754 recon(0,i) = (*this)(0,i);
755 recon(1,i) = (*this)(1,i);
756 recon(2,i) = j*(*this)(1,i);
757 recon(3,i) = j*(*this)(0,i);
766 for (
int i=0; i<Nc; i++) {
767 recon(0,i) = (*this)(0,i);
768 recon(1,i) = (*this)(1,i);
769 recon(2,i) = -(*this)(1,i);
770 recon(3,i) = (*this)(0,i);
775 for (
int i=0; i<Nc; i++) {
776 recon(0,i) = (*this)(0,i);
777 recon(1,i) = (*this)(1,i);
778 recon(2,i) = (*this)(1,i);
779 recon(3,i) = -(*this)(0,i);
788 for (
int i=0; i<Nc; i++) {
789 recon(0,i) = (*this)(0,i);
790 recon(1,i) = (*this)(1,i);
791 recon(2,i) = -j*(*this)(0,i);
792 recon(3,i) = j*(*this)(1,i);
797 for (
int i=0; i<Nc; i++) {
798 recon(0,i) = (*this)(0,i);
799 recon(1,i) = (*this)(1,i);
800 recon(2,i) = j*(*this)(0,i);
801 recon(3,i) = -j*(*this)(1,i);
810 for (
int i=0; i<Nc; i++) {
811 recon(0,i) = (*this)(0,i);
812 recon(1,i) = (*this)(1,i);
819 for (
int i=0; i<Nc; i++) {
822 recon(2,i) = (*this)(0,i);
823 recon(3,i) = (*this)(1,i);
832 for (
int i = 0; i < Nc; i++) {
833 recon(0, i) = (*this)(0, i);
834 recon(1, i) = (*this)(1, i);
835 recon(2, i) = (*this)(0, i);
836 recon(3, i) = (*this)(1, i);
841 for (
int i = 0; i < Nc; i++) {
842 recon(0, i) = (*this)(0, i);
843 recon(1, i) = (*this)(1, i);
844 recon(2, i) = -(*this)(0, i);
845 recon(3, i) = -(*this)(1, i);
860 __device__ __host__
inline complex<Float>&
operator()(
int s,
int c) {
return data[s*Nc + c]; }
868 __device__ __host__
inline const complex<Float>&
operator()(
int s,
int c)
const {
return data[s*Nc + c]; }
875 __device__ __host__
inline complex<Float>&
operator()(
int idx) {
return data[idx]; }
882 __device__ __host__
inline const complex<Float>&
operator()(
int idx)
const {
return data[idx]; }
896 __device__ __host__
void print()
const 898 for (
int s=0; s<Ns; s++) {
899 for (
int c=0; c<Nc; c++) {
900 printf(
"s=%d c=%d %e %e\n", s, c, data[s*Nc+c].real(), data[s*Nc+c].imag());
913 template <
typename Float,
int Nc,
int Ns>
917 complex<Float>
dot = 0;
931 template <
typename Float,
int Nc,
int Ns>
947 template <
typename Float,
int Nc,
int Ns>
951 complex<Float>
dot = 0;
953 for (
int c = 0; c < Nc; c++) {
954 dot.x += a(sa, c).real() * b(sb, c).real();
955 dot.x += a(sa, c).imag() * b(sb, c).imag();
956 dot.y += a(sa, c).real() * b(sb, c).imag();
957 dot.y -= a(sa, c).imag() * b(sb, c).real();
970 template <
typename Float,
int Nc,
int Ns>
984 template <
typename Float,
int Nc,
int Ns>
989 Matrix<complex<Float>, Nc>
out;
993 for (
int i = 0; i < Nc; i++) {
995 for (
int j = 0; j < Nc; j++) {
997 out(j, i).real(a(0, j).real() * b(0, i).real());
998 out(j, i).real(
out(j, i).real() + a(0, j).imag() * b(0, i).imag());
999 out(j, i).imag(a(0, j).imag() * b(0, i).real());
1000 out(j, i).imag(
out(j, i).imag() - a(0, j).real() * b(0, i).imag());
1004 for (
int s=1;
s<Ns;
s++) {
1005 out(j,i).real(
out(j,i).real() + a(
s,j).real() * b(
s,i).real() );
1006 out(j,i).real(
out(j,i).real() + a(
s,j).imag() * b(
s,i).imag() );
1007 out(j,i).imag(
out(j,i).imag() + a(
s,j).imag() * b(
s,i).real() );
1008 out(j,i).imag(
out(j,i).imag() - a(
s,j).real() * b(
s,i).imag() );
1022 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline 1028 for (
int i=0; i<Nc; i++) {
1030 for (
int s=0;
s<Ns;
s++) {
1044 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline 1050 for (
int i=0; i<Nc; i++) {
1052 for (
int s=0;
s<Ns;
s++) {
1066 template<
typename Float,
int Nc,
int Ns,
typename S> __device__ __host__
inline 1072 for (
int i=0; i<Nc; i++) {
1074 for (
int s=0;
s<Ns;
s++) {
1088 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline 1094 for (
int i=0; i<Nc; i++) {
1096 for (
int s=0;
s<Ns;
s++) {
1097 y.
data[
s*Nc + i].x = A(i,0).real() * x.
data[
s*Nc + 0].real();
1098 y.
data[
s*Nc + i].x -= A(i,0).imag() * x.
data[
s*Nc + 0].imag();
1099 y.
data[
s*Nc + i].y = A(i,0).real() * x.
data[
s*Nc + 0].imag();
1100 y.
data[
s*Nc + i].y += A(i,0).imag() * x.
data[
s*Nc + 0].real();
1103 for (
int j=1; j<Nc; j++) {
1105 for (
int s=0;
s<Ns;
s++) {
1106 y.
data[
s*Nc + i].x += A(i,j).real() * x.
data[
s*Nc + j].real();
1107 y.
data[
s*Nc + i].x -= A(i,j).imag() * x.
data[
s*Nc + j].imag();
1108 y.
data[
s*Nc + i].y += A(i,j).real() * x.
data[
s*Nc + j].imag();
1109 y.
data[
s*Nc + i].y += A(i,j).imag() * x.
data[
s*Nc + j].real();
1123 template<
typename Float,
int Nc,
int Ns> __device__ __host__
inline 1127 constexpr
int N = Ns * Nc;
1130 for (
int i=0; i<N; i++) {
1132 y.
data[i].x = A(i,0).real() * x.
data[0].real();
1133 y.
data[i].y = A(i,0).real() * x.
data[0].imag();
1135 y.
data[i].x = A(i,0).real() * x.
data[0].real();
1136 y.
data[i].x -= A(i,0).imag() * x.
data[0].imag();
1137 y.
data[i].y = A(i,0).real() * x.
data[0].imag();
1138 y.
data[i].y += A(i,0).imag() * x.
data[0].real();
1141 for (
int j=1; j<N; j++) {
1143 y.
data[i].x += A(i,j).real() * x.
data[j].real();
1144 y.
data[i].y += A(i,j).real() * x.
data[j].imag();
1146 y.
data[i].x += A(i,j).real() * x.
data[j].real();
1147 y.
data[i].x -= A(i,j).imag() * x.
data[j].imag();
1148 y.
data[i].y += A(i,j).real() * x.
data[j].imag();
1149 y.
data[i].y += A(i,j).imag() * x.
data[j].real();
__device__ __host__ ColorSpinor< Float, Nc, 2 > & operator=(const ColorSpinor< Float, Nc, 2 > &a)
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator+=(const ColorSpinor< Float, Nc, Ns > &a)
__device__ __host__ ColorSpinor< Float, Nc, 2 > chiral_project(int chirality) const
Project four-component spinor to either chirality.
__device__ __host__ void toNonRel()
Transform from relativistic into non-relavisitic basis Required normalization factor of 1/2 included ...
__device__ __host__ ColorSpinor< Float, Nc, 2 > & operator+=(const ColorSpinor< Float, Nc, 2 > &a)
__device__ __host__ ColorSpinor< Float, Nc, 4 > gamma(int dim)
complex< Float > data[size]
complex< Float > data[size]
colorspinor_wrapper is an internal class that is used to wrap instances of colorspinor accessors...
__device__ __host__ void print() const
Prints the NsxNc complex elements of the color spinor.
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator-=(const ColorSpinor< Float, Nc, Ns > &a)
__device__ __host__ complex< Float > & operator()(int idx)
1-d accessor functor
__device__ __host__ complex< Float > & operator()(int idx)
1-d accessor functor
__device__ __host__ Matrix< complex< Float >, Nc > outerProdSpinTrace(const ColorSpinor< Float, Nc, Ns > &a, const ColorSpinor< Float, Nc, Ns > &b)
__device__ __host__ const complex< Float > & operator()(int s, int c) const
2-d accessor functor
__device__ __host__ ColorSpinor< Float, Nc, 4 > & operator*=(const T &a)
__device__ __host__ const complex< Float > & operator()(int idx) const
1-d accessor functor
This is just a dummy structure we use for trove to define the required structure size.
__device__ __host__ ColorSpinor< Float, Nc, 4 > & operator=(const ColorSpinor< Float, Nc, 4 > &a)
__device__ __host__ ColorSpinor< Float, Nc, 4 > sigma(int mu, int nu)
__device__ __host__ ColorSpinor< Float, Nc, 2 > & operator*=(const T &a)
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator*=(const T &a)
Specialized container for Hermitian matrices (e.g., used for wrapping clover matrices) ...
__device__ __host__ const complex< Float > & operator()(int idx) const
1-d accessor functor
__device__ __host__ const complex< Float > & operator()(int idx) const
1-d accessor functor
__device__ __host__ const complex< Float > & operator()(int s, int c) const
2-d accessor functor
__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 = ,c conj(a(s,c)) * b(s,c)
__device__ __host__ ColorSpinor< Float, Nc, 2 > project(int dim, int sign) const
__device__ __host__ ColorSpinor< Float, Nc, Ns > & operator=(const ColorSpinor< Float, Nc, Ns > &a)
__device__ __host__ ColorSpinor< Float, Nc, 4 > igamma(int dim)
__device__ __host__ void print() const
__device__ __host__ ColorSpinor< Float, Nc, 4 > reconstruct(int dim, int sign) const
Spin reconstruct the full Spinor from the projected spinor.
colorspinor_ghost_wrapper is an internal class that is used to wrap instances of colorspinor accessor...
__device__ __host__ void print() const
cpuColorSpinorField * out
__device__ __host__ complex< Float > & operator()(int idx)
1-d accessor functor
__device__ __host__ ColorSpinor< Float, Nc, Ns > operator+(const ColorSpinor< Float, Nc, Ns > &x, const ColorSpinor< Float, Nc, Ns > &y)
ColorSpinor addition operator.
complex< Float > data[size]
__device__ __host__ ColorSpinor< Float, Nc, Ns > operator-() const
__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, Ns > operator*(const S &a, const ColorSpinor< Float, Nc, Ns > &x)
Compute the scalar-vector product y = a * x.
__device__ __host__ const complex< Float > & operator()(int s, int c) const
2-d accessor functor
__device__ __host__ void toRel()
Transform from non-relativistic into relavisitic basis.
__device__ __host__ ColorSpinor< Float, Nc, 4 > & operator+=(const ColorSpinor< Float, Nc, 4 > &a)
__device__ __host__ complex< Float > & operator()(int s, int c)
2-d accessor functor
__device__ __host__ complex< Float > & operator()(int s, int c)
2-d accessor functor
static constexpr int size
__device__ __host__ complex< Float > & operator()(int s, int c)
2-d accessor functor
static void dot(sFloat *res, gFloat *a, sFloat *b)