QUDA  0.9.0
gamma.cuh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <complex_quda.h>
4 
5 namespace quda {
6 
7  //A simple Euclidean gamma matrix class for use with the Wilson projectors.
8  template <typename ValueType, QudaGammaBasis basis, int dir>
9  class Gamma {
10  private:
11  const int ndim;
12 
13  protected:
14 
15 
16  //Which gamma matrix (dir = 0,4)
17  //dir = 0: gamma^1, dir = 1: gamma^2, dir = 2: gamma^3, dir = 3: gamma^4, dir =4: gamma^5
18  //int dir;
19 
20  //The basis to be used.
21  //QUDA_DEGRAND_ROSSI_GAMMA_BASIS is the chiral basis
22  //QUDA_UKQCD_GAMMA_BASIS is the non-relativistic basis.
23  //QudaGammaBasis basis;
24 
25  //The column with the non-zero element for each row
26  int coupling[4];
27  //The value of the matrix element, for each row
28  complex<ValueType> elem[4];
29 
30  public:
31 
32  __device__ __host__ Gamma() : ndim(4) {
33  complex<ValueType> I(0,1);
34  if((dir==0) || (dir==1)) {
35  coupling[0] = 3;
36  coupling[1] = 2;
37  coupling[2] = 1;
38  coupling[3] = 0;
39  } else if (dir == 2) {
40  coupling[0] = 2;
41  coupling[1] = 3;
42  coupling[2] = 0;
43  coupling[3] = 1;
44  } else if ((dir == 3) && (basis == QUDA_DEGRAND_ROSSI_GAMMA_BASIS)) {
45  coupling[0] = 2;
46  coupling[1] = 3;
47  coupling[2] = 0;
48  coupling[3] = 1;
49  } else if ((dir == 3) && (basis == QUDA_UKQCD_GAMMA_BASIS)) {
50  coupling[0] = 0;
51  coupling[1] = 1;
52  coupling[2] = 2;
53  coupling[3] = 3;
54  } else if ((dir == 4) && (basis == QUDA_DEGRAND_ROSSI_GAMMA_BASIS)) {
55  coupling[0] = 0;
56  coupling[1] = 1;
57  coupling[2] = 2;
58  coupling[3] = 3;
59  } else if ((dir == 4) && (basis == QUDA_UKQCD_GAMMA_BASIS)) {
60  coupling[0] = 2;
61  coupling[1] = 3;
62  coupling[2] = 0;
63  coupling[3] = 1;
64  } else {
65  printf("Warning: Gamma matrix not defined for dir = %d and basis = %d\n", dir, basis);
66  coupling[0] = 0;
67  coupling[1] = 0;
68  coupling[2] = 0;
69  coupling[3] = 0;
70  }
71 
72 
73  if((dir==0)) {
74  elem[0] = I;
75  elem[1] = I;
76  elem[2] = -I;
77  elem[3] = -I;
78  } else if((dir==1) && (basis == QUDA_DEGRAND_ROSSI_GAMMA_BASIS)) {
79  elem[0] = -1;
80  elem[1] = 1;
81  elem[2] = 1;
82  elem[3] = -1;
83  } else if((dir==1) && (basis == QUDA_UKQCD_GAMMA_BASIS)) {
84  elem[0] = 1;
85  elem[1] = -1;
86  elem[2] = -1;
87  elem[3] = 1;
88  } else if((dir==2)) {
89  elem[0] = I;
90  elem[1] = -I;
91  elem[2] = -I;
92  elem[3] = I;
93  } else if((dir==3) && (basis == QUDA_DEGRAND_ROSSI_GAMMA_BASIS)) {
94  elem[0] = 1;
95  elem[1] = 1;
96  elem[2] = 1;
97  elem[3] = 1;
98  } else if((dir==3) && (basis == QUDA_UKQCD_GAMMA_BASIS)) {
99  elem[0] = 1;
100  elem[1] = 1;
101  elem[2] = -1;
102  elem[3] = -1;
103  } else if((dir==4) && (basis == QUDA_DEGRAND_ROSSI_GAMMA_BASIS)) {
104  elem[0] = -1;
105  elem[1] = -1;
106  elem[2] = 1;
107  elem[3] = 1;
108  } else if((dir==4) && (basis == QUDA_UKQCD_GAMMA_BASIS)) {
109  elem[0] = 1;
110  elem[1] = 1;
111  elem[2] = 1;
112  elem[3] = 1;
113  } else {
114  elem[0] = 0;
115  elem[1] = 0;
116  elem[2] = 0;
117  elem[3] = 0;
118  }
119  }
120 
121  Gamma(const Gamma &g) : ndim(4) {
122  for(int i = 0; i < ndim+1; i++) {
123  coupling[i] = g.coupling[i];
124  elem[i] = g.elem[i];
125  }
126  }
127 
128  __device__ __host__ ~Gamma() {}
129 
130  //Returns the matrix element.
131  __device__ __host__ inline complex<ValueType> getelem(int row, int col) const {
132  return coupling[row] == col ? elem[row] : 0;
133  }
134 
135  //Like getelem, but one only needs to specify the row.
136  //The column of the non-zero component is returned via the "col" reference
137  __device__ __host__ inline complex<ValueType> getrowelem(int row, int &col) const {
138  col = coupling[row];
139  return elem[row];
140  }
141 
142  //Returns the type of Gamma matrix
143  inline int Dir() const {
144  return dir;
145  }
146  };
147 
148 } // namespace quda
int Dir() const
Definition: gamma.cuh:143
__device__ __host__ Gamma()
Definition: gamma.cuh:32
__device__ __host__ complex< ValueType > getrowelem(int row, int &col) const
Definition: gamma.cuh:137
int printf(const char *,...) __attribute__((__format__(__printf__
complex< ValueType > elem[4]
Definition: gamma.cuh:28
__device__ __host__ complex< ValueType > getelem(int row, int col) const
Definition: gamma.cuh:131
Gamma(const Gamma &g)
Definition: gamma.cuh:121
int coupling[4]
Definition: gamma.cuh:26
__device__ __host__ ~Gamma()
Definition: gamma.cuh:128
const int ndim
Definition: gamma.cuh:11