mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-09 23:45:36 +00:00
fix code duplication
This commit is contained in:
parent
cbc053c3db
commit
1b8176e2c0
@ -170,38 +170,116 @@ class GaugeGroup {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename LatticeMatrixType>
|
||||
template <typename LatticeMatrixType>
|
||||
static void LieRandomize(GridParallelRNG &pRNG, LatticeMatrixType &out,
|
||||
double scale = 1.0) {
|
||||
LieRandomize(pRNG, out, group_name(), scale);
|
||||
GridBase *grid = out.Grid();
|
||||
|
||||
typedef typename LatticeMatrixType::vector_type vector_type;
|
||||
typedef typename LatticeMatrixType::scalar_type scalar_type;
|
||||
|
||||
typedef iSinglet<vector_type> vTComplexType;
|
||||
|
||||
typedef Lattice<vTComplexType> LatticeComplexType;
|
||||
typedef typename GridTypeMapper<
|
||||
typename LatticeMatrixType::vector_object>::scalar_object MatrixType;
|
||||
|
||||
LatticeComplexType ca(grid);
|
||||
LatticeMatrixType lie(grid);
|
||||
LatticeMatrixType la(grid);
|
||||
ComplexD ci(0.0, scale);
|
||||
// ComplexD cone(1.0, 0.0);
|
||||
MatrixType ta;
|
||||
|
||||
lie = Zero();
|
||||
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
random(pRNG, ca);
|
||||
|
||||
ca = (ca + conjugate(ca)) * 0.5;
|
||||
ca = ca - 0.5;
|
||||
|
||||
generator(a, ta);
|
||||
|
||||
la = ci * ca * ta;
|
||||
|
||||
lie = lie + la; // e^{i la ta}
|
||||
}
|
||||
taExp(lie, out);
|
||||
}
|
||||
|
||||
static void GaussianFundamentalLieAlgebraMatrix(GridParallelRNG &pRNG,
|
||||
LatticeMatrix &out,
|
||||
Real scale = 1.0) {
|
||||
GaussianFundamentalLieAlgebraMatrix(pRNG, out, group_name(), scale);
|
||||
GridBase *grid = out.Grid();
|
||||
LatticeReal ca(grid);
|
||||
LatticeMatrix la(grid);
|
||||
Complex ci(0.0, scale);
|
||||
Matrix ta;
|
||||
|
||||
out = Zero();
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
gaussian(pRNG, ca);
|
||||
generator(a, ta);
|
||||
la = toComplex(ca) * ta;
|
||||
out += la;
|
||||
}
|
||||
out *= ci;
|
||||
}
|
||||
|
||||
static void FundamentalLieAlgebraMatrix(const LatticeAlgebraVector &h,
|
||||
LatticeMatrix &out,
|
||||
Real scale = 1.0) {
|
||||
FundamentalLieAlgebraMatrix(h, out, group_name(), scale);
|
||||
conformable(h, out);
|
||||
GridBase *grid = out.Grid();
|
||||
LatticeMatrix la(grid);
|
||||
Matrix ta;
|
||||
|
||||
out = Zero();
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
generator(a, ta);
|
||||
la = peekColour(h, a) * timesI(ta) * scale;
|
||||
out += la;
|
||||
}
|
||||
}
|
||||
|
||||
// Projects the algebra components a lattice matrix (of dimension ncol*ncol -1
|
||||
// ) inverse operation: FundamentalLieAlgebraMatrix
|
||||
static void projectOnAlgebra(LatticeAlgebraVector &h_out,
|
||||
const LatticeMatrix &in, Real scale = 1.0) {
|
||||
projectOnAlgebra(h_out, in, group_name(), scale);
|
||||
conformable(h_out, in);
|
||||
h_out = Zero();
|
||||
Matrix Ta;
|
||||
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
generator(a, Ta);
|
||||
pokeColour(h_out, -2.0 * (trace(timesI(Ta) * in)) * scale, a);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GaugeField>
|
||||
static void HotConfiguration(GridParallelRNG &pRNG, GaugeField &out) {
|
||||
HotConfiguration(pRNG, out, group_name());
|
||||
typedef typename GaugeField::vector_type vector_type;
|
||||
typedef iGroupMatrix<vector_type> vMatrixType;
|
||||
typedef Lattice<vMatrixType> LatticeMatrixType;
|
||||
|
||||
LatticeMatrixType Umu(out.Grid());
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
LieRandomize(pRNG, Umu, 1.0);
|
||||
PokeIndex<LorentzIndex>(out, Umu, mu);
|
||||
}
|
||||
}
|
||||
template <typename GaugeField>
|
||||
static void TepidConfiguration(GridParallelRNG &pRNG, GaugeField &out) {
|
||||
TepidConfiguration(pRNG, out, group_name());
|
||||
typedef typename GaugeField::vector_type vector_type;
|
||||
typedef iGroupMatrix<vector_type> vMatrixType;
|
||||
typedef Lattice<vMatrixType> LatticeMatrixType;
|
||||
|
||||
LatticeMatrixType Umu(out.Grid());
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
LieRandomize(pRNG, Umu, 0.01);
|
||||
PokeIndex<LorentzIndex>(out, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GaugeField>
|
||||
@ -255,17 +333,31 @@ class GaugeGroup {
|
||||
ProjectOnGaugeGroup(Umu, group_name());
|
||||
}
|
||||
|
||||
|
||||
template <int N> // reunitarise, resimplectify... previously ProjectSUn
|
||||
static void ProjectGn(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu) {
|
||||
ProjectGn(Umu, group_name());
|
||||
}
|
||||
|
||||
template <int N> // reunitarise, resimplectify... previously ProjectSUn
|
||||
static void ProjectGn(Lattice<iVector<iScalar<iMatrix<vComplexD, N> >, Nd> > &U) {
|
||||
ProjectGn(U, group_name());
|
||||
|
||||
}
|
||||
template <int N> // reunitarise, resimplectify... previously ProjectSUn
|
||||
static void ProjectGn(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu) {
|
||||
ProjectOnGaugeGroup(Umu);
|
||||
auto det = Determinant(Umu);
|
||||
|
||||
det = conjugate(det);
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
auto element = PeekIndex<ColourIndex>(Umu, N - 1, i);
|
||||
element = element * det;
|
||||
PokeIndex<ColourIndex>(Umu, element, Nc - 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
template <int N> // reunitarise, resimplectify... previously ProjectSUn
|
||||
static void ProjectGn(Lattice<iVector<iScalar<iMatrix<vComplexD, N> >, Nd> > &U, GroupName::SU) {
|
||||
GridBase *grid = U.Grid();
|
||||
// Reunitarise
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
auto Umu = PeekIndex<LorentzIndex>(U, mu);
|
||||
ProjectOnGaugeGroup(Umu);
|
||||
PokeIndex<LorentzIndex>(U, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -508,119 +508,6 @@ static void testGenerators(GroupName::SU) {
|
||||
std::cout << GridLogMessage << std::endl;
|
||||
}
|
||||
|
||||
template <typename LatticeMatrixType>
|
||||
static void LieRandomize(GridParallelRNG &pRNG, LatticeMatrixType &out, GroupName::SU,
|
||||
double scale = 1.0) {
|
||||
GridBase *grid = out.Grid();
|
||||
|
||||
typedef typename LatticeMatrixType::vector_type vector_type;
|
||||
typedef typename LatticeMatrixType::scalar_type scalar_type;
|
||||
|
||||
typedef iSinglet<vector_type> vTComplexType;
|
||||
|
||||
typedef Lattice<vTComplexType> LatticeComplexType;
|
||||
typedef typename GridTypeMapper<
|
||||
typename LatticeMatrixType::vector_object>::scalar_object MatrixType;
|
||||
|
||||
LatticeComplexType ca(grid);
|
||||
LatticeMatrixType lie(grid);
|
||||
LatticeMatrixType la(grid);
|
||||
ComplexD ci(0.0, scale);
|
||||
// ComplexD cone(1.0, 0.0);
|
||||
MatrixType ta;
|
||||
|
||||
lie = Zero();
|
||||
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
random(pRNG, ca);
|
||||
|
||||
ca = (ca + conjugate(ca)) * 0.5;
|
||||
ca = ca - 0.5;
|
||||
|
||||
generator(a, ta);
|
||||
|
||||
la = ci * ca * ta;
|
||||
|
||||
lie = lie + la; // e^{i la ta}
|
||||
}
|
||||
taExp(lie, out);
|
||||
}
|
||||
|
||||
static void GaussianFundamentalLieAlgebraMatrix(GridParallelRNG &pRNG,
|
||||
LatticeMatrix &out, GroupName::SU,
|
||||
Real scale = 1.0) {
|
||||
GridBase *grid = out.Grid();
|
||||
LatticeReal ca(grid);
|
||||
LatticeMatrix la(grid);
|
||||
Complex ci(0.0, scale);
|
||||
Matrix ta;
|
||||
|
||||
out = Zero();
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
gaussian(pRNG, ca);
|
||||
generator(a, ta);
|
||||
la = toComplex(ca) * ta;
|
||||
out += la;
|
||||
}
|
||||
out *= ci;
|
||||
}
|
||||
|
||||
static void FundamentalLieAlgebraMatrix(const LatticeAlgebraVector &h,
|
||||
LatticeMatrix &out, GroupName::SU,
|
||||
Real scale = 1.0) {
|
||||
conformable(h, out);
|
||||
GridBase *grid = out.Grid();
|
||||
LatticeMatrix la(grid);
|
||||
Matrix ta;
|
||||
|
||||
out = Zero();
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
generator(a, ta);
|
||||
la = peekColour(h, a) * timesI(ta) * scale;
|
||||
out += la;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GaugeField>
|
||||
static void HotConfiguration(GridParallelRNG &pRNG, GaugeField &out, GroupName::SU) {
|
||||
typedef typename GaugeField::vector_type vector_type;
|
||||
typedef iGroupMatrix<vector_type> vMatrixType;
|
||||
typedef Lattice<vMatrixType> LatticeMatrixType;
|
||||
|
||||
LatticeMatrixType Umu(out.Grid());
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
LieRandomize(pRNG, Umu, 1.0);
|
||||
PokeIndex<LorentzIndex>(out, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GaugeField>
|
||||
static void TepidConfiguration(GridParallelRNG &pRNG, GaugeField &out, GroupName::SU) {
|
||||
typedef typename GaugeField::vector_type vector_type;
|
||||
typedef iGroupMatrix<vector_type> vMatrixType;
|
||||
typedef Lattice<vMatrixType> LatticeMatrixType;
|
||||
|
||||
LatticeMatrixType Umu(out.Grid());
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
LieRandomize(pRNG, Umu, 0.01);
|
||||
PokeIndex<LorentzIndex>(out, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
// Projects the algebra components a lattice matrix (of dimension ncol*ncol -1
|
||||
// ) inverse operation: FundamentalLieAlgebraMatrix
|
||||
static void projectOnAlgebra(LatticeAlgebraVector &h_out,
|
||||
const LatticeMatrix &in, GroupName::SU, Real scale = 1.0) {
|
||||
conformable(h_out, in);
|
||||
h_out = Zero();
|
||||
Matrix Ta;
|
||||
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
generator(a, Ta);
|
||||
pokeColour(h_out, -2.0 * (trace(timesI(Ta) * in)) * scale, a);
|
||||
}
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static void ProjectOnGaugeGroup(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu, GroupName::SU) {
|
||||
Umu = ProjectOnGroup(Umu);
|
||||
@ -636,32 +523,6 @@ static void ProjectOnGaugeGroup(Lattice<iVector<iScalar<iMatrix<vComplexD, N> >,
|
||||
}
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static void ProjectGn(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu, GroupName::SU) {
|
||||
Umu = ProjectOnGroup(Umu);
|
||||
auto det = Determinant(Umu);
|
||||
|
||||
det = conjugate(det);
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
auto element = PeekIndex<ColourIndex>(Umu, N - 1, i);
|
||||
element = element * det;
|
||||
PokeIndex<ColourIndex>(Umu, element, Nc - 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static void ProjectGn(Lattice<iVector<iScalar<iMatrix<vComplexD, N> >, Nd> > &U, GroupName::SU) {
|
||||
GridBase *grid = U.Grid();
|
||||
// Reunitarise
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
auto Umu = PeekIndex<LorentzIndex>(U, mu);
|
||||
Umu = ProjectOnGroup(Umu);
|
||||
ProjectSUn(Umu);
|
||||
PokeIndex<LorentzIndex>(U, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fundamental rep gauge xform
|
||||
*/
|
||||
|
@ -253,119 +253,6 @@ static void testGenerators(GroupName::Sp) {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename LatticeMatrixType>
|
||||
static void LieRandomize(GridParallelRNG &pRNG, LatticeMatrixType &out, GroupName::Sp,
|
||||
double scale = 1.0) {
|
||||
GridBase *grid = out.Grid();
|
||||
|
||||
typedef typename LatticeMatrixType::vector_type vector_type;
|
||||
typedef typename LatticeMatrixType::scalar_type scalar_type;
|
||||
|
||||
typedef iSinglet<vector_type> vTComplexType;
|
||||
|
||||
typedef Lattice<vTComplexType> LatticeComplexType;
|
||||
typedef typename GridTypeMapper<
|
||||
typename LatticeMatrixType::vector_object>::scalar_object MatrixType;
|
||||
|
||||
LatticeComplexType ca(grid);
|
||||
LatticeMatrixType lie(grid);
|
||||
LatticeMatrixType la(grid);
|
||||
ComplexD ci(0.0, scale);
|
||||
// ComplexD cone(1.0, 0.0);
|
||||
MatrixType ta;
|
||||
|
||||
lie = Zero();
|
||||
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
random(pRNG, ca);
|
||||
|
||||
ca = (ca + conjugate(ca)) * 0.5;
|
||||
ca = ca - 0.5;
|
||||
|
||||
generator(a, ta);
|
||||
|
||||
la = ci * ca * ta;
|
||||
|
||||
lie = lie + la; // e^{i la ta}
|
||||
}
|
||||
taExp(lie, out);
|
||||
}
|
||||
|
||||
static void GaussianFundamentalLieAlgebraMatrix(GridParallelRNG &pRNG,
|
||||
LatticeMatrix &out, GroupName::Sp,
|
||||
Real scale = 1.0) {
|
||||
GridBase *grid = out.Grid();
|
||||
LatticeReal ca(grid);
|
||||
LatticeMatrix la(grid);
|
||||
Complex ci(0.0, scale);
|
||||
Matrix ta;
|
||||
|
||||
out = Zero();
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
gaussian(pRNG, ca);
|
||||
generator(a, ta);
|
||||
la = toComplex(ca) * ta;
|
||||
out += la;
|
||||
}
|
||||
out *= ci;
|
||||
}
|
||||
|
||||
static void FundamentalLieAlgebraMatrix(const LatticeAlgebraVector &h,
|
||||
LatticeMatrix &out, GroupName::Sp,
|
||||
Real scale = 1.0) {
|
||||
conformable(h, out);
|
||||
GridBase *grid = out.Grid();
|
||||
LatticeMatrix la(grid);
|
||||
Matrix ta;
|
||||
|
||||
out = Zero();
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
generator(a, ta);
|
||||
la = peekColour(h, a) * timesI(ta) * scale;
|
||||
out += la;
|
||||
}
|
||||
}
|
||||
|
||||
// Projects the algebra components a lattice matrix (of dimension ncol*ncol -1
|
||||
// ) inverse operation: FundamentalLieAlgebraMatrix
|
||||
static void projectOnAlgebra(LatticeAlgebraVector &h_out,
|
||||
const LatticeMatrix &in, GroupName::Sp, Real scale = 1.0) {
|
||||
conformable(h_out, in);
|
||||
h_out = Zero();
|
||||
Matrix Ta;
|
||||
|
||||
for (int a = 0; a < AdjointDimension; a++) {
|
||||
generator(a, Ta);
|
||||
pokeColour(h_out, -2.0 * (trace(timesI(Ta) * in)) * scale, a);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GaugeField>
|
||||
static void HotConfiguration(GridParallelRNG &pRNG, GaugeField &out, GroupName::Sp) {
|
||||
typedef typename GaugeField::vector_type vector_type;
|
||||
typedef iGroupMatrix<vector_type> vMatrixType;
|
||||
typedef Lattice<vMatrixType> LatticeMatrixType;
|
||||
|
||||
LatticeMatrixType Umu(out.Grid());
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
LieRandomize(pRNG, Umu, 1.0);
|
||||
PokeIndex<LorentzIndex>(out, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename GaugeField>
|
||||
static void TepidConfiguration(GridParallelRNG &pRNG, GaugeField &out, GroupName::Sp) {
|
||||
typedef typename GaugeField::vector_type vector_type;
|
||||
typedef iGroupMatrix<vector_type> vMatrixType;
|
||||
typedef Lattice<vMatrixType> LatticeMatrixType;
|
||||
|
||||
LatticeMatrixType Umu(out.Grid());
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
LieRandomize(pRNG, Umu, 0.01);
|
||||
PokeIndex<LorentzIndex>(out, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static void ProjectOnGaugeGroup(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu, GroupName::Sp) {
|
||||
Umu = ProjectOnSpGroup(Umu);
|
||||
@ -381,32 +268,6 @@ static void ProjectOnGaugeGroup(Lattice<iVector<iScalar<iMatrix<vComplexD, N> >,
|
||||
}
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static void ProjectGn(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu, GroupName::Sp) {
|
||||
Umu = ProjectOnSpGroup(Umu);
|
||||
auto det = Determinant(Umu);
|
||||
|
||||
det = conjugate(det);
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
auto element = PeekIndex<ColourIndex>(Umu, N - 1, i);
|
||||
element = element * det;
|
||||
PokeIndex<ColourIndex>(Umu, element, Nc - 1, i);
|
||||
}
|
||||
}
|
||||
|
||||
template <int N>
|
||||
static void ProjectGn(Lattice<iVector<iScalar<iMatrix<vComplexD, N> >, Nd> > &U, GroupName::Sp) {
|
||||
GridBase *grid = U.Grid();
|
||||
// Reunitarise
|
||||
for (int mu = 0; mu < Nd; mu++) {
|
||||
auto Umu = PeekIndex<LorentzIndex>(U, mu);
|
||||
Umu = ProjectOnSpGroup(Umu);
|
||||
ProjectSUn(Umu);
|
||||
PokeIndex<LorentzIndex>(U, Umu, mu);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
template <ONLY_IF_Sp>
|
||||
static void OmegaInvariance(ColourMatrix &in) {
|
||||
|
Loading…
Reference in New Issue
Block a user