mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-04 05:54:32 +00:00 
			
		
		
		
	Merge branch 'feature/hadrons' into feature/rare_kaon
This commit is contained in:
		@@ -36,22 +36,6 @@ See the full license in the file "LICENSE" in the top level distribution directo
 | 
			
		||||
#include <Grid/Hadrons/Module.hpp>
 | 
			
		||||
#include <Grid/Hadrons/ModuleFactory.hpp>
 | 
			
		||||
 | 
			
		||||
namespace Grid {
 | 
			
		||||
    // Overload >> to extract gamma pair from "<g1 g2>" string.
 | 
			
		||||
    template <typename T1, typename T2>
 | 
			
		||||
    inline std::istringstream &operator>>(std::istringstream &sstr,
 | 
			
		||||
                                          std::pair<T1, T2> &buf)
 | 
			
		||||
    {
 | 
			
		||||
        unsigned int buf1;
 | 
			
		||||
        unsigned int buf2;
 | 
			
		||||
        char c;
 | 
			
		||||
        sstr >> c >> buf1 >> buf2 >> c;
 | 
			
		||||
        sstr.peek();
 | 
			
		||||
        buf = std::make_pair((T1)buf1, (T2)buf2);
 | 
			
		||||
        return sstr;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
BEGIN_HADRONS_NAMESPACE
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
@@ -63,8 +47,8 @@ BEGIN_HADRONS_NAMESPACE
 | 
			
		||||
 - q1: input propagator 1 (string)
 | 
			
		||||
 - q2: input propagator 2 (string)
 | 
			
		||||
 - gammas: gamma products to insert at sink & source, pairs of gamma matrices 
 | 
			
		||||
           (space-separated integers) in square brackets (i.e. [g_sink g_src]),
 | 
			
		||||
           in a sequence (e.g. "[15 7][7 15][7 7]").
 | 
			
		||||
           (space-separated strings) in angled brackets (i.e. <g_sink g_src>),
 | 
			
		||||
           in a sequence (e.g. "<Gamma5 Gamma5><Gamma5 GammaT>").
 | 
			
		||||
 | 
			
		||||
           Special values: "all" - perform all possible contractions.
 | 
			
		||||
 - mom: momentum insertion, space-separated float sequence (e.g ".1 .2 1. 0."),
 | 
			
		||||
 
 | 
			
		||||
@@ -1,72 +0,0 @@
 | 
			
		||||
/*************************************************************************************
 | 
			
		||||
 | 
			
		||||
Grid physics library, www.github.com/paboyle/Grid 
 | 
			
		||||
 | 
			
		||||
Source file: lib/qcd/spin/Dirac.cc
 | 
			
		||||
 | 
			
		||||
Copyright (C) 2015
 | 
			
		||||
Copyright (C) 2016
 | 
			
		||||
 | 
			
		||||
Author: Antonin Portelli <antonin.portelli@me.com>
 | 
			
		||||
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
Author: paboyle <paboyle@ph.ed.ac.uk>
 | 
			
		||||
 | 
			
		||||
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 */
 | 
			
		||||
#include <Grid/Grid.h>
 | 
			
		||||
 | 
			
		||||
namespace Grid {
 | 
			
		||||
namespace QCD {
 | 
			
		||||
 | 
			
		||||
#include "GammaMulTable.h"
 | 
			
		||||
 | 
			
		||||
const std::array<const char *, Gamma::nGamma> Gamma::name = {{
 | 
			
		||||
  "-Gamma5      ",
 | 
			
		||||
  "Gamma5       ",
 | 
			
		||||
  "-GammaT      ",
 | 
			
		||||
  "GammaT       ",
 | 
			
		||||
  "-GammaTGamma5",
 | 
			
		||||
  "GammaTGamma5 ",
 | 
			
		||||
  "-GammaX      ",
 | 
			
		||||
  "GammaX       ",
 | 
			
		||||
  "-GammaXGamma5",
 | 
			
		||||
  "GammaXGamma5 ",
 | 
			
		||||
  "-GammaY      ",
 | 
			
		||||
  "GammaY       ",
 | 
			
		||||
  "-GammaYGamma5",
 | 
			
		||||
  "GammaYGamma5 ",
 | 
			
		||||
  "-GammaZ      ",
 | 
			
		||||
  "GammaZ       ",
 | 
			
		||||
  "-GammaZGamma5",
 | 
			
		||||
  "GammaZGamma5 ",
 | 
			
		||||
  "-Identity    ",
 | 
			
		||||
  "Identity     ",
 | 
			
		||||
  "-SigmaXT     ",
 | 
			
		||||
  "SigmaXT      ",
 | 
			
		||||
  "-SigmaXY     ",
 | 
			
		||||
  "SigmaXY      ",
 | 
			
		||||
  "-SigmaXZ     ",
 | 
			
		||||
  "SigmaXZ      ",
 | 
			
		||||
  "-SigmaYT     ",
 | 
			
		||||
  "SigmaYT      ",
 | 
			
		||||
  "-SigmaYZ     ",
 | 
			
		||||
  "SigmaYZ      ",
 | 
			
		||||
  "-SigmaZT     ",
 | 
			
		||||
  "SigmaZT      "}};
 | 
			
		||||
 | 
			
		||||
}}
 | 
			
		||||
							
								
								
									
										1432
									
								
								lib/qcd/spin/Dirac.h
									
									
									
									
									
								
							
							
						
						
									
										1432
									
								
								lib/qcd/spin/Dirac.h
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1348
									
								
								lib/qcd/spin/Gamma.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1348
									
								
								lib/qcd/spin/Gamma.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -10,10 +10,10 @@
 | 
			
		||||
NotebookFileLineBreakTest
 | 
			
		||||
NotebookFileLineBreakTest
 | 
			
		||||
NotebookDataPosition[       158,          7]
 | 
			
		||||
NotebookDataLength[     58006,       1512]
 | 
			
		||||
NotebookOptionsPosition[     56426,       1458]
 | 
			
		||||
NotebookOutlinePosition[     56786,       1474]
 | 
			
		||||
CellTagsIndexPosition[     56743,       1471]
 | 
			
		||||
NotebookDataLength[     56640,       1480]
 | 
			
		||||
NotebookOptionsPosition[     55061,       1426]
 | 
			
		||||
NotebookOutlinePosition[     55421,       1442]
 | 
			
		||||
CellTagsIndexPosition[     55378,       1439]
 | 
			
		||||
WindowFrame->Normal*)
 | 
			
		||||
 | 
			
		||||
(* Beginning of Notebook Content *)
 | 
			
