/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: lib/qcd/spin/Dirac.h Copyright (C) 2015 Copyright (C) 2016 Author: Antonin Portelli Author: Peter Boyle Author: Peter Boyle Author: paboyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #ifndef GRID_QCD_DIRAC_H #define GRID_QCD_DIRAC_H // Gamma matrices using the code generated by the Mathematica notebook // gamma-gen/gamma-gen.nb in Gamma.cc & Gamma.h //////////////////////////////////////////////////////////////////////////////// #include NAMESPACE_BEGIN(Grid); // Dirac algebra adjoint operator (not in QCD:: to overload other adj) inline QCD::Gamma adj(const QCD::Gamma &g) { return QCD::Gamma (QCD::Gamma::adj[g.g]); } // Dirac algebra mutliplication operator inline Gamma operator*(const Gamma &g1, const Gamma &g2) { return Gamma (Gamma::mul[g1.g][g2.g]); } // general left multiply template inline auto operator*(const Gamma &G, const iScalar &arg) ->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type { iScalar ret; ret._internal=G*arg._internal; return ret; } template inline auto operator*(const Gamma &G, const iVector &arg) ->typename std::enable_if,SpinorIndex>::notvalue,iVector>::type { iVector ret; for(int i=0;i inline auto operator*(const Gamma &G, const iMatrix &arg) ->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type { iMatrix ret; for(int i=0;i inline auto operator*(const iScalar &arg, const Gamma &G) ->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type { iScalar ret; ret._internal=arg._internal*G; return ret; } template inline auto operator * (const iMatrix &arg, const Gamma &G) ->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type { iMatrix ret; for(int i=0;i inline auto operator*(const GammaL &gl, const iVector &arg) ->typename std::enable_if, SpinorIndex>::value, iVector>::type { iVector buf; buf(0) = 0.; buf(1) = 0.; buf(2) = 2.*arg(2); buf(3) = 2.*arg(3); return gl.gamma*buf; }; // matrix left multiply template inline auto operator*(const GammaL &gl, const iMatrix &arg) ->typename std::enable_if, SpinorIndex>::value, iMatrix>::type { iMatrix buf; for(unsigned int i = 0; i < Ns; ++i) { buf(0, i) = 0.; buf(1, i) = 0.; buf(2, i) = 2.*arg(2, i); buf(3, i) = 2.*arg(3, i); } return gl.gamma*buf; }; // matrix right multiply template inline auto operator*(const iMatrix &arg, const GammaL &gl) ->typename std::enable_if, SpinorIndex>::value, iMatrix>::type { iMatrix buf; buf = arg*gl.gamma; for(unsigned int i = 0; i < Ns; ++i) { buf(i, 0) = 0.; buf(i, 1) = 0.; buf(i, 2) = 2.*buf(i, 2); buf(i, 3) = 2.*buf(i, 3); } return buf; }; //general left multiply template inline auto operator*(const GammaL &gl, const iScalar &arg) ->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type { iScalar ret; ret._internal=gl*arg._internal; return ret; } template inline auto operator*(const GammaL &gl, const iVector &arg) ->typename std::enable_if,SpinorIndex>::notvalue,iVector>::type { iVector ret; for(int i=0;i inline auto operator*(const GammaL &gl, const iMatrix &arg) ->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type { iMatrix ret; for(int i=0;i inline auto operator*(const iScalar &arg, const GammaL &gl) ->typename std::enable_if,SpinorIndex>::notvalue,iScalar>::type { iScalar ret; ret._internal=arg._internal*gl; return ret; } template inline auto operator * (const iMatrix &arg, const GammaL &gl) ->typename std::enable_if,SpinorIndex>::notvalue,iMatrix>::type { iMatrix ret; for(int i=0;i