1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-09 23:45:36 +00:00

Merge pull request #26 from LupoA/sp2n/irreps

Sp2n/irreps
This commit is contained in:
chillenzer 2023-06-01 16:28:15 +00:00 committed by GitHub
commit 69dc5172dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 298 additions and 256 deletions

View File

@ -20,7 +20,7 @@ NAMESPACE_BEGIN(Grid);
* in the SUnTwoIndex.h file
*/
template <int ncolour, TwoIndexSymmetry S, class group_name>
template <int ncolour, TwoIndexSymmetry S, class group_name = GroupName::SU>
class TwoIndexRep {
public:
// typdef to be used by the Representations class in HMC to get the

View File

@ -31,6 +31,67 @@ enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
namespace detail {
template <class cplx, int nc, TwoIndexSymmetry S>
struct baseOffDiagonalSpHelper;
template <class cplx, int nc>
struct baseOffDiagonalSpHelper<cplx, nc, AntiSymmetric> {
static const int ngroup = nc / 2;
static void baseOffDiagonalSp(int i, int j, iScalar<iScalar<iMatrix<cplx, nc> > > &eij) {
eij = Zero();
RealD tmp;
if ((i == ngroup + j) && (1 <= j) && (j < ngroup)) {
for (int k = 0; k < ngroup; k++) {
if (k < j) {
tmp = sqrt(2 * j * (j + 1));
tmp = 1 / tmp;
tmp *= std::sqrt(2.0);
eij()()(k, k + ngroup) = tmp;
eij()()(k + ngroup, k) = -tmp;
}
if (k == j) {
tmp = sqrt(2 * j * (j + 1));
tmp = -j / tmp;
tmp *= std::sqrt(2.0);
eij()()(k, k + ngroup) = tmp;
eij()()(k + ngroup, k) = -tmp;
}
}
}
else if (i != ngroup + j) {
for (int k = 0; k < nc; k++)
for (int l = 0; l < nc; l++) {
eij()()(l, k) =
delta(i, k) * delta(j, l) - delta(j, k) * delta(i, l);
}
}
RealD nrm = 1. / std::sqrt(2.0);
eij = eij * nrm;
}
};
template <class cplx, int nc>
struct baseOffDiagonalSpHelper<cplx, nc, Symmetric> {
static void baseOffDiagonalSp(int i, int j, iScalar<iScalar<iMatrix<cplx, nc> > > &eij) {
eij = Zero();
for (int k = 0; k < nc; k++)
for (int l = 0; l < nc; l++)
eij()()(l, k) =
delta(i, k) * delta(j, l) + delta(j, k) * delta(i, l);
RealD nrm = 1. / std::sqrt(2.0);
eij = eij * nrm;
}
};
} // closing detail namespace
template <int ncolour, TwoIndexSymmetry S, class group_name>
class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
public:
@ -41,9 +102,12 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
"ngroup is only implemented for SU and Sp currently.");
static const int ngroup =
std::is_same<group_name, GroupName::SU>::value ? ncolour : ncolour / 2;
static const int Dimension = std::is_same<group_name, GroupName::SU>::value
? ncolour * (ncolour + S) / 2
: ngroup * (ncolour + S) + S;
static const int Dimension =
(ncolour * (ncolour + S) / 2) + (std::is_same<group_name, GroupName::Sp>::value ? (S - 1) / 2 : 0);
static const int DimensionAS =
(ncolour * (ncolour - 1) / 2) + (std::is_same<group_name, GroupName::Sp>::value ? (- 1) : 0);
static const int DimensionS =
ncolour * (ncolour + 1) / 2;
static const int NumGenerators =
GaugeGroup<ncolour, group_name>::AlgebraDimension;
@ -75,97 +139,17 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
typedef iGroupMatrix<Complex> Matrix;
typedef iGroupMatrix<ComplexF> MatrixF;
typedef iGroupMatrix<ComplexD> MatrixD;
template <class cplx>
static void base(int Index, iGroupMatrix<cplx> &eij) {
// This is inside of this function because you can't use this class without
// this function but you can still use its static constants because as a
// template the following static_assert is only triggered if this function
// is instantiated which in turn happens only when it's used.
static_assert(
std::is_same<group_name, GroupName::Sp>::value ? S != Symmetric : true,
"The symmetric two-index representation of Sp(2N) does not work "
"currently. If you want to use it, you need to implement the "
"equivalent of Eq. (27) and (28) from "
"https://doi.org/10.48550/arXiv.2202.05516.");
// returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
assert(Index < Dimension);
eij = Zero();
// for the linearisation of the 2 indexes
static int a[ncolour * (ncolour - 1) / 2][2]; // store the a <-> i,j
static bool filled = false;
if (!filled) {
int counter = 0;
for (int i = 1; i < ncolour; i++) {
for (int j = 0; j < i; j++) {
a[counter][0] = i;
if (j == 0 && ngroup == ncolour / 2 && i == ngroup + j) {
j = j + 1;
}
a[counter][1] = j;
counter++;
}
}
filled = true;
}
if (Index < ncolour * (ncolour - 1) / 2) {
baseOffDiagonal(a[Index][0], a[Index][1], eij, group_name());
} else {
baseDiagonal(Index, eij);
}
}
private:
template <class cplx>
static void baseDiagonal(int Index, iGroupMatrix<cplx> &eij) {
eij = Zero();
eij()()(Index - ncolour * (ncolour - 1) / 2,
Index - ncolour * (ncolour - 1) / 2) = 1.0;
}
template <class cplx>
static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij,
GroupName::Sp) {
eij = Zero();
RealD tmp;
if ((i == ngroup + j) && (1 <= j) && (j < ngroup)) {
for (int k = 0; k < ngroup; k++) {
if (k < j) {
tmp = sqrt(2 * j * (j + 1));
tmp = 1 / tmp;
tmp *= std::sqrt(2.0);
eij()()(k, k + ngroup) = tmp;
eij()()(k + ngroup, k) = -tmp;
}
if (k == j) {
tmp = sqrt(2 * j * (j + 1));
tmp = -j / tmp;
tmp *= std::sqrt(2.0);
eij()()(k, k + ngroup) = tmp;
eij()()(k + ngroup, k) = -tmp;
}
}
}
else if (i != ngroup + j) {
for (int k = 0; k < ncolour; k++)
for (int l = 0; l < ncolour; l++) {
eij()()(l, k) =
delta(i, k) * delta(j, l) + S * delta(j, k) * delta(i, l);
}
}
RealD nrm = 1. / std::sqrt(2.0);
eij = eij * nrm;
}
template <class cplx>
static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij,
GroupName::SU) {
static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij, GroupName::SU) {
eij = Zero();
for (int k = 0; k < ncolour; k++)
for (int l = 0; l < ncolour; l++)
@ -175,7 +159,48 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
RealD nrm = 1. / std::sqrt(2.0);
eij = eij * nrm;
}
template <class cplx>
static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij, GroupName::Sp) {
detail::baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(i, j, eij);
}
public:
template <class cplx>
static void base(int Index, iGroupMatrix<cplx> &eij) {
// returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
assert(Index < Dimension);
eij = Zero();
// for the linearisation of the 2 indexes
static int a[ncolour * (ncolour - 1) / 2][2]; // store the a <-> i,j
static bool filled = false;
if (!filled) {
int counter = 0;
for (int i = 1; i < ncolour; i++) {
for (int j = 0; j < i; j++) {
if (std::is_same<group_name, GroupName::Sp>::value)
{
if (j==0 && i==ngroup+j && S==-1) {
//std::cout << "skipping" << std::endl; // for Sp2n this vanishes identically.
j = j+1;
}
}
a[counter][0] = i;
a[counter][1] = j;
counter++;
}
}
filled = true;
}
if (Index < ncolour*ncolour - DimensionS)
{
baseOffDiagonal(a[Index][0], a[Index][1], eij, group_name());
} else {
baseDiagonal(Index, eij);
}
}
static void printBase(void) {
for (int gen = 0; gen < Dimension; gen++) {
Matrix tmp;

View File

@ -307,7 +307,7 @@ int main(int argc, char** argv) {
std::cout << GridLogMessage << "Two index Symmetric: Checking Group Structure"
<< std::endl;
// Testing HMC representation classes
TwoIndexRep< Nc, Symmetric > TIndexRep(grid);
TwoIndexRep< Nc, Symmetric> TIndexRep(grid);
// Test group structure
// (U_f * V_f)_r = U_r * V_r
@ -324,23 +324,23 @@ int main(int argc, char** argv) {
}
TIndexRep.update_representation(UV2);
typename TwoIndexRep< Nc, Symmetric >::LatticeField UVr2 = TIndexRep.U; // (U_f * V_f)_r
typename TwoIndexRep< Nc, Symmetric>::LatticeField UVr2 = TIndexRep.U; // (U_f * V_f)_r
TIndexRep.update_representation(U2);
typename TwoIndexRep< Nc, Symmetric >::LatticeField Ur2 = TIndexRep.U; // U_r
typename TwoIndexRep< Nc, Symmetric>::LatticeField Ur2 = TIndexRep.U; // U_r
TIndexRep.update_representation(V2);
typename TwoIndexRep< Nc, Symmetric >::LatticeField Vr2 = TIndexRep.U; // V_r
typename TwoIndexRep< Nc, Symmetric>::LatticeField Vr2 = TIndexRep.U; // V_r
typename TwoIndexRep< Nc, Symmetric >::LatticeField Ur2Vr2(grid);
typename TwoIndexRep< Nc, Symmetric>::LatticeField Ur2Vr2(grid);
Ur2Vr2 = Zero();
for (int mu = 0; mu < Nd; mu++) {
typename TwoIndexRep< Nc, Symmetric >::LatticeMatrix Urmu2 = peekLorentz(Ur2,mu);
typename TwoIndexRep< Nc, Symmetric >::LatticeMatrix Vrmu2 = peekLorentz(Vr2,mu);
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Urmu2 = peekLorentz(Ur2,mu);
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Vrmu2 = peekLorentz(Vr2,mu);
pokeLorentz(Ur2Vr2,Urmu2*Vrmu2, mu);
}
typename TwoIndexRep< Nc, Symmetric >::LatticeField Diff_check2 = UVr2 - Ur2Vr2;
typename TwoIndexRep< Nc, Symmetric>::LatticeField Diff_check2 = UVr2 - Ur2Vr2;
std::cout << GridLogMessage << "Group structure SU("<<Nc<<") check difference (Two Index Symmetric): " << norm2(Diff_check2) << std::endl;
@ -407,7 +407,7 @@ int main(int argc, char** argv) {
if (TwoIndexRep<Nc, AntiSymmetric >::Dimension != 1){
if (TwoIndexRep<Nc, AntiSymmetric>::Dimension != 1){
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
@ -416,7 +416,7 @@ int main(int argc, char** argv) {
std::cout << GridLogMessage << "Two Index anti-Symmetric: Check Group Structure"
<< std::endl;
// Testing HMC representation classes
TwoIndexRep< Nc, AntiSymmetric > TIndexRepA(grid);
TwoIndexRep< Nc, AntiSymmetric> TIndexRepA(grid);
// Test group structure
@ -434,23 +434,23 @@ int main(int argc, char** argv) {
}
TIndexRep.update_representation(UV2A);
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeField UVr2A = TIndexRepA.U; // (U_f * V_f)_r
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField UVr2A = TIndexRepA.U; // (U_f * V_f)_r
TIndexRep.update_representation(U2A);
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeField Ur2A = TIndexRepA.U; // U_r
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Ur2A = TIndexRepA.U; // U_r
TIndexRep.update_representation(V2A);
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeField Vr2A = TIndexRepA.U; // V_r
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Vr2A = TIndexRepA.U; // V_r
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeField Ur2Vr2A(grid);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Ur2Vr2A(grid);
Ur2Vr2A = Zero();
for (int mu = 0; mu < Nd; mu++) {
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeMatrix Urmu2A = peekLorentz(Ur2A,mu);
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeMatrix Vrmu2A = peekLorentz(Vr2A,mu);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Urmu2A = peekLorentz(Ur2A,mu);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Vrmu2A = peekLorentz(Vr2A,mu);
pokeLorentz(Ur2Vr2A,Urmu2A*Vrmu2A, mu);
}
typename TwoIndexRep< Nc, AntiSymmetric >::LatticeField Diff_check2A = UVr2A - Ur2Vr2A;
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Diff_check2A = UVr2A - Ur2Vr2A;
std::cout << GridLogMessage << "Group structure SU("<<Nc<<") check difference (Two Index anti-Symmetric): " << norm2(Diff_check2A) << std::endl;

View File

@ -4,107 +4,138 @@
using namespace Grid;
int main(int argc, char** argv) {
Grid_init(&argc, &argv);
template<int this_nc>
static void check_dimensions() {
const int this_n = this_nc/2;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
RealD realA;
std::cout << GridLogMessage << "Nc = " << this_n << " 2as dimension is " << Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension << std::endl;
std::cout << GridLogMessage << "Nc = " << this_n << " 2s dimension is " << Sp_TwoIndex<this_nc, Symmetric>::Dimension << std::endl;
std::cout << GridLogMessage << "Nc = " << this_n << " algebra dimension is " << this_algebra_dim << std::endl;
realA = Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension + Sp_TwoIndex<this_nc, Symmetric>::Dimension;
std::cout << GridLogMessage << "Checking dim(2AS) + dim(AS) + 1 = Nc * Nc " << this_algebra_dim << std::endl;
assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
}
const int this_nc = 4;
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
typedef Sp_TwoIndex<this_nc, AntiSymmetric>::iGroupMatrix<Complex> Matrix;
typedef Sp_TwoIndex<this_nc, AntiSymmetric>::iGroupTwoIndexMatrix<Complex> ASMatrix;
Matrix Omega;
Matrix eij_a;
Matrix eij_b;
Matrix eij_c;
Matrix e_sum;
Omega = Zero();
for (int i = 0; i < this_n; i++)
{
Omega()()(i, this_n + i) = 1.;
Omega()()(this_n + i, i) = -1;
}
std::cout << "Omega " << Omega << std::endl;
template<int this_nc, TwoIndexSymmetry S>
static void S_checks() {
std::cout << S << std::endl;
std::cout << 1 + S * 3 << std::endl;
}
template<int this_nc, TwoIndexSymmetry S>
static void run_base_checks() {
std::cout << GridLogMessage << " ****** " << std::endl;
std::cout << GridLogMessage << "Running checks for Nc = " << this_nc << " TwoIndex Symmetry = " << S << std::endl;
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, S>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupMatrix<Complex> Matrix;
typedef typename Sp_TwoIndex<this_nc, S>::template iGroupTwoIndexMatrix<Complex> ASMatrix;
RealD realS = S;
Matrix Omega;
Matrix eij_a;
Matrix eij_b;
Matrix eij_c;
Matrix e_sum;
Omega = Zero();
for (int i = 0; i < this_n; i++)
{
Omega()()(i, this_n + i) = 1.;
Omega()()(this_n + i, i) = -1;
}
RealD realA;
RealD realB;
std::cout << GridLogMessage << "2as dimension is " << this_irrep_dim << std::endl;
std::cout << GridLogMessage << "algebra dimension is " << this_algebra_dim << std::endl;
realA = Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension + Sp_TwoIndex<this_nc, Symmetric>::Dimension;
realB = Sp<this_nc>::Dimension*Sp<this_nc>::Dimension;
assert ( realA == realB);
RealD realA;
RealD realB;
std::cout << GridLogMessage << "checking base is antisymmetric " << std::endl;
for (int a=0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, AntiSymmetric>::base(a, eij_c);
e_sum = eij_c + transpose(eij_c);
std::cout << GridLogMessage << "e_ab + e_ab^T " << norm2(e_sum) << std::endl;
assert(norm2(e_sum) < 1e-8);
}
std::cout << GridLogMessage << "Checking Tr (e^(ab) Omega ) = 0 and Tr (e^(ab) e^(cd) = delta^((ab)(cd)) ) " << std::endl;
for (int a=0; a < Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension; a++) {
Sp_TwoIndex<this_nc, AntiSymmetric>::base(a, eij_a);
realA = norm2(trace(Omega*eij_a));
std::cout << GridLogMessage << "Omega trace for (ab) = " << a << std::endl;
assert(realA == 0);
for (int b=0; b < Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension; b++) {
Sp_TwoIndex<this_nc, AntiSymmetric>::base(b, eij_b);
auto d_ab = TensorRemove(trace(eij_a * eij_b));
#if verbose
std::cout << GridLogMessage << "Tr( e_{ab=" << a << "} e_{cd=" << b << "} ) = " << d_ab << std::endl;
#endif
std::cout << GridLogMessage << "Orthonormality for (ab) = " << a << std::endl;
if (a==b) {
assert(real(d_ab)+1 < 1e-8);
assert(imag(d_ab) < 1e-8);
} else {
assert(real(d_ab) < 1e-8);
assert(imag(d_ab) < 1e-8);
std::cout << GridLogMessage << "checking base has symmetry " << S << std::endl;
for (int a=0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, S>::base(a, eij_c);
e_sum = eij_c - realS * transpose(eij_c);
std::cout << GridLogMessage << "e_ab - (" << S << " * e_ab^T ) = " << norm2(e_sum) << std::endl;
assert(norm2(e_sum) < 1e-8);
}
std::cout << GridLogMessage << "Checking Tr (e^(ab) Omega ) = 0 and Tr (e^(ab) e^(cd) = delta^((ab)(cd)) ) " << std::endl;
for (int a=0; a < Sp_TwoIndex<this_nc, S>::Dimension; a++) {
Sp_TwoIndex<this_nc, S>::base(a, eij_a);
realA = norm2(trace(Omega*eij_a));
std::cout << GridLogMessage << "Checkig Omega-trace for e_{ab=" << a << "} " << std::endl;
//std::cout << GridLogMessage << "Tr ( Omega e_{ab=" << a << "} ) = " << realA << std::endl;
assert(realA < 1e-8);
for (int b=0; b < Sp_TwoIndex<this_nc, S>::Dimension; b++) {
Sp_TwoIndex<this_nc, S>::base(b, eij_b);
auto d_ab = TensorRemove(trace(eij_a * eij_b));
#if verbose
std::cout << GridLogMessage << "Tr( e_{ab=" << a << "} e_{cd=" << b << "} ) = " << d_ab << std::endl;
#endif
std::cout << GridLogMessage << "Checking orthonormality for e_{ab = " << a << "} " << std::endl;
if (a==b) {
assert(real(d_ab) - realS < 1e-8);
assert(imag(d_ab) < 1e-8);
} else {
assert(real(d_ab) < 1e-8);
assert(imag(d_ab) < 1e-8);
}
}
}
}
int sum = 0;
int sum_im = 0;
Vector<Matrix> ta_fund(this_algebra_dim);
Vector<Matrix> eij(this_irrep_dim);
Matrix tmp_l;
Matrix tmp_r;
for (int n = 0; n < this_algebra_dim; n++)
{
Sp<this_nc>::generator(n, ta_fund[n]);
}
for (int a = 0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, AntiSymmetric>::base(a, eij[a]);
}
for (int gen_id = 0; gen_id < this_algebra_dim; gen_id++)
{
Complex iTr;
sum = 0;
sum_im = 0;
std::cout << GridLogMessage << "generator number " << gen_id << std::endl;
int sum = 0;
int sum_im = 0;
Vector<Matrix> ta_fund(this_algebra_dim);
Vector<Matrix> eij(this_irrep_dim);
Matrix tmp_l;
Matrix tmp_r;
for (int n = 0; n < this_algebra_dim; n++)
{
Sp<this_nc>::generator(n, ta_fund[n]);
}
for (int a = 0; a < this_irrep_dim; a++)
{
tmp_l = adj(eij[a])*ta_fund[gen_id]*eij[a];
tmp_r = adj(eij[a])*eij[a]*transpose(ta_fund[gen_id]);
#if verbose
std::cout << GridLogMessage << " as_indx = " << a << " eDag T_F e = " << std::endl << tmp_l << std::endl;
std::cout << GridLogMessage << " as_indx = " << a << " eDag e T_F^T = " << std::endl << tmp_r << std::endl;
#endif
std::cout << GridLogMessage << " as_indx = " << a << " Tr(sum) = " << TensorRemove(trace(tmp_l+tmp_r)) << std::endl;
sum += real(TensorRemove(trace(tmp_l+tmp_r)));
sum_im += imag(TensorRemove(trace(tmp_l+tmp_r)));
Sp_TwoIndex<this_nc, S>::base(a, eij[a]);
}
for (int gen_id = 0; gen_id < this_algebra_dim; gen_id++)
{
Complex iTr;
sum = 0;
sum_im = 0;
std::cout << GridLogMessage << "generator number " << gen_id << std::endl;
for (int a = 0; a < this_irrep_dim; a++)
{
tmp_l = adj(eij[a])*ta_fund[gen_id]*eij[a];
tmp_r = adj(eij[a])*eij[a]*transpose(ta_fund[gen_id]);
#if verbose
std::cout << GridLogMessage << " as_indx = " << a << " eDag T_F e = " << std::endl << tmp_l << std::endl;
std::cout << GridLogMessage << " as_indx = " << a << " eDag e T_F^T = " << std::endl << tmp_r << std::endl;
#endif
//std::cout << GridLogMessage << " as_indx = " << a << " Tr(eDag T_F e + eDag e T_F^T) = " << TensorRemove(trace(tmp_l+tmp_r)) << std::endl;
sum += real(TensorRemove(trace(tmp_l+tmp_r)));
sum_im += imag(TensorRemove(trace(tmp_l+tmp_r)));
}
std::cout << GridLogMessage << "re-evaluated trace of the generator " << gen_id << " is " << sum << " " << sum_im << std::endl;
assert ( sum < 1e-8) ;
assert ( sum_im < 1e-8) ;
}
std::cout << GridLogMessage << "re-evaluated trace of the generator " << gen_id << " is " << sum << " " << sum_im << std::endl;
assert ( sum < 1e-8) ;
assert ( sum_im < 1e-8) ;
}
Grid_finalize();
}
int main(int argc, char** argv) {
check_dimensions<2>();
check_dimensions<4>();
check_dimensions<6>();
check_dimensions<8>();
run_base_checks<2, Symmetric>();
run_base_checks<4, Symmetric>();
run_base_checks<4, AntiSymmetric>();
run_base_checks<6, Symmetric>();
run_base_checks<6, AntiSymmetric>();
run_base_checks<8, Symmetric>();
run_base_checks<8, AntiSymmetric>();
}

View File

@ -2,66 +2,52 @@
using namespace Grid;
template<int ncolour>
void run_checks(bool print_generators = 0) {
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(" << ncolour << ")" << "Fundamental" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
if (print_generators)
{
Sp<ncolour>::printGenerators();
}
Sp<ncolour>::testGenerators();
if (Sp_TwoIndex<ncolour, Symmetric>::Dimension > 1) {
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(" << ncolour << ")" << "TwoIndex Symmetric: " << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
if (print_generators) {
Sp_TwoIndex<ncolour, Symmetric>::printGenerators();
}
Sp_TwoIndex<ncolour, Symmetric>::testGenerators();
}
if (Sp_TwoIndex<ncolour, AntiSymmetric>::Dimension > 1) {
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(" << ncolour << ")" << "TwoIndex AntiSymmetric: " << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
if (print_generators) {
Sp_TwoIndex<ncolour, AntiSymmetric>::printGenerators();
}
Sp_TwoIndex<ncolour, AntiSymmetric>::testGenerators();
}
}
int main(int argc, char** argv) {
Grid_init(&argc, &argv);
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(2) (print and test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp2::printGenerators();
Sp2::testGenerators();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(4) (print and test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp4::printGenerators();
Sp4::testGenerators();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(6) (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp6::testGenerators();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(8) (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp8::testGenerators();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(4) TwoIndexAS (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<4, AntiSymmetric>::testGenerators();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(6) TwoIndexAS (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<6, AntiSymmetric>::testGenerators();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(8) TwoIndexAS (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<8, AntiSymmetric>::testGenerators();
run_checks<2>(1); // check and print Nc=2
run_checks<4>(1); // check and print Nc=4
run_checks<6>(); // check Nc=6
run_checks<8>(); // check Nc=8
Grid_finalize();
}