		||||
@@ -64,7 +64,10 @@ Cell[BoxData["\<\"/Users/antonin/Development/Grid/lib/qcd/spin/gamma-gen\"\>"]\
 | 
			
		||||
   3.6942153028002653`*^9, 3.694215388363636*^9, 3.694215531793765*^9, 
 | 
			
		||||
   3.694293467607703*^9, 3.694294096138891*^9, 3.694297419616928*^9, 
 | 
			
		||||
   3.694297655191285*^9, 3.69429782738804*^9, 3.694297901657515*^9, 
 | 
			
		||||
   3.6942984168973837`*^9}]
 | 
			
		||||
   3.6942984168973837`*^9, 3.6948949168128557`*^9, 3.69489495942482*^9, 
 | 
			
		||||
   3.6949627104409447`*^9, {3.694962842273374*^9, 3.6949628507953672`*^9}, 
 | 
			
		||||
   3.694963445768766*^9, 3.6949643976358423`*^9, {3.694964715764683*^9, 
 | 
			
		||||
   3.6949647261937733`*^9}, 3.6949650592533703`*^9, 3.694965165070952*^9}]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
@@ -382,7 +385,11 @@ Cell[BoxData[
 | 
			
		||||
   3.694214931160738*^9, 3.6942149565175247`*^9}, 3.69421520140513*^9, 
 | 
			
		||||
   3.694215303184371*^9, 3.694215388782826*^9, 3.694215532274271*^9, 
 | 
			
		||||
   3.694293468120837*^9, 3.69429409699356*^9, 3.694297655587861*^9, 
 | 
			
		||||
   3.694297827778974*^9, 3.694297902050129*^9, 3.694298417447421*^9}]
 | 
			
		||||
   3.694297827778974*^9, 3.694297902050129*^9, 3.694298417447421*^9, 
 | 
			
		||||
   3.694894917294997*^9, 3.6948949597758904`*^9, 3.6949627108824663`*^9, 
 | 
			
		||||
   3.694962851174364*^9, 3.6949634461305313`*^9, 3.694964397971891*^9, {
 | 
			
		||||
   3.6949647161810303`*^9, 3.6949647264866943`*^9}, 3.6949650598407507`*^9, 
 | 
			
		||||
   3.694965165456048*^9}]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
 | 
			
		||||
Cell["Full multiplication table:", "Text",
 | 
			
		||||
@@ -566,14 +573,19 @@ Cell[BoxData[
 | 
			
		||||
   3.694214931237383*^9, 3.6942149565897913`*^9}, 3.6942152015279818`*^9, 
 | 
			
		||||
   3.694215303248364*^9, 3.694215388866436*^9, 3.694215532359406*^9, 
 | 
			
		||||
   3.694293468220346*^9, 3.694294097121203*^9, 3.694297655690278*^9, 
 | 
			
		||||
   3.694297827858612*^9, 3.694297902125073*^9, 3.694298417530912*^9}]
 | 
			
		||||
   3.694297827858612*^9, 3.694297902125073*^9, 3.694298417530912*^9, 
 | 
			
		||||
   3.694894917375866*^9, 3.694894959839177*^9, 3.694962710968522*^9, 
 | 
			
		||||
   3.6949628512863817`*^9, 3.694963446206002*^9, 3.694964398046623*^9, {
 | 
			
		||||
   3.6949647162797327`*^9, 3.694964726526013*^9}, 3.6949650599380713`*^9, 
 | 
			
		||||
   3.694965165531089*^9}]
 | 
			
		||||
}, Open  ]]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
 | 
			
		||||
Cell["Header file Dirac.h generation", "Section",
 | 
			
		||||
 CellChangeTimes->{{3.694208986784461*^9, 3.6942090005062523`*^9}}],
 | 
			
		||||
