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

cleaner twoindex class, cleaner tests

This commit is contained in:
Alessandro Lupo 2023-05-26 16:55:30 +01:00
parent e61a9ed2b4
commit fe88a0c12f
4 changed files with 216 additions and 375 deletions

View File

@ -31,23 +31,7 @@ enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
template <int nc, TwoIndexSymmetry S, class group_name>
struct DimensionHelper;
template <int nc, TwoIndexSymmetry S>
struct DimensionHelper<nc, S, GroupName::SU> {
static const int Dimension = nc * (nc + S) / 2;
};
template <int nc>
struct DimensionHelper<nc, Symmetric, GroupName::Sp> {
static const int Dimension = nc * (nc + 1) / 2;
};
template <int nc>
struct DimensionHelper<nc, AntiSymmetric, GroupName::Sp> {
static const int Dimension = (nc / 2) * (nc - 1) - 1;
};
namespace detail {
template <class cplx, int nc, TwoIndexSymmetry S>
struct baseOffDiagonalSpHelper;
@ -106,6 +90,8 @@ struct baseOffDiagonalSpHelper<cplx, nc, Symmetric> {
}
};
} // closing detail namespace
template <int ncolour, TwoIndexSymmetry S, class group_name>
class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
public:
@ -117,7 +103,11 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
static const int ngroup =
std::is_same<group_name, GroupName::SU>::value ? ncolour : ncolour / 2;
static const int Dimension =
DimensionHelper<ncolour, S, group_name>::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;
@ -149,43 +139,9 @@ 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) {
// returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
base(Index, eij, group_name());
}
template <class cplx>
static void base(int Index, iGroupMatrix<cplx> &eij, GroupName::SU) {
// 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;
a[counter][1] = j;
counter++;
}
}
filled = true;
}
if (Index < ncolour * (ncolour - 1) / 2) {
baseOffDiagonal(a[Index][0], a[Index][1], eij);
} else {
baseDiagonal(Index, eij);
}
}
template <class cplx>
static void base(int Index, iGroupMatrix<cplx> &eij, GroupName::Sp) {
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();
@ -197,24 +153,27 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
int counter = 0;
for (int i = 1; i < ncolour; i++) {
for (int j = 0; j < i; j++) {
a[counter][0] = i;
if (j==0 && i==ngroup+j && S==-1) {
//std::cout << "skipping" << std::endl; // for Sp2n this vanishes identically.
j = j+1;
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 < DimensionHelper<ncolour, AntiSymmetric, GroupName::Sp>::Dimension + 1) { // +1 the singlet
baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(a[Index][0], a[Index][1], eij);
if (Index < ncolour*ncolour - DimensionS)
{
baseOffDiagonal(a[Index][0], a[Index][1], eij, group_name());
} else {
baseDiagonal(Index, eij);
baseDiagonal(Index, eij);
}
}
}
template <class cplx>
static void baseDiagonal(int Index, iGroupMatrix<cplx> &eij) {
@ -224,7 +183,7 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
}
template <class cplx>
static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij) {
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++)
@ -236,8 +195,8 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
}
template <class cplx>
static void baseOffDiagonalSp(int i, int j, iGroupMatrix<cplx> &eij) {
baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(i, j, eij);
static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij, GroupName::Sp) {
detail::baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(i, j, eij);
}
static void printBase(void) {

View File

@ -324,30 +324,30 @@ int main(int argc, char** argv) {
}
TIndexRep.update_representation(UV2);
typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::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, GroupName::SU >::LatticeField Ur2 = TIndexRep.U; // U_r
typename TwoIndexRep< Nc, Symmetric>::LatticeField Ur2 = TIndexRep.U; // U_r
TIndexRep.update_representation(V2);
typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::LatticeField Vr2 = TIndexRep.U; // V_r
typename TwoIndexRep< Nc, Symmetric>::LatticeField Vr2 = TIndexRep.U; // V_r
typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::LatticeField Ur2Vr2(grid);
typename TwoIndexRep< Nc, Symmetric>::LatticeField Ur2Vr2(grid);
Ur2Vr2 = Zero();
for (int mu = 0; mu < Nd; mu++) {
typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::LatticeMatrix Urmu2 = peekLorentz(Ur2,mu);
typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::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, GroupName::SU >::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;
// Check correspondence of algebra and group transformations
// Create a random vector
SU<Nc>::LatticeAlgebraVector h_sym(grid);
typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix Ar_sym(grid);
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Ar_sym(grid);
random(gridRNG,h_sym);
h_sym = real(h_sym);
SU_TwoIndex<Nc,Symmetric>::TwoIndexLieAlgebraMatrix(h_sym,Ar_sym);
@ -360,13 +360,13 @@ int main(int argc, char** argv) {
// Exponentiate
typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix U2iS(grid);
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix U2iS(grid);
U2iS = expMat(Ar_sym, 1.0, 16);
typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix uno2iS(grid);
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix uno2iS(grid);
uno2iS = 1.0;
// Check matrix U2iS, must be real orthogonal
typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix Ucheck2iS = U2iS - conjugate(U2iS);
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Ucheck2iS = U2iS - conjugate(U2iS);
std::cout << GridLogMessage << "Reality check: " << norm2(Ucheck2iS)
<< std::endl;
@ -399,15 +399,15 @@ int main(int argc, char** argv) {
TIndexRep.update_representation(U);
Ur2 = TIndexRep.U; // U_r
typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix Ur02 = peekLorentz(Ur2,0); // this should be the same as U2iS
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Ur02 = peekLorentz(Ur2,0); // this should be the same as U2iS
typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix Diff_check_mat2 = Ur02 - U2iS;
typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Diff_check_mat2 = Ur02 - U2iS;
std::cout << GridLogMessage << "Projections structure check group difference (Two Index Symmetric): " << norm2(Diff_check_mat2) << std::endl;
if (TwoIndexRep<Nc, AntiSymmetric , GroupName::SU>::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, GroupName::SU > TIndexRepA(grid);
TwoIndexRep< Nc, AntiSymmetric> TIndexRepA(grid);
// Test group structure
@ -434,30 +434,30 @@ int main(int argc, char** argv) {
}
TIndexRep.update_representation(UV2A);
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::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, GroupName::SU >::LatticeField Ur2A = TIndexRepA.U; // U_r
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Ur2A = TIndexRepA.U; // U_r
TIndexRep.update_representation(V2A);
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::LatticeField Vr2A = TIndexRepA.U; // V_r
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Vr2A = TIndexRepA.U; // V_r
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::LatticeField Ur2Vr2A(grid);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeField Ur2Vr2A(grid);
Ur2Vr2A = Zero();
for (int mu = 0; mu < Nd; mu++) {
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::LatticeMatrix Urmu2A = peekLorentz(Ur2A,mu);
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::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, GroupName::SU >::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;
// Check correspondence of algebra and group transformations
// Create a random vector
SU<Nc>::LatticeAlgebraVector h_Asym(grid);
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix Ar_Asym(grid);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Ar_Asym(grid);
random(gridRNG,h_Asym);
h_Asym = real(h_Asym);
SU_TwoIndex< Nc, AntiSymmetric>::TwoIndexLieAlgebraMatrix(h_Asym,Ar_Asym);
@ -470,13 +470,13 @@ int main(int argc, char** argv) {
// Exponentiate
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix U2iAS(grid);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix U2iAS(grid);
U2iAS = expMat(Ar_Asym, 1.0, 16);
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix uno2iAS(grid);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix uno2iAS(grid);
uno2iAS = 1.0;
// Check matrix U2iS, must be real orthogonal
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix Ucheck2iAS = U2iAS - conjugate(U2iAS);
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Ucheck2iAS = U2iAS - conjugate(U2iAS);
std::cout << GridLogMessage << "Reality check: " << norm2(Ucheck2iAS)
<< std::endl;
@ -509,9 +509,9 @@ int main(int argc, char** argv) {
TIndexRepA.update_representation(U);
Ur2A = TIndexRepA.U; // U_r
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix Ur02A = peekLorentz(Ur2A,0); // this should be the same as U2iS
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Ur02A = peekLorentz(Ur2A,0); // this should be the same as U2iS
typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix Diff_check_mat2A = Ur02A - U2iAS;
typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Diff_check_mat2A = Ur02A - U2iAS;
std::cout << GridLogMessage << "Projections structure check group difference (Two Index anti-Symmetric): " << norm2(Diff_check_mat2A) << std::endl;
} else {

View File

@ -1,212 +1,141 @@
#include <Grid/Grid.h>
#define verbose 1
#define verbose 0
using namespace Grid;
static void antisymm_base() {
const int this_nc = 6;
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;
}
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;
assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
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);
}
}
}
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;
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)));
}
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) ;
}
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)
}
static void symm_base() {
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;
}
const int this_nc = 6;
const int this_n = this_nc/2;
const int this_irrep_dim = Sp_TwoIndex<this_nc, Symmetric>::Dimension;
const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
typedef Sp_TwoIndex<this_nc, Symmetric>::iGroupMatrix<Complex> Matrix;
typedef Sp_TwoIndex<this_nc, Symmetric>::iGroupTwoIndexMatrix<Complex> SMatrix;
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;
RealD realA;
RealD realB;
std::cout << GridLogMessage << "symm 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;
assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
std::cout << GridLogMessage << "checking base is symmetric " << std::endl;
for (int a=0; a < this_irrep_dim; a++)
{
Sp_TwoIndex<this_nc, Symmetric>::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, Symmetric>::Dimension; a++) {
Sp_TwoIndex<this_nc, Symmetric>::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, Symmetric>::Dimension; b++) {
Sp_TwoIndex<this_nc, Symmetric>::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, Symmetric>::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) ;
}
}
int main(int argc, char** argv) {
std::cout << GridLogMessage << "Checking AntiSymmetric base " << std::endl;
antisymm_base();
std::cout << GridLogMessage << "*************** " << std::endl;
std::cout << GridLogMessage << "Checking Symmetric base " << std::endl;
symm_base();
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,99 +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(2) TwoIndexS (print & test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<2, Symmetric>::printGenerators();
Sp_TwoIndex<2, Symmetric>::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(4) TwoIndexS (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<4, Symmetric>::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(6) TwoIndexS (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<6, Symmetric>::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();
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
std::cout << GridLogMessage << "* Generators for Sp(8) TwoIndexS (test)" << std::endl;
std::cout << GridLogMessage << "*********************************************"
<< std::endl;
Sp_TwoIndex<8, Symmetric>::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();
}