Grid 0.7.0
Dirac.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: lib/qcd/spin/Dirac.h
6
7Copyright (C) 2015
8Copyright (C) 2016
9
10Author: Antonin Portelli <antonin.portelli@me.com>
11Author: Peter Boyle <paboyle@ph.ed.ac.uk>
12Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
13Author: paboyle <paboyle@ph.ed.ac.uk>
14
15This program is free software; you can redistribute it and/or modify
16it under the terms of the GNU General Public License as published by
17the Free Software Foundation; either version 2 of the License, or
18(at your option) any later version.
19
20This program is distributed in the hope that it will be useful,
21but WITHOUT ANY WARRANTY; without even the implied warranty of
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23GNU General Public License for more details.
24
25You should have received a copy of the GNU General Public License along
26with this program; if not, write to the Free Software Foundation, Inc.,
2751 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28
29See the full license in the file "LICENSE" in the top level distribution directory
30*************************************************************************************/
31 /* END LEGAL */
32#ifndef GRID_QCD_DIRAC_H
33#define GRID_QCD_DIRAC_H
34
35 // Gamma matrices using the code generated by the Mathematica notebook
36 // gamma-gen/gamma-gen.nb in Gamma.cc & Gamma.h
38#include <Grid/qcd/spin/Gamma.h>
39
41
42// Dirac algebra adjoint operator (not in to overload other adj)
43inline Gamma adj(const Gamma &g)
44{
45 return Gamma (Gamma::adj[g.g]);
46}
47
48
49
50// Dirac algebra mutliplication operator
51inline Gamma operator*(const Gamma &g1, const Gamma &g2)
52{
53 return Gamma (Gamma::mul[g1.g][g2.g]);
54}
55
56// general left multiply
57template<class vtype>
59 ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
60{
62 ret._internal=G*arg._internal;
63 return ret;
64}
65
66template<class vtype,int N>
68 ->typename std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,iVector<vtype,N>>::type
69{
71 for(int i=0;i<N;i++){
72 ret._internal[i]=G*arg._internal[i];
73 }
74 return ret;
75}
76
77template<class vtype, int N>
79 ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
80{
82 for(int i=0;i<N;i++){
83 for(int j=0;j<N;j++){
84 ret._internal[i][j]=G*arg._internal[i][j];
85 }}
86 return ret;
87}
88
89// general right multiply
90template<class vtype>
92 ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
93{
95 ret._internal=arg._internal*G;
96 return ret;
97}
98
99template<class vtype, int N>
101 ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
102{
104 for(int i=0;i<N;i++){
105 for(int j=0;j<N;j++){
106 ret._internal[i][j]=arg._internal[i][j]*G;
107 }}
108 return ret;
109}
110
111// Gamma-left matrices gL_mu = g_mu*(1 - g5)
114{
115public:
116 typedef Gamma::Algebra Algebra;
118public:
119 GammaL(const Algebra initg): gamma(initg) {}
120 GammaL(const Gamma initg): gamma(initg) {}
121};
122
123// vector multiply
124template<class vtype>
126 ->typename std::enable_if<matchGridTensorIndex<iVector<vtype, Ns>, SpinorIndex>::value, iVector<vtype, Ns>>::type
127{
129
130 buf(0) = 0.;
131 buf(1) = 0.;
132 buf(2) = 2.*arg(2);
133 buf(3) = 2.*arg(3);
134
135 return gl.gamma*buf;
136};
137
138// matrix left multiply
139template<class vtype>
141 ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype, Ns>, SpinorIndex>::value, iMatrix<vtype, Ns>>::type
142{
144
145 for(unsigned int i = 0; i < Ns; ++i)
146 {
147 buf(0, i) = 0.;
148 buf(1, i) = 0.;
149 buf(2, i) = 2.*arg(2, i);
150 buf(3, i) = 2.*arg(3, i);
151 }
152
153 return gl.gamma*buf;
154};
155
156// matrix right multiply
157template<class vtype>
159 ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype, Ns>, SpinorIndex>::value, iMatrix<vtype, Ns>>::type
160{
162
163 buf = arg*gl.gamma;
164 for(unsigned int i = 0; i < Ns; ++i)
165 {
166 buf(i, 0) = 0.;
167 buf(i, 1) = 0.;
168 buf(i, 2) = 2.*buf(i, 2);
169 buf(i, 3) = 2.*buf(i, 3);
170 }
171
172 return buf;
173};
174
175//general left multiply
176template<class vtype>
178 ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
179{
180 iScalar<vtype> ret;
181 ret._internal=gl*arg._internal;
182 return ret;
183}
184
185template<class vtype,int N>
187 ->typename std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,iVector<vtype,N>>::type
188{
190 for(int i=0;i<N;i++){
191 ret._internal[i]=gl*arg._internal[i];
192 }
193 return ret;
194}
195
196template<class vtype, int N>
198 ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
199{
201 for(int i=0;i<N;i++){
202 for(int j=0;j<N;j++){
203 ret._internal[i][j]=gl*arg._internal[i][j];
204 }}
205 return ret;
206}
207
208//general right multiply
209template<class vtype>
211 ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
212{
213 iScalar<vtype> ret;
214 ret._internal=arg._internal*gl;
215 return ret;
216}
217
218template<class vtype, int N>
220 ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
221{
223 for(int i=0;i<N;i++){
224 for(int j=0;j<N;j++){
225 ret._internal[i][j]=arg._internal[i][j]*gl;
226 }}
227 return ret;
228}
229
231
232#endif
#define accelerator_inline
Gamma adj(const Gamma &g)
Definition Dirac.h:43
Gamma operator*(const Gamma &g1, const Gamma &g2)
Definition Dirac.h:51
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Ns
Definition QCD.h:51
const int SpinorIndex
Definition QCD.h:77
Gamma gamma
Definition Dirac.h:117
GammaL(const Gamma initg)
Definition Dirac.h:120
Gamma::Algebra Algebra
Definition Dirac.h:116
GammaL(const Algebra initg)
Definition Dirac.h:119
Definition Gamma.h:10
static const std::array< Algebra, nGamma > adj
Definition Gamma.h:65
static const std::array< std::array< Algebra, nGamma >, nGamma > mul
Definition Gamma.h:99
Algebra g
Definition Gamma.h:51
vtype _internal[N][N]
vtype _internal
vtype _internal[N]