Cell["Header file Gamma.h generation", "Section",
 | 
			
		||||
 CellChangeTimes->{{3.694208986784461*^9, 3.6942090005062523`*^9}, {
 | 
			
		||||
  3.694965123390101*^9, 3.694965123950851*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell["File skeleton:", "Text",
 | 
			
		||||
 CellFrame->{{0, 0}, {0, 0.5}},
 | 
			
		||||
@@ -591,7 +603,7 @@ Cell[BoxData[
 | 
			
		||||
     RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
      "out", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
       "\"\<#ifndef GRID_QCD_DIRAC_H\n#define GRID_QCD_DIRAC_H\n\n// code \
 | 
			
		||||
       "\"\<#ifndef GRID_QCD_GAMMA_H\n#define GRID_QCD_GAMMA_H\n\n// code \
 | 
			
		||||
generated by the Mathematica notebook gamma-gen/gamma-gen.nb\n\n#include \
 | 
			
		||||
<array>\n\nnamespace Grid {\nnamespace QCD {\n\nclass Gamma {\n  public:\n\
 | 
			
		||||
\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
@@ -603,16 +615,15 @@ generated by the Mathematica notebook gamma-gen/gamma-gen.nb\n\n#include \
 | 
			
		||||
       "\"\<    static const std::array<const char *, nGamma>                \
 | 
			
		||||
name;\n    static const std::array<std::array<Algebra, nGamma>, nGamma> mul;\n\
 | 
			
		||||
    static const std::array<Algebra, nGamma>                     adj;\n    \
 | 
			
		||||
static const std::array<const Gamma, 4>                      gmu;\n    \
 | 
			
		||||
Algebra                                                      g;\n  public:\n  \
 | 
			
		||||
  Gamma(Algebra initg): g(initg) {}  \n};\n\ninline Gamma operator*(const \
 | 
			
		||||
Gamma &g1, const Gamma &g2)\n{\n  return Gamma(Gamma::mul[g1.g][g2.g]);\n}\n\n\
 | 
			
		||||
inline Gamma adj(const Gamma &g)\n{\n  return Gamma(Gamma::adj[g.g]);\n}\n\n\
 | 
			
		||||
\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
  Gamma(Algebra initg): g(initg) {}  \n};\n\n\>\""}]}], ";", 
 | 
			
		||||
     "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", " ", "=", 
 | 
			
		||||
      RowBox[{"out", "<>", "funcCode"}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", "=", 
 | 
			
		||||
      RowBox[{"out", "<>", "\"\<\n}}\n\n#endif\n\>\""}]}], ";", 
 | 
			
		||||
     "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{"out", "<>", "\"\<\n}}\n\n#endif // GRID_QCD_GAMMA_H\n\>\""}]}],
 | 
			
		||||
      ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}]], "Input",
 | 
			
		||||
 CellChangeTimes->{{3.69419645529875*^9, 3.694196727399803*^9}, {
 | 
			
		||||
   3.694196786125751*^9, 3.694196882528638*^9}, {3.694197240621915*^9, 
 | 
			
		||||
@@ -628,7 +639,11 @@ inline Gamma adj(const Gamma &g)\n{\n  return Gamma(Gamma::adj[g.g]);\n}\n\n\
 | 
			
		||||
   3.694214647829077*^9}, {3.694214730808668*^9, 3.6942148593149223`*^9}, {
 | 
			
		||||
   3.694214900404429*^9, 3.694214905595294*^9}, {3.6942155281289682`*^9, 
 | 
			
		||||
   3.6942155289376802`*^9}, {3.694297793776082*^9, 3.694297819122456*^9}, {
 | 
			
		||||
   3.694297854809973*^9, 3.694297889420939*^9}}],
 | 
			
		||||
   3.694297854809973*^9, 3.694297889420939*^9}, {3.694963324045937*^9, 
 | 
			
		||||
   3.694963343265525*^9}, {3.694964367519239*^9, 3.69496439461199*^9}, {
 | 
			
		||||
   3.694964462130747*^9, 3.6949644669959793`*^9}, 3.694964509762739*^9, {
 | 
			
		||||
   3.694964705045744*^9, 3.694964723148797*^9}, {3.694964992988984*^9, 
 | 
			
		||||
   3.6949649968504257`*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell["Gamma enum generation:", "Text",
 | 
			
		||||
 CellFrame->{{0, 0}, {0, 0.5}},
 | 
			
		||||
@@ -1218,38 +1233,7 @@ iMatrix<vtype, Ns>>::type\n{\n  iMatrix<vtype, Ns> ret;\n\n  switch (G.g) \n  \
 | 
			
		||||
       RowBox[{"{", 
 | 
			
		||||
        RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", "=", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
      "out", "<>", 
 | 
			
		||||
       "\"\<\n// FIXME\n//\n// Optimisation; switch over to a \
 | 
			
		||||
\\\"multGammaX(ret._internal,arg._internal)\\\" style early and\n// note that \
 | 
			
		||||
doing so from the lattice operator will avoid copy back and case switch \
 | 
			
		||||
overhead, as\n// was done for the tensor math operator to remove operator * \
 | 
			
		||||
notation early\n//\n\n//left multiply\ntemplate<class vtype> \ninline auto \
 | 
			
		||||
operator*(const Gamma &G, const iScalar<vtype> &arg)\n->typename \
 | 
			
		||||
std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,\
 | 
			
		||||
iScalar<vtype>>::type \n{\n  iScalar<vtype> ret;\n  \
 | 
			
		||||
ret._internal=G*arg._internal;\n  return ret;\n}\n\ntemplate<class vtype,int \
 | 
			
		||||
N>\ninline auto operator*(const Gamma &G, const iVector<vtype, N> &arg)\n\
 | 
			
		||||
->typename \
 | 
			
		||||
std::enable_if<matchGridTensorIndex<iVector<vtype,N>,SpinorIndex>::notvalue,\
 | 
			
		||||
iVector<vtype,N>>::type \n{\n  iVector<vtype,N> ret;\n  for(int i=0;i<N;i++){\
 | 
			
		||||
\n    ret._internal[i]=G*arg._internal[i];\n  }\n  return ret;\n}\n\n\
 | 
			
		||||
template<class vtype, int N>\ninline auto operator*(const Gamma &G, const \
 | 
			
		||||
iMatrix<vtype, N> &arg) \n->typename \
 | 
			
		||||
std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,\
 | 
			
		||||
iMatrix<vtype,N>>::type \n{\n  iMatrix<vtype,N> ret;\n  for(int i=0;i<N;i++){\
 | 
			
		||||
\n  for(int j=0;j<N;j++){\n    ret._internal[i][j]=G*arg._internal[i][j];\n  \
 | 
			
		||||
}}\n  return ret;\n}\n\n//right multiply\ntemplate<class vtype>\ninline auto \
 | 
			
		||||
operator*(const iScalar<vtype> &arg, const Gamma &G)\n->typename \
 | 
			
		||||
std::enable_if<matchGridTensorIndex<iScalar<vtype>,SpinorIndex>::notvalue,\
 | 
			
		||||
iScalar<vtype>>::type \n{\n  iScalar<vtype> ret;\n  \
 | 
			
		||||
ret._internal=arg._internal*G;\n  return ret;\n}\n\ntemplate<class vtype, int \
 | 
			
		||||
N>\ninline auto operator * (const iMatrix<vtype, N> &arg, const Gamma &G) \n\
 | 
			
		||||
->typename \
 | 
			
		||||
std::enable_if<matchGridTensorIndex<iMatrix<vtype,N>,SpinorIndex>::notvalue,\
 | 
			
		||||
iMatrix<vtype,N>>::type \n{\n  iMatrix<vtype,N> ret;\n  for(int i=0;i<N;i++){\
 | 
			
		||||
\n  for(int j=0;j<N;j++){\n    ret._internal[i][j]=arg._internal[i][j]*G;\n  \
 | 
			
		||||
}}\n  return ret;\n}\n\n\>\"", "<>", 
 | 
			
		||||
      RowBox[{"out", "<>", 
 | 
			
		||||
       RowBox[{"vecFinal", "[", "]"}], "<>", "\"\<\\n\>\"", "<>", 
 | 
			
		||||
       RowBox[{"lmatFinal", "[", "]"}], "<>", "\"\<\\n\>\"", "<>", 
 | 
			
		||||
       RowBox[{"rmatFinal", "[", "]"}]}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
@@ -1272,7 +1256,8 @@ iMatrix<vtype,N>>::type \n{\n  iMatrix<vtype,N> ret;\n  for(int i=0;i<N;i++){\
 | 
			
		||||
   3.694212885985661*^9}, {3.694213330227892*^9, 3.694213417940996*^9}, {
 | 
			
		||||
   3.694214921431739*^9, 3.694214951876449*^9}, {3.6942151046483088`*^9, 
 | 
			
		||||
   3.694215118335286*^9}, {3.6942151634191313`*^9, 3.694215188429871*^9}, {
 | 
			
		||||
   3.6942940839999113`*^9, 3.694294090686364*^9}}],
 | 
			
		||||
   3.6942940839999113`*^9, 3.694294090686364*^9}, {3.69489488486012*^9, 
 | 
			
		||||
   3.6948948916252403`*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell["Header file generation:", "Text",
 | 
			
		||||
 CellFrame->{{0, 0}, {0, 0.5}},
 | 
			
		||||
@@ -1281,7 +1266,7 @@ Cell["Header file generation:", "Text",
 | 
			
		||||
Cell[BoxData[
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"file", "=", 
 | 
			
		||||
   RowBox[{"OpenWrite", "[", "\"\<Dirac.h\>\"", "]"}]}], ";", 
 | 
			
		||||
   RowBox[{"OpenWrite", "[", "\"\<Gamma.h\>\"", "]"}]}], ";", 
 | 
			
		||||
  RowBox[{"WriteString", "[", 
 | 
			
		||||
   RowBox[{"file", ",", 
 | 
			
		||||
    RowBox[{"makeHeaderCode", "[", 
 | 
			
		||||
@@ -1289,171 +1274,154 @@ Cell[BoxData[
 | 
			
		||||
      RowBox[{"makeEnumCode", "[", "\"\<    \>\"", "]"}], ",", 
 | 
			
		||||
      RowBox[{"makeFuncCode", "[", "]"}]}], "]"}]}], "]"}], ";", 
 | 
			
		||||
  RowBox[{"Close", "[", "file", "]"}], ";"}]], "Input",
 | 
			
		||||
 CellChangeTimes->{{3.694207263508134*^9, 3.694207312537463*^9}}]
 | 
			
		||||
 CellChangeTimes->{{3.694207263508134*^9, 3.694207312537463*^9}, {
 | 
			
		||||
  3.6948949122726097`*^9, 3.6948949127609673`*^9}}]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
 | 
			
		||||
Cell["Dirac.cc source file generation", "Section",
 | 
			
		||||
 CellChangeTimes->{{3.694209250542284*^9, 3.694209266269907*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell[BoxData[{
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{
 | 
			
		||||
  "out", " ", "=", " ", 
 | 
			
		||||
   "\"\<const std::array<std::array<Gamma::Algebra, Gamma::nGamma>, \
 | 
			
		||||
Gamma::nGamma> \nGamma::mul = {{\\n\>\""}], ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
   RowBox[{
 | 
			
		||||
    RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{
 | 
			
		||||
      RowBox[{"out", "=", 
 | 
			
		||||
       RowBox[{"out", "<>", 
 | 
			
		||||
        RowBox[{"If", "[", 
 | 
			
		||||
         RowBox[{
 | 
			
		||||
          RowBox[{"i2", "\[Equal]", 
 | 
			
		||||
           RowBox[{"First", "[", "alg", "]"}]}], ",", "\"\<  {\>\"", ",", 
 | 
			
		||||
          "\"\<   \>\"", ",", "\"\<   \>\""}], "]"}], "\[IndentingNewLine]", 
 | 
			
		||||
        "<>", "\"\<Gamma::\>\"", "<>", 
 | 
			
		||||
        RowBox[{"enum", "[", 
 | 
			
		||||
         RowBox[{"i1", ".", "i2"}], "]"}], "<>", 
 | 
			
		||||
        RowBox[{"If", "[", 
 | 
			
		||||
         RowBox[{
 | 
			
		||||
          RowBox[{"i2", "\[Equal]", 
 | 
			
		||||
           RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}\>\"", ",", 
 | 
			
		||||
          "\"\<\>\"", ",", "\"\<\>\""}], "]"}], "\[IndentingNewLine]", "<>", 
 | 
			
		||||
        RowBox[{"If", "[", 
 | 
			
		||||
         RowBox[{
 | 
			
		||||
          RowBox[{"i2", "\[Equal]", 
 | 
			
		||||
           RowBox[{"Last", "[", "alg", "]"}]}], ",", 
 | 
			
		||||
          RowBox[{"If", "[", 
 | 
			
		||||
           RowBox[{
 | 
			
		||||
            RowBox[{"i1", "\[Equal]", 
 | 
			
		||||
             RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<\>\"", ",", 
 | 
			
		||||
            "\"\<\\n  ,\\n\>\"", ",", "\"\<\\n  ,\\n\>\""}], "]"}], ",", 
 | 
			
		||||
          "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", 
 | 
			
		||||
      "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{"{", 
 | 
			
		||||
       RowBox[{"i2", ",", "alg"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", 
 | 
			
		||||
    RowBox[{"{", 
 | 
			
		||||
     RowBox[{"i1", ",", "alg"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"out", "=", 
 | 
			
		||||
   RowBox[{"out", "<>", "\"\<\\n}};\\n\\n\>\""}]}], 
 | 
			
		||||
  ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
   RowBox[{
 | 
			
		||||
   "out", "<>", 
 | 
			
		||||
    "\"\<const std::array<Gamma::Algebra, Gamma::nGamma> Gamma::adj = \
 | 
			
		||||
{\\n\>\""}]}], ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
   RowBox[{
 | 
			
		||||
    RowBox[{"out", "=", 
 | 
			
		||||
     RowBox[{"out", "<>", "\"\<  Gamma::\>\"", "<>", 
 | 
			
		||||
      RowBox[{"enum", "[", 
 | 
			
		||||
       RowBox[{"i", "\[ConjugateTranspose]"}], "]"}], "<>", 
 | 
			
		||||
      RowBox[{"If", "[", 
 | 
			
		||||
       RowBox[{
 | 
			
		||||
        RowBox[{"i", "\[Equal]", 
 | 
			
		||||
         RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<\>\"", ",", 
 | 
			
		||||
        "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", 
 | 
			
		||||
    "\[IndentingNewLine]", 
 | 
			
		||||
    RowBox[{"{", 
 | 
			
		||||
     RowBox[{"i", ",", "alg"}], "}"}]}], "]"}], 
 | 
			
		||||
  ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"out", "=", 
 | 
			
		||||
   RowBox[{"out", "<>", "\"\<\\n};\\n\>\""}]}], 
 | 
			
		||||
  ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"file", "=", 
 | 
			
		||||
   RowBox[{"OpenWrite", "[", "\"\<GammaMulTable.h\>\"", "]"}]}], 
 | 
			
		||||
  ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"WriteString", "[", 
 | 
			
		||||
   RowBox[{"file", ",", "out"}], "]"}], ";"}], "\[IndentingNewLine]", 
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"Close", "[", "file", "]"}], ";"}]}], "Input",
 | 
			
		||||
 CellChangeTimes->{{3.694188457712205*^9, 3.694188459081934*^9}, {
 | 
			
		||||
   3.694188583199066*^9, 3.694188690803248*^9}, {3.6941887378127832`*^9, 
 | 
			
		||||
   3.6941889049946423`*^9}, {3.694188939559833*^9, 3.6941889419840307`*^9}, {
 | 
			
		||||
   3.694189004894498*^9, 3.694189029210237*^9}, 3.694189123631489*^9, {
 | 
			
		||||
   3.694189184854504*^9, 3.694189212219471*^9}, {3.694189278607349*^9, 
 | 
			
		||||
   3.694189315273435*^9}, {3.694189367213715*^9, 3.694189508102169*^9}, {
 | 
			
		||||
   3.694189592594305*^9, 3.69418967222689*^9}, {3.69418976988986*^9, 
 | 
			
		||||
   3.694189793142088*^9}, {3.6941898310221663`*^9, 3.694189833288706*^9}, {
 | 
			
		||||
   3.694189898235135*^9, 3.694189929506019*^9}, 3.6941900145565357`*^9, {
 | 
			
		||||
   3.694190119264579*^9, 3.694190161822473*^9}, {3.694209485052578*^9, 
 | 
			
		||||
   3.6942094865108747`*^9}, {3.694211744604581*^9, 3.6942117644193983`*^9}, {
 | 
			
		||||
   3.694211794987585*^9, 3.694211795663188*^9}, 3.694213436760853*^9, {
 | 
			
		||||
   3.6942134707645893`*^9, 3.69421347411766*^9}, {3.694215381435295*^9, 
 | 
			
		||||
   3.694215385261436*^9}, {3.694297237092742*^9, 3.6942972934131393`*^9}, {
 | 
			
		||||
   3.6942974934555683`*^9, 3.694297566898333*^9}, {3.694297598113819*^9, 
 | 
			
		||||
   3.694297609176114*^9}, {3.694297683998802*^9, 3.694297711493322*^9}}],
 | 
			
		||||
Cell["Gamma.cc source file generation", "Section",
 | 
			
		||||
 CellChangeTimes->{{3.694209250542284*^9, 3.694209266269907*^9}, {
 | 
			
		||||
  3.6949651357846317`*^9, 3.694965136291535*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell[BoxData[
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{
 | 
			
		||||
   RowBox[{"makeSourceCode", "[", "]"}], ":=", 
 | 
			
		||||
   RowBox[{"Module", "[", 
 | 
			
		||||
  RowBox[{"makeSourceCode", "[", "]"}], ":=", 
 | 
			
		||||
  RowBox[{"Module", "[", 
 | 
			
		||||
   RowBox[{
 | 
			
		||||
    RowBox[{"{", 
 | 
			
		||||
     RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", 
 | 
			
		||||
    RowBox[{
 | 
			
		||||
     RowBox[{"{", 
 | 
			
		||||
      RowBox[{"out", "=", "\"\<\>\""}], "}"}], ",", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{
 | 
			
		||||
      RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
       RowBox[{
 | 
			
		||||
       "out", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
        "\"\<#include <Grid.h>\n\nnamespace Grid {\nnamespace QCD {\n\n\
 | 
			
		||||
#include \\\"GammaMulTable.h\\\"\n\nconst std::array<const char *, \
 | 
			
		||||
Gamma::nGamma> Gamma::name = {{\n\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{"Do", "[", 
 | 
			
		||||
       RowBox[{
 | 
			
		||||
        RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
         RowBox[{"out", "<>", "\"\<  \\\"\>\"", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
          RowBox[{"StringPadRight", "[", 
 | 
			
		||||
           RowBox[{
 | 
			
		||||
            RowBox[{"StringTrim", "[", 
 | 
			
		||||
             RowBox[{
 | 
			
		||||
              RowBox[{"StringReplace", "[", 
 | 
			
		||||
               RowBox[{
 | 
			
		||||
                RowBox[{"enum", "[", "g", "]"}], ",", 
 | 
			
		||||
                RowBox[{"\"\<Minus\>\"", "\[Rule]", "\"\<-\>\""}]}], "]"}], 
 | 
			
		||||
              ",", "\"\<Algebra::\>\""}], "]"}], ",", "13"}], "]"}], "<>", 
 | 
			
		||||
          "\[IndentingNewLine]", "\"\<\\\"\>\"", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
          
 | 
			
		||||
          RowBox[{"If", "[", 
 | 
			
		||||
           RowBox[{
 | 
			
		||||
            RowBox[{"g", "\[Equal]", 
 | 
			
		||||
             RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}};\\n\>\"", ",", 
 | 
			
		||||
            "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", 
 | 
			
		||||
        RowBox[{"{", 
 | 
			
		||||
         RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", 
 | 
			
		||||
      "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{"out", " ", "=", 
 | 
			
		||||
       RowBox[{"out", "<>", "\"\<\n}}\n\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
      
 | 
			
		||||
      RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}], 
 | 
			
		||||
  "\[IndentingNewLine]"}]], "Input",
 | 
			
		||||
     RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
      "out", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
       "\"\<// code generated by the Mathematica notebook \
 | 
			
		||||
gamma-gen/gamma-gen.nb\n\n#include <Grid/Grid.h>\n\nnamespace Grid {\n\
 | 
			
		||||
namespace QCD {\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
      "out", " ", "<>", 
 | 
			
		||||
       "\"\<\n\nconst std::array<const Gamma, 4> Gamma::gmu = {{\n  \
 | 
			
		||||
Gamma(Gamma::Algebra::GammaX),\n  Gamma(Gamma::Algebra::GammaY),\n  \
 | 
			
		||||
Gamma(Gamma::Algebra::GammaZ),\n  Gamma(Gamma::Algebra::GammaT)}};\n\nconst \
 | 
			
		||||
std::array<const char *, Gamma::nGamma> Gamma::name = {{\n\>\""}]}], ";", 
 | 
			
		||||
     "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
       RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
        RowBox[{"out", "<>", "\"\<  \\\"\>\"", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
         RowBox[{"StringPadRight", "[", 
 | 
			
		||||
          RowBox[{
 | 
			
		||||
           RowBox[{"StringTrim", "[", 
 | 
			
		||||
            RowBox[{
 | 
			
		||||
             RowBox[{"StringReplace", "[", 
 | 
			
		||||
              RowBox[{
 | 
			
		||||
               RowBox[{"enum", "[", "g", "]"}], ",", 
 | 
			
		||||
               RowBox[{"\"\<Minus\>\"", "\[Rule]", "\"\<-\>\""}]}], "]"}], 
 | 
			
		||||
             ",", "\"\<Algebra::\>\""}], "]"}], ",", "13"}], "]"}], "<>", 
 | 
			
		||||
         "\[IndentingNewLine]", "\"\<\\\"\>\"", "<>", "\[IndentingNewLine]", 
 | 
			
		||||
         RowBox[{"If", "[", 
 | 
			
		||||
          RowBox[{
 | 
			
		||||
           RowBox[{"g", "\[Equal]", 
 | 
			
		||||
            RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}};\\n\\n\>\"", 
 | 
			
		||||
           ",", "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", 
 | 
			
		||||
       "\[IndentingNewLine]", 
 | 
			
		||||
       RowBox[{"{", 
 | 
			
		||||
        RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
      "out", "<>", 
 | 
			
		||||
       "\"\<const std::array<Gamma::Algebra, Gamma::nGamma> Gamma::adj = \
 | 
			
		||||
{{\\n\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
       RowBox[{"out", "=", 
 | 
			
		||||
        RowBox[{"out", "<>", "\"\<  Gamma::\>\"", "<>", 
 | 
			
		||||
         RowBox[{"enum", "[", 
 | 
			
		||||
          RowBox[{"g", "\[ConjugateTranspose]"}], "]"}], "<>", 
 | 
			
		||||
         RowBox[{"If", "[", 
 | 
			
		||||
          RowBox[{
 | 
			
		||||
           RowBox[{"g", "\[Equal]", 
 | 
			
		||||
            RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}};\\n\\n\>\"", 
 | 
			
		||||
           ",", "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", 
 | 
			
		||||
       "\[IndentingNewLine]", 
 | 
			
		||||
       RowBox[{"{", 
 | 
			
		||||
        RowBox[{"g", ",", "alg"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", " ", "=", " ", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
      "out", " ", "<>", 
 | 
			
		||||
       "\"\<const std::array<std::array<Gamma::Algebra, Gamma::nGamma>, \
 | 
			
		||||
Gamma::nGamma> Gamma::mul = {{\\n\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
      RowBox[{
 | 
			
		||||
       RowBox[{"Do", "[", "\[IndentingNewLine]", 
 | 
			
		||||
        RowBox[{
 | 
			
		||||
         RowBox[{"out", "=", 
 | 
			
		||||
          RowBox[{"out", "<>", 
 | 
			
		||||
           RowBox[{"If", "[", 
 | 
			
		||||
            RowBox[{
 | 
			
		||||
             RowBox[{"g2", "\[Equal]", 
 | 
			
		||||
              RowBox[{"First", "[", "alg", "]"}]}], ",", "\"\<  {{\>\"", ",", 
 | 
			
		||||
             "\"\<   \>\"", ",", "\"\<   \>\""}], "]"}], 
 | 
			
		||||
           "\[IndentingNewLine]", "<>", "\"\<Gamma::\>\"", "<>", 
 | 
			
		||||
           RowBox[{"enum", "[", 
 | 
			
		||||
            RowBox[{"g1", ".", "g2"}], "]"}], "<>", 
 | 
			
		||||
           RowBox[{"If", "[", 
 | 
			
		||||
            RowBox[{
 | 
			
		||||
             RowBox[{"g2", "\[Equal]", 
 | 
			
		||||
              RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<}}\>\"", ",", 
 | 
			
		||||
             "\"\<\>\"", ",", "\"\<\>\""}], "]"}], "\[IndentingNewLine]", "<>", 
 | 
			
		||||
           RowBox[{"If", "[", 
 | 
			
		||||
            RowBox[{
 | 
			
		||||
             RowBox[{"g2", "\[Equal]", 
 | 
			
		||||
              RowBox[{"Last", "[", "alg", "]"}]}], ",", 
 | 
			
		||||
             RowBox[{"If", "[", 
 | 
			
		||||
              RowBox[{
 | 
			
		||||
               RowBox[{"g1", "\[Equal]", 
 | 
			
		||||
                RowBox[{"Last", "[", "alg", "]"}]}], ",", "\"\<\>\"", ",", 
 | 
			
		||||
               "\"\<\\n  ,\\n\>\"", ",", "\"\<\\n  ,\\n\>\""}], "]"}], ",", 
 | 
			
		||||
             "\"\<,\\n\>\"", ",", "\"\<,\\n\>\""}], "]"}]}]}], ",", 
 | 
			
		||||
         "\[IndentingNewLine]", 
 | 
			
		||||
         RowBox[{"{", 
 | 
			
		||||
          RowBox[{"g2", ",", "alg"}], "}"}]}], "]"}], ",", 
 | 
			
		||||
       "\[IndentingNewLine]", 
 | 
			
		||||
       RowBox[{"{", 
 | 
			
		||||
        RowBox[{"g1", ",", "alg"}], "}"}]}], "]"}], ";", 
 | 
			
		||||
     "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", "=", 
 | 
			
		||||
      RowBox[{"out", "<>", "\"\<\\n}};\\n\\n\>\""}]}], ";", 
 | 
			
		||||
     "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"out", " ", "=", 
 | 
			
		||||
      RowBox[{"out", "<>", "\"\<}}\\n\>\""}]}], ";", "\[IndentingNewLine]", 
 | 
			
		||||
     RowBox[{"Return", "[", "out", "]"}]}]}], "]"}]}]], "Input",
 | 
			
		||||
 CellChangeTimes->{{3.69421121373662*^9, 3.694211248473432*^9}, {
 | 
			
		||||
   3.6942118524105463`*^9, 3.694211892664316*^9}, {3.69421196260581*^9, 
 | 
			
		||||
   3.69421202215168*^9}, {3.69421216516626*^9, 3.694212368624585*^9}, {
 | 
			
		||||
   3.694212488334324*^9, 3.694212500692437*^9}, 3.6942134310746183`*^9, {
 | 
			
		||||
   3.694215284859365*^9, 3.694215285515815*^9}, {3.694215368213806*^9, 
 | 
			
		||||
   3.69421537607312*^9}, {3.694215508990799*^9, 3.694215509814066*^9}}],
 | 
			
		||||
   3.69421537607312*^9}, {3.694215508990799*^9, 3.694215509814066*^9}, {
 | 
			
		||||
   3.69489462883849*^9, 3.694894689512344*^9}, {3.6948947475649767`*^9, 
 | 
			
		||||
   3.694894811418371*^9}, {3.6949626931212053`*^9, 3.694962703130487*^9}, {
 | 
			
		||||
   3.694962897531991*^9, 3.694962897865933*^9}, {3.6949629511775627`*^9, 
 | 
			
		||||
   3.694963031525289*^9}, {3.694963065828494*^9, 3.694963098327538*^9}, {
 | 
			
		||||
   3.6949632020836153`*^9, 3.6949632715940027`*^9}, {3.694963440035037*^9, 
 | 
			
		||||
   3.6949634418966017`*^9}, {3.6949651447067547`*^9, 3.694965161228381*^9}, {
 | 
			
		||||
   3.694967957845581*^9, 3.694967958364184*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell[BoxData[
 | 
			
		||||
 RowBox[{
 | 
			
		||||
  RowBox[{"file", "=", 
 | 
			
		||||
   RowBox[{"OpenWrite", "[", "\"\<Dirac.cc\>\"", "]"}]}], ";", 
 | 
			
		||||
   RowBox[{"OpenWrite", "[", "\"\<Gamma.cc\>\"", "]"}]}], ";", 
 | 
			
		||||
  RowBox[{"WriteString", "[", 
 | 
			
		||||
   RowBox[{"file", ",", 
 | 
			
		||||
    RowBox[{"makeSourceCode", "[", "]"}]}], "]"}], ";", 
 | 
			
		||||
  RowBox[{"Close", "[", "file", "]"}], ";"}]], "Input",
 | 
			
		||||
 CellChangeTimes->{{3.694212294084733*^9, 3.694212304244363*^9}, {
 | 
			
		||||
  3.6942124200138683`*^9, 3.694212434840803*^9}}]
 | 
			
		||||
  3.6942124200138683`*^9, 3.694212434840803*^9}, {3.6948947822948923`*^9, 
 | 
			
		||||
  3.694894782897565*^9}}],
 | 
			
		||||
 | 
			
		||||
Cell[BoxData[""], "Input",
 | 
			
		||||
 CellChangeTimes->{{3.6949630607688303`*^9, 3.694963063131344*^9}}]
 | 
			
		||||
}, Open  ]]
 | 
			
		||||
},
 | 
			
		||||
WindowSize->{1246, 1005},
 | 
			
		||||
@@ -1476,43 +1444,43 @@ Notebook[{
 | 
			
		||||
Cell[558, 20, 1295, 18, 502, "Text"],
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
Cell[1878, 42, 513, 10, 75, "Input"],
 | 
			
		||||
Cell[2394, 54, 821, 12, 32, "Output"]
 | 
			
		||||
Cell[2394, 54, 1090, 15, 32, "Output"]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
Cell[3252, 71, 114, 1, 64, "Section"],
 | 
			
		||||
Cell[3369, 74, 475, 14, 54, "Input"],
 | 
			
		||||
Cell[3847, 90, 190, 2, 30, "Text"],
 | 
			
		||||
Cell[4040, 94, 5454, 168, 427, "Input"],
 | 
			
		||||
Cell[9497, 264, 119, 1, 30, "Text"],
 | 
			
		||||
Cell[9619, 267, 2115, 63, 96, "Input"],
 | 
			
		||||
Cell[11737, 332, 133, 1, 30, "Text"],
 | 
			
		||||
Cell[3521, 74, 114, 1, 64, "Section"],
 | 
			
		||||
Cell[3638, 77, 475, 14, 54, "Input"],
 | 
			
		||||
Cell[4116, 93, 190, 2, 30, "Text"],
 | 
			
		||||
Cell[4309, 97, 5454, 168, 427, "Input"],
 | 
			
		||||
Cell[9766, 267, 119, 1, 30, "Text"],
 | 
			
		||||
Cell[9888, 270, 2115, 63, 96, "Input"],
 | 
			
		||||
Cell[12006, 335, 133, 1, 30, "Text"],
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
Cell[11895, 337, 479, 15, 32, "Input"],
 | 
			
		||||
Cell[12377, 354, 1398, 30, 96, "Output"]
 | 
			
		||||
Cell[12164, 340, 479, 15, 32, "Input"],
 | 
			
		||||
Cell[12646, 357, 1648, 34, 96, "Output"]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
Cell[13790, 387, 110, 1, 30, "Text"],
 | 
			
		||||
Cell[14309, 394, 110, 1, 30, "Text"],
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
Cell[13925, 392, 476, 12, 32, "Input"],
 | 
			
		||||
Cell[14404, 406, 6453, 162, 312, "Output"]
 | 
			
		||||
Cell[14444, 399, 476, 12, 32, "Input"],
 | 
			
		||||
Cell[14923, 413, 6697, 166, 312, "Output"]
 | 
			
		||||
}, Open  ]]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
Cell[20906, 574, 117, 1, 64, "Section"],
 | 
			
		||||
Cell[21026, 577, 128, 2, 38, "Text"],
 | 
			
		||||
Cell[21157, 581, 2742, 49, 894, "Input"],
 | 
			
		||||
Cell[23902, 632, 164, 3, 38, "Text"],
 | 
			
		||||
Cell[24069, 637, 4876, 148, 684, "Input"],
 | 
			
		||||
Cell[28948, 787, 2588, 55, 201, "Input"],
 | 
			
		||||
Cell[31539, 844, 149, 2, 38, "Text"],
 | 
			
		||||
Cell[31691, 848, 17242, 426, 3456, "Input"],
 | 
			
		||||
Cell[48936, 1276, 137, 2, 38, "Text"],
 | 
			
		||||
Cell[49076, 1280, 468, 11, 32, "Input"]
 | 
			
		||||
Cell[21669, 585, 166, 2, 64, "Section"],
 | 
			
		||||
Cell[21838, 589, 128, 2, 38, "Text"],
 | 
			
		||||
Cell[21969, 593, 2923, 52, 705, "Input"],
 | 
			
		||||
Cell[24895, 647, 164, 3, 38, "Text"],
 | 
			
		||||
Cell[25062, 652, 4876, 148, 684, "Input"],
 | 
			
		||||
Cell[29941, 802, 2588, 55, 201, "Input"],
 | 
			
		||||
Cell[32532, 859, 149, 2, 38, "Text"],
 | 
			
		||||
Cell[32684, 863, 15249, 396, 2133, "Input"],
 | 
			
		||||
Cell[47936, 1261, 137, 2, 38, "Text"],
 | 
			
		||||
Cell[48076, 1265, 521, 12, 32, "Input"]
 | 
			
		||||
}, Open  ]],
 | 
			
		||||
Cell[CellGroupData[{
 | 
			
		||||
Cell[49581, 1296, 116, 1, 64, "Section"],
 | 
			
		||||
Cell[49700, 1299, 4128, 95, 390, "Input"],
 | 
			
		||||
Cell[53831, 1396, 2179, 48, 432, "Input"],
 | 
			
		||||
Cell[56013, 1446, 397, 9, 32, "Input"]
 | 
			
		||||
Cell[48634, 1282, 167, 2, 64, "Section"],
 | 
			
		||||
Cell[48804, 1286, 5693, 122, 831, "Input"],
 | 
			
		||||
Cell[54500, 1410, 448, 10, 32, "Input"],
 | 
			
		||||
Cell[54951, 1422, 94, 1, 32, "Input"]
 | 
			
		||||
}, Open  ]]
 | 
			
		||||
}
 | 
			
		||||
]
 | 
			
		||||
 
 | 
			
		||||
@@ -138,6 +138,54 @@ namespace Grid {
 | 
			
		||||
    unsigned int               dimInd_{0};
 | 
			
		||||
  };
 | 
			
		||||
  
 | 
			
		||||
  // Pair IO utilities /////////////////////////////////////////////////////////
 | 
			
		||||
  // helper function to parse input in the format "<obj1 obj2>"
 | 
			
		||||
  template <typename T1, typename T2>
 | 
			
		||||
  inline std::istream & operator>>(std::istream &is, std::pair<T1, T2> &buf)
 | 
			
		||||
  {
 | 
			
		||||
    T1 buf1;
 | 
			
		||||
    T2 buf2;
 | 
			
		||||
    char c;
 | 
			
		||||
 | 
			
		||||
    // Search for "pair" delimiters.
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
      is.get(c);
 | 
			
		||||
    } while (c != '<' && !is.eof());
 | 
			
		||||
    if (c == '<')
 | 
			
		||||
    {
 | 
			
		||||
      int start = is.tellg();
 | 
			
		||||
      do
 | 
			
		||||
      {
 | 
			
		||||
        is.get(c);
 | 
			
		||||
      } while (c != '>' && !is.eof());
 | 
			
		||||
      if (c == '>')
 | 
			
		||||
      {
 | 
			
		||||
        int end = is.tellg();
 | 
			
		||||
        int psize = end - start - 1;
 | 
			
		||||
 | 
			
		||||
        // Only read data between pair limiters.
 | 
			
		||||
        is.seekg(start);
 | 
			
		||||
        std::string tmpstr(psize, ' ');
 | 
			
		||||
        is.read(&tmpstr[0], psize);
 | 
			
		||||
        std::istringstream temp(tmpstr);
 | 
			
		||||
        temp >> buf1 >> buf2;
 | 
			
		||||
        buf = std::make_pair(buf1, buf2);
 | 
			
		||||
        is.seekg(end);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    is.peek();
 | 
			
		||||
    return is;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  // output to streams for pairs
 | 
			
		||||
  template <class T1, class T2>
 | 
			
		||||
  inline std::ostream & operator<<(std::ostream &os, const std::pair<T1, T2> &p)
 | 
			
		||||
  {
 | 
			
		||||
    os << "<" << p.first << " " << p.second << ">";
 | 
			
		||||
    return os;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Abstract writer/reader classes ////////////////////////////////////////////
 | 
			
		||||
  // static polymorphism implemented using CRTP idiom
 | 
			
		||||
  class Serializable;
 | 
			
		||||
 
 | 
			
		||||
@@ -189,6 +189,15 @@ public:\
 | 
			
		||||
    }\
 | 
			
		||||
    return os;\
 | 
			
		||||
  }\
 | 
			
		||||
  inline friend std::istream & operator>>(std::istream &is, name &obj)\
 | 
			
		||||
  {\
 | 
			
		||||
    std::string buf;\
 | 
			
		||||
    is >> buf;\
 | 
			
		||||
    if (buf == #undefname) {obj = name::undefname;}\
 | 
			
		||||
    GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_ENUMTEST,__VA_ARGS__))\
 | 
			
		||||
    else {obj = name::undefname;}\
 | 
			
		||||
    return is;\
 | 
			
		||||
  }\
 | 
			
		||||
private:\
 | 
			
		||||
  int value_;\
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,7 @@ int main(int argc,char **argv)
 | 
			
		||||
  // test serializable class writing
 | 
			
		||||
  myclass              obj(1234); // non-trivial constructor
 | 
			
		||||
  std::vector<myclass> vec;
 | 
			
		||||
  std::pair<myenum, myenum> pair;
 | 
			
		||||
  
 | 
			
		||||
  std::cout << "-- serialisable class writing to 'bother.xml'..." << std::endl;
 | 
			
		||||
  write(WR,"obj",obj);
 | 
			
		||||
@@ -120,6 +121,8 @@ int main(int argc,char **argv)
 | 
			
		||||
  vec.push_back(myclass(1234));
 | 
			
		||||
  vec.push_back(myclass(5678));
 | 
			
		||||
  vec.push_back(myclass(3838));
 | 
			
		||||
  pair = std::make_pair(myenum::red, myenum::blue);
 | 
			
		||||
 | 
			
		||||
  write(WR, "objvec", vec);
 | 
			
		||||
  std::cout << "-- serialisable class writing to std::cout:" << std::endl;
 | 
			
		||||
  std::cout << obj << std::endl;
 | 
			
		||||
@@ -127,21 +130,30 @@ int main(int argc,char **argv)
 | 
			
		||||
  std::cout << "vec[0] == obj: " << ((vec[0] == obj) ? "true" : "false") << std::endl;
 | 
			
		||||
  std::cout << "vec[1] == obj: " << ((vec[1] == obj) ? "true" : "false") << std::endl;
 | 
			
		||||
  
 | 
			
		||||
  write(WR, "objpair", pair);
 | 
			
		||||
  std::cout << "-- pair writing to std::cout:" << std::endl;
 | 
			
		||||
  std::cout << pair << std::endl;
 | 
			
		||||
  
 | 
			
		||||
  // read tests
 | 
			
		||||
  std::cout << "\n==== IO self-consistency tests" << std::endl;
 | 
			
		||||
  //// XML
 | 
			
		||||
  ioTest<XmlWriter, XmlReader>("iotest.xml", obj, "XML    (object)           ");
 | 
			
		||||
  ioTest<XmlWriter, XmlReader>("iotest.xml", vec, "XML    (vector of objects)");
 | 
			
		||||
  ioTest<XmlWriter, XmlReader>("iotest.xml", pair, "XML    (pair of objects)");
 | 
			
		||||
  //// binary
 | 
			
		||||
  ioTest<BinaryWriter, BinaryReader>("iotest.bin", obj, "binary (object)           ");
 | 
			
		||||
  ioTest<BinaryWriter, BinaryReader>("iotest.bin", vec, "binary (vector of objects)");
 | 
			
		||||
  ioTest<BinaryWriter, BinaryReader>("iotest.bin", pair, "binary (pair of objects)");
 | 
			
		||||
  //// text
 | 
			
		||||
  ioTest<TextWriter, TextReader>("iotest.dat", obj, "text   (object)           ");
 | 
			
		||||
  ioTest<TextWriter, TextReader>("iotest.dat", vec, "text   (vector of objects)");
 | 
			
		||||
  ioTest<TextWriter, TextReader>("iotest.dat", pair, "text   (pair of objects)");
 | 
			
		||||
  //// HDF5
 | 
			
		||||
#undef HAVE_HDF5
 | 
			
		||||
#ifdef HAVE_HDF5
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader>("iotest.h5", obj, "HDF5   (object)           ");
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader>("iotest.h5", vec, "HDF5   (vector of objects)");
 | 
			
		||||
  ioTest<Hdf5Writer, Hdf5Reader>("iotest.h5", pair, "HDF5   (pair of objects)");
 | 
			
		||||
#endif
 | 
			
		||||
  
 | 
			
		||||
  std::cout << "\n==== vector flattening/reconstruction" << std::endl;
 | 
			
		||||
 
 | 
			
		||||
@@ -137,7 +137,7 @@ void test(const Expr &a, const Expr &b)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void checkMat(const Gamma::Algebra a, GridSerialRNG &rng)
 | 
			
		||||
void checkGamma(const Gamma::Algebra a, GridSerialRNG &rng)
 | 
			
		||||
{
 | 
			
		||||
  SpinVector v;
 | 
			
		||||
  SpinMatrix m, &testg = testAlgebra[a];
 | 
			
		||||
@@ -212,6 +212,28 @@ std::cout << std::endl;
 | 
			
		||||
#undef CHECK_PROJ
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void checkGammaL(const Gamma::Algebra a, GridSerialRNG &rng)
 | 
			
		||||
{
 | 
			
		||||
  SpinVector v;
 | 
			
		||||
  SpinMatrix m, &testg = testAlgebra[a], pl;
 | 
			
		||||
  GammaL     gl(a);
 | 
			
		||||
  bool       pass = true;
 | 
			
		||||
  
 | 
			
		||||
  random(rng, v);
 | 
			
		||||
  random(rng, m);
 | 
			
		||||
  
 | 
			
		||||
  pl = testAlgebra[Gamma::Algebra::Identity]
 | 
			
		||||
       - testAlgebra[Gamma::Algebra::Gamma5];
 | 
			
		||||
  std::cout << GridLogMessage << "Checking left-projected " << Gamma::name[a] << ": ";
 | 
			
		||||
  std::cout << "vecmul ";
 | 
			
		||||
  test(gl*v, testg*pl*v);
 | 
			
		||||
  std::cout << "matlmul ";
 | 
			
		||||
  test(gl*m, testg*pl*m);
 | 
			
		||||
  std::cout << "matrmul ";
 | 
			
		||||
  test(m*gl, m*testg*pl);
 | 
			
		||||
  std::cout << std::endl;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[])
 | 
			
		||||
{
 | 
			
		||||
  Grid_init(&argc,&argv);
 | 
			
		||||
@@ -230,7 +252,7 @@ int main(int argc, char *argv[])
 | 
			
		||||
  std::cout << GridLogMessage << "======== Multiplication operators check" << std::endl;
 | 
			
		||||
  for (int i = 0; i < Gamma::nGamma; ++i)
 | 
			
		||||
  {
 | 
			
		||||
    checkMat(i, sRNG);
 | 
			
		||||
    checkGamma(i, sRNG);
 | 
			
		||||
  }
 | 
			
		||||
  std::cout << GridLogMessage << std::endl;
 | 
			
		||||
  std::cout << GridLogMessage << "======== Algebra multiplication table check" << std::endl;
 | 
			
		||||
@@ -249,6 +271,11 @@ int main(int argc, char *argv[])
 | 
			
		||||
  std::cout << GridLogMessage << "======== Spin projectors check" << std::endl;
 | 
			
		||||
  checkProject(sRNG);
 | 
			
		||||
  std::cout << GridLogMessage << std::endl;
 | 
			
		||||
  std::cout << GridLogMessage << "======== Gamma-left matrices check" << std::endl;
 | 
			
		||||
  for (int i = 0; i < Gamma::nGamma; ++i)
 | 
			
		||||
  {
 | 
			
		||||
    checkGammaL(i, sRNG);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  Grid_finalize();
 | 
			
		||||
  
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user