From e855c41772aaffb167bb6c448052737812bdfeb5 Mon Sep 17 00:00:00 2001 From: Julian Lenz Date: Thu, 18 May 2023 18:09:38 +0100 Subject: [PATCH 1/3] Unified spfundamental.h with fundamental.h --- Grid/qcd/representations/Representations.h | 1 - Grid/qcd/representations/fundamental.h | 7 ++-- Grid/qcd/representations/hmc_types.h | 1 - Grid/qcd/representations/spfundamental.h | 42 ---------------------- 4 files changed, 4 insertions(+), 47 deletions(-) delete mode 100644 Grid/qcd/representations/spfundamental.h diff --git a/Grid/qcd/representations/Representations.h b/Grid/qcd/representations/Representations.h index 8791f653..85dc6596 100644 --- a/Grid/qcd/representations/Representations.h +++ b/Grid/qcd/representations/Representations.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/Grid/qcd/representations/fundamental.h b/Grid/qcd/representations/fundamental.h index 4d4779e1..90592abb 100644 --- a/Grid/qcd/representations/fundamental.h +++ b/Grid/qcd/representations/fundamental.h @@ -13,7 +13,7 @@ NAMESPACE_BEGIN(Grid); * Empty since HMC updates already the fundamental representation */ -template +template class FundamentalRep { public: static const int Dimension = ncolour; @@ -21,7 +21,7 @@ public: // typdef to be used by the Representations class in HMC to get the // types for the higher representation fields - typedef typename SU::LatticeMatrix LatticeMatrix; + typedef typename GaugeGroup::LatticeMatrix LatticeMatrix; typedef LatticeGaugeField LatticeField; explicit FundamentalRep(GridBase* grid) {} //do nothing @@ -45,7 +45,8 @@ public: -typedef FundamentalRep FundamentalRepresentation; +typedef FundamentalRep FundamentalRepresentation; +typedef FundamentalRep SpFundamentalRepresentation; NAMESPACE_END(Grid); diff --git a/Grid/qcd/representations/hmc_types.h b/Grid/qcd/representations/hmc_types.h index a24d5752..7ad67079 100644 --- a/Grid/qcd/representations/hmc_types.h +++ b/Grid/qcd/representations/hmc_types.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/Grid/qcd/representations/spfundamental.h b/Grid/qcd/representations/spfundamental.h deleted file mode 100644 index df6b6fed..00000000 --- a/Grid/qcd/representations/spfundamental.h +++ /dev/null @@ -1,42 +0,0 @@ - - -#ifndef SPFUNDAMENTAL_H -#define SPFUNDAMENTAL_H - -NAMESPACE_BEGIN(Grid); - -/* - * This is an helper class for the HMC - * Empty since HMC updates already the fundamental representation - */ - -template -class SpFundamentalRep { -public: - static const int Dimension = ncolour; - //static const int nSp = ncolour/2; - static const bool isFundamental = true; - - // typdef to be used by the Representations class in HMC to get the - // types for the higher representation fields - typedef typename Sp::LatticeMatrix LatticeMatrix; - typedef LatticeGaugeField LatticeField; - - explicit SpFundamentalRep(GridBase* grid) {} //do nothing - void update_representation(const LatticeGaugeField& Uin) {} // do nothing - - LatticeField RtoFundamentalProject(const LatticeField& in, Real scale = 1.0) const{ - return (scale * in); - } - -}; - - - - - -typedef SpFundamentalRep SpFundamentalRepresentation; - -NAMESPACE_END(Grid); - -#endif From b8bdc2eefbe5a585bf7b140c32e0bf7a3b8503e3 Mon Sep 17 00:00:00 2001 From: Julian Lenz Date: Thu, 18 May 2023 18:36:29 +0100 Subject: [PATCH 2/3] Unified two index representations --- Grid/qcd/representations/Representations.h | 1 - Grid/qcd/representations/hmc_types.h | 1 - Grid/qcd/representations/sp_two_index.h | 100 --------------------- Grid/qcd/representations/two_index.h | 25 +++--- 4 files changed, 14 insertions(+), 113 deletions(-) delete mode 100644 Grid/qcd/representations/sp_two_index.h diff --git a/Grid/qcd/representations/Representations.h b/Grid/qcd/representations/Representations.h index 85dc6596..22311be0 100644 --- a/Grid/qcd/representations/Representations.h +++ b/Grid/qcd/representations/Representations.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #endif diff --git a/Grid/qcd/representations/hmc_types.h b/Grid/qcd/representations/hmc_types.h index 7ad67079..5e4ab020 100644 --- a/Grid/qcd/representations/hmc_types.h +++ b/Grid/qcd/representations/hmc_types.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include diff --git a/Grid/qcd/representations/sp_two_index.h b/Grid/qcd/representations/sp_two_index.h deleted file mode 100644 index 7fe097b9..00000000 --- a/Grid/qcd/representations/sp_two_index.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Policy classes for the HMC - * Authors: Guido Cossu, David Preti - */ - -#ifndef SP2N2INDEX_H_H -#define SP2N2INDEX_H_H - -NAMESPACE_BEGIN(Grid); - -/* - * This is an helper class for the HMC - * Should contain only the data for the two index representations - * and the facility to convert from the fundamental -> two index - * The templated parameter TwoIndexSymmetry choses between the - * symmetric and antisymmetric representations - * - * There is an - * enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 }; - * in the SUnTwoIndex.h file - */ - -template -class SpTwoIndexRep { -public: - // typdef to be used by the Representations class in HMC to get the - // types for the higher representation fields - typedef typename Sp_TwoIndex::LatticeTwoIndexMatrix LatticeMatrix; - typedef typename Sp_TwoIndex::LatticeTwoIndexField LatticeField; - static const int Dimension = (ncolour * (ncolour + S) / 2) + S; - static const bool isFundamental = false; - //static const int nsp = Nc / 2; - LatticeField U; - - explicit SpTwoIndexRep(GridBase *grid) : U(grid) {} - - void update_representation(const LatticeGaugeField &Uin) { - std::cout << GridLogDebug << "Updating TwoIndex representation\n"; - // Uin is in the fundamental representation - // get the U in TwoIndexRep - // (U)_{(ij)(lk)} = tr [ adj(e^(ij)) U e^(lk) transpose(U) ] - conformable(U, Uin); - U = Zero(); - LatticeColourMatrix tmp(Uin.Grid()); - - Vector::Matrix> eij(Dimension); - - for (int a = 0; a < Dimension; a++) - Sp_TwoIndex::base(a, eij[a]); - - for (int mu = 0; mu < Nd; mu++) { - auto Uin_mu = peekLorentz(Uin, mu); - auto U_mu = peekLorentz(U, mu); - for (int a = 0; a < Dimension; a++) { - tmp = transpose(Uin_mu) * adj(eij[a]) * Uin_mu; - for (int b = 0; b < Dimension; b++) - pokeColour(U_mu, trace(tmp * eij[b]), a, b); - } - pokeLorentz(U, U_mu, mu); - } - } - - LatticeGaugeField RtoFundamentalProject(const LatticeField &in, - Real scale = 1.0) const { - LatticeGaugeField out(in.Grid()); - out = Zero(); - - for (int mu = 0; mu < Nd; mu++) { - LatticeColourMatrix out_mu(in.Grid()); // fundamental representation - LatticeMatrix in_mu = peekLorentz(in, mu); - - out_mu = Zero(); - - typename Sp::LatticeAlgebraVector h(in.Grid()); - projectOnAlgebra(h, in_mu, double(Nc + 2 * S)); // factor T(r)/T(fund) - FundamentalLieAlgebraMatrix(h, out_mu); // apply scale only once - pokeLorentz(out, out_mu, mu); // should be 2 for sp4 as. ok - } - return out; - } - -private: - void projectOnAlgebra(typename Sp::LatticeAlgebraVector &h_out, - const LatticeMatrix &in, Real scale = 1.0) const { - Sp_TwoIndex::projectOnAlgebra(h_out, in, scale); - } - - void FundamentalLieAlgebraMatrix( - typename Sp::LatticeAlgebraVector &h, - typename Sp::LatticeMatrix &out, Real scale = 1.0) const { - Sp::FundamentalLieAlgebraMatrix(h, out, scale); - } -}; - -typedef SpTwoIndexRep SpTwoIndexSymmetricRepresentation; -typedef SpTwoIndexRep SpTwoIndexAntiSymmetricRepresentation; - -NAMESPACE_END(Grid); - -#endif diff --git a/Grid/qcd/representations/two_index.h b/Grid/qcd/representations/two_index.h index 8dfb5561..9fa6a203 100644 --- a/Grid/qcd/representations/two_index.h +++ b/Grid/qcd/representations/two_index.h @@ -20,14 +20,14 @@ NAMESPACE_BEGIN(Grid); * in the SUnTwoIndex.h file */ -template +template class TwoIndexRep { public: // typdef to be used by the Representations class in HMC to get the // types for the higher representation fields - typedef typename SU_TwoIndex::LatticeTwoIndexMatrix LatticeMatrix; - typedef typename SU_TwoIndex::LatticeTwoIndexField LatticeField; - static const int Dimension = ncolour * (ncolour + S) / 2; + typedef typename GaugeGroupTwoIndex::LatticeTwoIndexMatrix LatticeMatrix; + typedef typename GaugeGroupTwoIndex::LatticeTwoIndexField LatticeField; + static const int Dimension = GaugeGroupTwoIndex::Dimension; static const bool isFundamental = false; LatticeField U; @@ -43,10 +43,10 @@ public: U = Zero(); LatticeColourMatrix tmp(Uin.Grid()); - Vector::Matrix> eij(Dimension); + Vector::Matrix> eij(Dimension); for (int a = 0; a < Dimension; a++) - SU_TwoIndex::base(a, eij[a]); + GaugeGroupTwoIndex::base(a, eij[a]); for (int mu = 0; mu < Nd; mu++) { auto Uin_mu = peekLorentz(Uin, mu); @@ -71,7 +71,7 @@ public: out_mu = Zero(); - typename SU::LatticeAlgebraVector h(in.Grid()); + typename GaugeGroup::LatticeAlgebraVector h(in.Grid()); projectOnAlgebra(h, in_mu, double(Nc + 2 * S)); // factor T(r)/T(fund) FundamentalLieAlgebraMatrix(h, out_mu); // apply scale only once pokeLorentz(out, out_mu, mu); @@ -82,18 +82,21 @@ public: private: void projectOnAlgebra(typename SU::LatticeAlgebraVector &h_out, const LatticeMatrix &in, Real scale = 1.0) const { - SU_TwoIndex::projectOnAlgebra(h_out, in, scale); + GaugeGroupTwoIndex::projectOnAlgebra(h_out, in, scale); } void FundamentalLieAlgebraMatrix( typename SU::LatticeAlgebraVector &h, typename SU::LatticeMatrix &out, Real scale = 1.0) const { - SU::FundamentalLieAlgebraMatrix(h, out, scale); + GaugeGroup::FundamentalLieAlgebraMatrix(h, out, scale); } }; -typedef TwoIndexRep TwoIndexSymmetricRepresentation; -typedef TwoIndexRep TwoIndexAntiSymmetricRepresentation; +typedef TwoIndexRep TwoIndexSymmetricRepresentation; +typedef TwoIndexRep TwoIndexAntiSymmetricRepresentation; + +typedef TwoIndexRep SpTwoIndexSymmetricRepresentation; +typedef TwoIndexRep SpTwoIndexAntiSymmetricRepresentation; NAMESPACE_END(Grid); From 85b2cb7a8aa3b9eceb4ed85e03881baac1bea3e4 Mon Sep 17 00:00:00 2001 From: Alessandro Lupo Date: Sun, 21 May 2023 14:50:28 +0100 Subject: [PATCH 3/3] changing some hardcoded SUn lines --- Grid/qcd/representations/two_index.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Grid/qcd/representations/two_index.h b/Grid/qcd/representations/two_index.h index 9fa6a203..9a06dc6f 100644 --- a/Grid/qcd/representations/two_index.h +++ b/Grid/qcd/representations/two_index.h @@ -80,14 +80,14 @@ public: } private: - void projectOnAlgebra(typename SU::LatticeAlgebraVector &h_out, + void projectOnAlgebra(typename GaugeGroup::LatticeAlgebraVector &h_out, const LatticeMatrix &in, Real scale = 1.0) const { GaugeGroupTwoIndex::projectOnAlgebra(h_out, in, scale); } void FundamentalLieAlgebraMatrix( - typename SU::LatticeAlgebraVector &h, - typename SU::LatticeMatrix &out, Real scale = 1.0) const { + typename GaugeGroup::LatticeAlgebraVector &h, + typename GaugeGroup::LatticeMatrix &out, Real scale = 1.0) const { GaugeGroup::FundamentalLieAlgebraMatrix(h, out, scale); } };