1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 15:55:37 +00:00

NAMESPACE & format

This commit is contained in:
paboyle 2018-01-14 21:52:27 +00:00
parent 1fbab4032b
commit 59ba9ff3bb

View File

@ -28,35 +28,35 @@ with this program; if not, write to the Free Software Foundation, Inc.,
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/ *************************************************************************************/
/* END LEGAL */ /* END LEGAL */
#ifndef GRID_QCD_DIRAC_H #ifndef GRID_QCD_DIRAC_H
#define GRID_QCD_DIRAC_H #define GRID_QCD_DIRAC_H
// Gamma matrices using the code generated by the Mathematica notebook // Gamma matrices using the code generated by the Mathematica notebook
// gamma-gen/gamma-gen.nb in Gamma.cc & Gamma.h // gamma-gen/gamma-gen.nb in Gamma.cc & Gamma.h
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <Grid/qcd/spin/Gamma.h> #include <Grid/qcd/spin/Gamma.h>
namespace Grid { NAMESPACE_BEGIN(Grid);
// Dirac algebra adjoint operator (not in QCD:: to overload other adj) // Dirac algebra adjoint operator (not in QCD:: to overload other adj)
inline QCD::Gamma adj(const QCD::Gamma &g) inline QCD::Gamma adj(const QCD::Gamma &g)
{ {
return QCD::Gamma (QCD::Gamma::adj[g.g]); return QCD::Gamma (QCD::Gamma::adj[g.g]);
} }
namespace QCD {
// Dirac algebra mutliplication operator // Dirac algebra mutliplication operator
inline Gamma operator*(const Gamma &g1, const Gamma &g2) inline Gamma operator*(const Gamma &g1, const Gamma &g2)
{ {
return Gamma (Gamma::mul[g1.g][g2.g]); return Gamma (Gamma::mul[g1.g][g2.g]);
} }
// general left multiply // general left multiply
template<class vtype> template<class vtype>
inline auto operator*(const Gamma &G, const iScalar<vtype> &arg) inline auto operator*(const Gamma &G, const iScalar<vtype> &arg)
->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
{ {
iScalar<vtype> ret; iScalar<vtype> ret;
ret._internal=G*arg._internal; ret._internal=G*arg._internal;
@ -65,7 +65,7 @@ inline auto operator*(const Gamma &G, const iScalar<vtype> &arg)
template<class vtype,int N> template<class vtype,int N>
inline auto operator*(const Gamma &G, const iVector<vtype, N> &arg) inline auto operator*(const Gamma &G, const iVector<vtype, N> &arg)
->typename std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,iVector<vtype,N>>::type ->typename std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,iVector<vtype,N>>::type
{ {
iVector<vtype,N> ret; iVector<vtype,N> ret;
for(int i=0;i<N;i++){ for(int i=0;i<N;i++){
@ -76,20 +76,20 @@ inline auto operator*(const Gamma &G, const iVector<vtype, N> &arg)
template<class vtype, int N> template<class vtype, int N>
inline auto operator*(const Gamma &G, const iMatrix<vtype, N> &arg) inline auto operator*(const Gamma &G, const iMatrix<vtype, N> &arg)
->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
{ {
iMatrix<vtype,N> ret; iMatrix<vtype,N> ret;
for(int i=0;i<N;i++){ for(int i=0;i<N;i++){
for(int j=0;j<N;j++){ for(int j=0;j<N;j++){
ret._internal[i][j]=G*arg._internal[i][j]; ret._internal[i][j]=G*arg._internal[i][j];
}} }}
return ret; return ret;
} }
// general right multiply // general right multiply
template<class vtype> template<class vtype>
inline auto operator*(const iScalar<vtype> &arg, const Gamma &G) inline auto operator*(const iScalar<vtype> &arg, const Gamma &G)
->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
{ {
iScalar<vtype> ret; iScalar<vtype> ret;
ret._internal=arg._internal*G; ret._internal=arg._internal*G;
@ -98,13 +98,13 @@ inline auto operator*(const iScalar<vtype> &arg, const Gamma &G)
template<class vtype, int N> template<class vtype, int N>
inline auto operator * (const iMatrix<vtype, N> &arg, const Gamma &G) inline auto operator * (const iMatrix<vtype, N> &arg, const Gamma &G)
->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
{ {
iMatrix<vtype,N> ret; iMatrix<vtype,N> ret;
for(int i=0;i<N;i++){ for(int i=0;i<N;i++){
for(int j=0;j<N;j++){ for(int j=0;j<N;j++){
ret._internal[i][j]=arg._internal[i][j]*G; ret._internal[i][j]=arg._internal[i][j]*G;
}} }}
return ret; return ret;
} }
@ -123,7 +123,7 @@ public:
// vector multiply // vector multiply
template<class vtype> template<class vtype>
inline auto operator*(const GammaL &gl, const iVector<vtype, Ns> &arg) inline auto operator*(const GammaL &gl, const iVector<vtype, Ns> &arg)
->typename std::enable_if<matchGridTensorIndex<iVector<vtype, Ns>, SpinorIndex>::value, iVector<vtype, Ns>>::type ->typename std::enable_if<matchGridTensorIndex<iVector<vtype, Ns>, SpinorIndex>::value, iVector<vtype, Ns>>::type
{ {
iVector<vtype, Ns> buf; iVector<vtype, Ns> buf;
@ -138,17 +138,17 @@ inline auto operator*(const GammaL &gl, const iVector<vtype, Ns> &arg)
// matrix left multiply // matrix left multiply
template<class vtype> template<class vtype>
inline auto operator*(const GammaL &gl, const iMatrix<vtype, Ns> &arg) inline auto operator*(const GammaL &gl, const iMatrix<vtype, Ns> &arg)
->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype, Ns>, SpinorIndex>::value, iMatrix<vtype, Ns>>::type ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype, Ns>, SpinorIndex>::value, iMatrix<vtype, Ns>>::type
{ {
iMatrix<vtype, Ns> buf; iMatrix<vtype, Ns> buf;
for(unsigned int i = 0; i < Ns; ++i) for(unsigned int i = 0; i < Ns; ++i)
{ {
buf(0, i) = 0.; buf(0, i) = 0.;
buf(1, i) = 0.; buf(1, i) = 0.;
buf(2, i) = 2.*arg(2, i); buf(2, i) = 2.*arg(2, i);
buf(3, i) = 2.*arg(3, i); buf(3, i) = 2.*arg(3, i);
} }
return gl.gamma*buf; return gl.gamma*buf;
}; };
@ -156,18 +156,18 @@ inline auto operator*(const GammaL &gl, const iMatrix<vtype, Ns> &arg)
// matrix right multiply // matrix right multiply
template<class vtype> template<class vtype>
inline auto operator*(const iMatrix<vtype, Ns> &arg, const GammaL &gl) inline auto operator*(const iMatrix<vtype, Ns> &arg, const GammaL &gl)
->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype, Ns>, SpinorIndex>::value, iMatrix<vtype, Ns>>::type ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype, Ns>, SpinorIndex>::value, iMatrix<vtype, Ns>>::type
{ {
iMatrix<vtype, Ns> buf; iMatrix<vtype, Ns> buf;
buf = arg*gl.gamma; buf = arg*gl.gamma;
for(unsigned int i = 0; i < Ns; ++i) for(unsigned int i = 0; i < Ns; ++i)
{ {
buf(i, 0) = 0.; buf(i, 0) = 0.;
buf(i, 1) = 0.; buf(i, 1) = 0.;
buf(i, 2) = 2.*buf(i, 2); buf(i, 2) = 2.*buf(i, 2);
buf(i, 3) = 2.*buf(i, 3); buf(i, 3) = 2.*buf(i, 3);
} }
return buf; return buf;
}; };
@ -175,7 +175,7 @@ inline auto operator*(const iMatrix<vtype, Ns> &arg, const GammaL &gl)
//general left multiply //general left multiply
template<class vtype> template<class vtype>
inline auto operator*(const GammaL &gl, const iScalar<vtype> &arg) inline auto operator*(const GammaL &gl, const iScalar<vtype> &arg)
->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
{ {
iScalar<vtype> ret; iScalar<vtype> ret;
ret._internal=gl*arg._internal; ret._internal=gl*arg._internal;
@ -184,7 +184,7 @@ inline auto operator*(const GammaL &gl, const iScalar<vtype> &arg)
template<class vtype,int N> template<class vtype,int N>
inline auto operator*(const GammaL &gl, const iVector<vtype, N> &arg) inline auto operator*(const GammaL &gl, const iVector<vtype, N> &arg)
->typename std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,iVector<vtype,N>>::type ->typename std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,iVector<vtype,N>>::type
{ {
iVector<vtype,N> ret; iVector<vtype,N> ret;
for(int i=0;i<N;i++){ for(int i=0;i<N;i++){
@ -195,20 +195,20 @@ inline auto operator*(const GammaL &gl, const iVector<vtype, N> &arg)
template<class vtype, int N> template<class vtype, int N>
inline auto operator*(const GammaL &gl, const iMatrix<vtype, N> &arg) inline auto operator*(const GammaL &gl, const iMatrix<vtype, N> &arg)
->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
{ {
iMatrix<vtype,N> ret; iMatrix<vtype,N> ret;
for(int i=0;i<N;i++){ for(int i=0;i<N;i++){
for(int j=0;j<N;j++){ for(int j=0;j<N;j++){
ret._internal[i][j]=gl*arg._internal[i][j]; ret._internal[i][j]=gl*arg._internal[i][j];
}} }}
return ret; return ret;
} }
//general right multiply //general right multiply
template<class vtype> template<class vtype>
inline auto operator*(const iScalar<vtype> &arg, const GammaL &gl) inline auto operator*(const iScalar<vtype> &arg, const GammaL &gl)
->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type ->typename std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,iScalar<vtype>>::type
{ {
iScalar<vtype> ret; iScalar<vtype> ret;
ret._internal=arg._internal*gl; ret._internal=arg._internal*gl;
@ -217,16 +217,16 @@ inline auto operator*(const iScalar<vtype> &arg, const GammaL &gl)
template<class vtype, int N> template<class vtype, int N>
inline auto operator * (const iMatrix<vtype, N> &arg, const GammaL &gl) inline auto operator * (const iMatrix<vtype, N> &arg, const GammaL &gl)
->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type ->typename std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,iMatrix<vtype,N>>::type
{ {
iMatrix<vtype,N> ret; iMatrix<vtype,N> ret;
for(int i=0;i<N;i++){ for(int i=0;i<N;i++){
for(int j=0;j<N;j++){ for(int j=0;j<N;j++){
ret._internal[i][j]=arg._internal[i][j]*gl; ret._internal[i][j]=arg._internal[i][j]*gl;
}} }}
return ret; return ret;
} }
}} NAMESPACE_END(Grid);
#endif #endif