mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	cleaner twoindex class, cleaner tests
This commit is contained in:
		@@ -31,23 +31,7 @@ enum TwoIndexSymmetry { Symmetric = 1, AntiSymmetric = -1 };
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
 | 
					inline Real delta(int a, int b) { return (a == b) ? 1.0 : 0.0; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <int nc, TwoIndexSymmetry S, class group_name>
 | 
					namespace detail {
 | 
				
			||||||
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;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <class cplx, int nc, TwoIndexSymmetry S>
 | 
					template <class cplx, int nc, TwoIndexSymmetry S>
 | 
				
			||||||
struct baseOffDiagonalSpHelper;
 | 
					struct baseOffDiagonalSpHelper;
 | 
				
			||||||
@@ -106,6 +90,8 @@ struct baseOffDiagonalSpHelper<cplx, nc, Symmetric> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}   // closing detail namespace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <int ncolour, TwoIndexSymmetry S, class group_name>
 | 
					template <int ncolour, TwoIndexSymmetry S, class group_name>
 | 
				
			||||||
class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
					class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
				
			||||||
 public:
 | 
					 public:
 | 
				
			||||||
@@ -117,7 +103,11 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
				
			|||||||
  static const int ngroup =
 | 
					  static const int ngroup =
 | 
				
			||||||
      std::is_same<group_name, GroupName::SU>::value ? ncolour : ncolour / 2;
 | 
					      std::is_same<group_name, GroupName::SU>::value ? ncolour : ncolour / 2;
 | 
				
			||||||
  static const int Dimension =
 | 
					  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 =
 | 
					  static const int NumGenerators =
 | 
				
			||||||
      GaugeGroup<ncolour, group_name>::AlgebraDimension;
 | 
					      GaugeGroup<ncolour, group_name>::AlgebraDimension;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -149,43 +139,9 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
				
			|||||||
  typedef iGroupMatrix<Complex> Matrix;
 | 
					  typedef iGroupMatrix<Complex> Matrix;
 | 
				
			||||||
  typedef iGroupMatrix<ComplexF> MatrixF;
 | 
					  typedef iGroupMatrix<ComplexF> MatrixF;
 | 
				
			||||||
  typedef iGroupMatrix<ComplexD> MatrixD;
 | 
					  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>
 | 
					  template <class cplx>
 | 
				
			||||||
  static void base(int Index, iGroupMatrix<cplx> &eij, GroupName::SU) {
 | 
					   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++) {
 | 
					 | 
				
			||||||
          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) {
 | 
					 | 
				
			||||||
     // returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
 | 
					     // returns (e)^(ij)_{kl} necessary for change of base U_F -> U_R
 | 
				
			||||||
     assert(Index < Dimension);
 | 
					     assert(Index < Dimension);
 | 
				
			||||||
     eij = Zero();
 | 
					     eij = Zero();
 | 
				
			||||||
@@ -197,24 +153,27 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
				
			|||||||
       int counter = 0;
 | 
					       int counter = 0;
 | 
				
			||||||
       for (int i = 1; i < ncolour; i++) {
 | 
					       for (int i = 1; i < ncolour; i++) {
 | 
				
			||||||
         for (int j = 0; j < i; j++) {
 | 
					         for (int j = 0; j < i; j++) {
 | 
				
			||||||
           a[counter][0] = i;
 | 
					             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.
 | 
					               if (j==0 && i==ngroup+j && S==-1) {
 | 
				
			||||||
                 j = j+1;
 | 
					                   //std::cout << "skipping" << std::endl; // for Sp2n this vanishes identically.
 | 
				
			||||||
 | 
					                   j = j+1;
 | 
				
			||||||
 | 
					               }
 | 
				
			||||||
             }
 | 
					             }
 | 
				
			||||||
 | 
					           a[counter][0] = i;
 | 
				
			||||||
           a[counter][1] = j;
 | 
					           a[counter][1] = j;
 | 
				
			||||||
           counter++;
 | 
					           counter++;
 | 
				
			||||||
         }
 | 
					         }
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
       filled = true;
 | 
					       filled = true;
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
 | 
					     if (Index < ncolour*ncolour - DimensionS)
 | 
				
			||||||
     if (Index < DimensionHelper<ncolour, AntiSymmetric, GroupName::Sp>::Dimension + 1) {   // +1 the singlet
 | 
					     {
 | 
				
			||||||
       baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(a[Index][0], a[Index][1], eij);
 | 
					         baseOffDiagonal(a[Index][0], a[Index][1], eij, group_name());
 | 
				
			||||||
     } else {
 | 
					     } else {
 | 
				
			||||||
       baseDiagonal(Index, eij);
 | 
					         baseDiagonal(Index, eij);
 | 
				
			||||||
 | 
					       }
 | 
				
			||||||
     }
 | 
					     }
 | 
				
			||||||
   }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  template <class cplx>
 | 
					  template <class cplx>
 | 
				
			||||||
  static void baseDiagonal(int Index, iGroupMatrix<cplx> &eij) {
 | 
					  static void baseDiagonal(int Index, iGroupMatrix<cplx> &eij) {
 | 
				
			||||||
@@ -224,7 +183,7 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  template <class cplx>
 | 
					  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();
 | 
					    eij = Zero();
 | 
				
			||||||
    for (int k = 0; k < ncolour; k++)
 | 
					    for (int k = 0; k < ncolour; k++)
 | 
				
			||||||
      for (int l = 0; l < ncolour; l++)
 | 
					      for (int l = 0; l < ncolour; l++)
 | 
				
			||||||
@@ -236,8 +195,8 @@ class GaugeGroupTwoIndex : public GaugeGroup<ncolour, group_name> {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  template <class cplx>
 | 
					  template <class cplx>
 | 
				
			||||||
  static void baseOffDiagonalSp(int i, int j, iGroupMatrix<cplx> &eij) {
 | 
					  static void baseOffDiagonal(int i, int j, iGroupMatrix<cplx> &eij, GroupName::Sp) {
 | 
				
			||||||
  baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(i, j, eij);
 | 
					    detail::baseOffDiagonalSpHelper<cplx, ncolour, S>::baseOffDiagonalSp(i, j, eij);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static void printBase(void) {
 | 
					  static void printBase(void) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -324,30 +324,30 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  TIndexRep.update_representation(UV2);
 | 
					  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);
 | 
					  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);
 | 
					  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();
 | 
					  Ur2Vr2 = Zero();
 | 
				
			||||||
  for (int mu = 0; mu < Nd; mu++) {
 | 
					  for (int mu = 0; mu < Nd; mu++) {
 | 
				
			||||||
    typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::LatticeMatrix Urmu2 = peekLorentz(Ur2,mu);
 | 
					    typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Urmu2 = peekLorentz(Ur2,mu);
 | 
				
			||||||
    typename TwoIndexRep< Nc, Symmetric, GroupName::SU >::LatticeMatrix Vrmu2 = peekLorentz(Vr2,mu);
 | 
					    typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix Vrmu2 = peekLorentz(Vr2,mu);
 | 
				
			||||||
    pokeLorentz(Ur2Vr2,Urmu2*Vrmu2, 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;
 | 
					  std::cout << GridLogMessage << "Group structure SU("<<Nc<<") check difference (Two Index Symmetric): " << norm2(Diff_check2) << std::endl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Check correspondence of algebra and group transformations
 | 
					  // Check correspondence of algebra and group transformations
 | 
				
			||||||
  // Create a random vector
 | 
					  // Create a random vector
 | 
				
			||||||
  SU<Nc>::LatticeAlgebraVector h_sym(grid);
 | 
					  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);
 | 
					  random(gridRNG,h_sym);
 | 
				
			||||||
  h_sym = real(h_sym);
 | 
					  h_sym = real(h_sym);
 | 
				
			||||||
  SU_TwoIndex<Nc,Symmetric>::TwoIndexLieAlgebraMatrix(h_sym,Ar_sym);
 | 
					  SU_TwoIndex<Nc,Symmetric>::TwoIndexLieAlgebraMatrix(h_sym,Ar_sym);
 | 
				
			||||||
@@ -360,13 +360,13 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Exponentiate
 | 
					  // Exponentiate
 | 
				
			||||||
  typename TwoIndexRep< Nc, Symmetric, GroupName::SU>::LatticeMatrix U2iS(grid);
 | 
					  typename TwoIndexRep< Nc, Symmetric>::LatticeMatrix U2iS(grid);
 | 
				
			||||||
  U2iS  = expMat(Ar_sym, 1.0, 16);
 | 
					  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;
 | 
					  uno2iS = 1.0;
 | 
				
			||||||
  // Check matrix U2iS, must be real orthogonal
 | 
					  // 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::cout << GridLogMessage << "Reality check: " << norm2(Ucheck2iS)
 | 
				
			||||||
      << std::endl;
 | 
					      << std::endl;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -399,15 +399,15 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  TIndexRep.update_representation(U);
 | 
					  TIndexRep.update_representation(U);
 | 
				
			||||||
  Ur2 = TIndexRep.U;  // U_r  
 | 
					  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;
 | 
					  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::cout << GridLogMessage << "*********************************************"
 | 
				
			||||||
      << std::endl;
 | 
					      << std::endl;
 | 
				
			||||||
@@ -416,7 +416,7 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  std::cout << GridLogMessage << "Two Index anti-Symmetric: Check Group Structure"
 | 
					  std::cout << GridLogMessage << "Two Index anti-Symmetric: Check Group Structure"
 | 
				
			||||||
      << std::endl;
 | 
					      << std::endl;
 | 
				
			||||||
  // Testing HMC representation classes
 | 
					  // Testing HMC representation classes
 | 
				
			||||||
  TwoIndexRep< Nc, AntiSymmetric, GroupName::SU > TIndexRepA(grid);
 | 
					  TwoIndexRep< Nc, AntiSymmetric> TIndexRepA(grid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Test group structure
 | 
					  // Test group structure
 | 
				
			||||||
@@ -434,30 +434,30 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  TIndexRep.update_representation(UV2A);
 | 
					  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);
 | 
					  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);
 | 
					  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();
 | 
					  Ur2Vr2A = Zero();
 | 
				
			||||||
  for (int mu = 0; mu < Nd; mu++) {
 | 
					  for (int mu = 0; mu < Nd; mu++) {
 | 
				
			||||||
    typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::LatticeMatrix Urmu2A = peekLorentz(Ur2A,mu);
 | 
					    typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Urmu2A = peekLorentz(Ur2A,mu);
 | 
				
			||||||
    typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU >::LatticeMatrix Vrmu2A = peekLorentz(Vr2A,mu);
 | 
					    typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix Vrmu2A = peekLorentz(Vr2A,mu);
 | 
				
			||||||
    pokeLorentz(Ur2Vr2A,Urmu2A*Vrmu2A, 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;
 | 
					  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
 | 
					  // Check correspondence of algebra and group transformations
 | 
				
			||||||
  // Create a random vector
 | 
					  // Create a random vector
 | 
				
			||||||
  SU<Nc>::LatticeAlgebraVector h_Asym(grid);
 | 
					  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);
 | 
					  random(gridRNG,h_Asym);
 | 
				
			||||||
  h_Asym = real(h_Asym);
 | 
					  h_Asym = real(h_Asym);
 | 
				
			||||||
  SU_TwoIndex< Nc, AntiSymmetric>::TwoIndexLieAlgebraMatrix(h_Asym,Ar_Asym);
 | 
					  SU_TwoIndex< Nc, AntiSymmetric>::TwoIndexLieAlgebraMatrix(h_Asym,Ar_Asym);
 | 
				
			||||||
@@ -470,13 +470,13 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  // Exponentiate
 | 
					  // Exponentiate
 | 
				
			||||||
  typename TwoIndexRep< Nc, AntiSymmetric, GroupName::SU>::LatticeMatrix U2iAS(grid);
 | 
					  typename TwoIndexRep< Nc, AntiSymmetric>::LatticeMatrix U2iAS(grid);
 | 
				
			||||||
  U2iAS  = expMat(Ar_Asym, 1.0, 16);
 | 
					  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;
 | 
					  uno2iAS = 1.0;
 | 
				
			||||||
  // Check matrix U2iS, must be real orthogonal
 | 
					  // 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::cout << GridLogMessage << "Reality check: " << norm2(Ucheck2iAS)
 | 
				
			||||||
      << std::endl;
 | 
					      << std::endl;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -509,9 +509,9 @@ int main(int argc, char** argv) {
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  TIndexRepA.update_representation(U);
 | 
					  TIndexRepA.update_representation(U);
 | 
				
			||||||
  Ur2A = TIndexRepA.U;  // U_r  
 | 
					  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;
 | 
					  std::cout << GridLogMessage << "Projections structure check group difference (Two Index anti-Symmetric): " << norm2(Diff_check_mat2A) << std::endl;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
} else  {
 | 
					} else  {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,212 +1,141 @@
 | 
				
			|||||||
#include <Grid/Grid.h>
 | 
					#include <Grid/Grid.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define verbose 1
 | 
					#define verbose 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace Grid;
 | 
					using namespace Grid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void antisymm_base() {
 | 
					template<int this_nc>
 | 
				
			||||||
 | 
					static void check_dimensions() {
 | 
				
			||||||
  const int this_nc = 6;
 | 
					    
 | 
				
			||||||
  const int this_n = this_nc/2;
 | 
					    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;
 | 
				
			||||||
  const int this_algebra_dim = Sp<this_nc>::AlgebraDimension;
 | 
					    
 | 
				
			||||||
  typedef Sp_TwoIndex<this_nc, AntiSymmetric>::iGroupMatrix<Complex> Matrix;
 | 
					    RealD realA;
 | 
				
			||||||
  typedef Sp_TwoIndex<this_nc, AntiSymmetric>::iGroupTwoIndexMatrix<Complex> ASMatrix;
 | 
					    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;
 | 
				
			||||||
  Matrix Omega;
 | 
					    std::cout << GridLogMessage << "Nc = " << this_n << " algebra dimension is " << this_algebra_dim << std::endl;
 | 
				
			||||||
  Matrix eij_a;
 | 
					    realA = Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension + Sp_TwoIndex<this_nc, Symmetric>::Dimension;
 | 
				
			||||||
  Matrix eij_b;
 | 
					    std::cout << GridLogMessage << "Checking dim(2AS) + dim(AS) + 1 = Nc * Nc " << this_algebra_dim << std::endl;
 | 
				
			||||||
  Matrix eij_c;
 | 
					    assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
 | 
				
			||||||
  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) ;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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;
 | 
					      RealD realA;
 | 
				
			||||||
  const int this_n = this_nc/2;
 | 
					      RealD realB;
 | 
				
			||||||
  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;
 | 
					      std::cout << GridLogMessage << "checking base has symmetry " << S << std::endl;
 | 
				
			||||||
  RealD realB;
 | 
					      for (int a=0; a < this_irrep_dim; a++)
 | 
				
			||||||
  std::cout << GridLogMessage << "symm dimension is " << this_irrep_dim << std::endl;
 | 
					      {
 | 
				
			||||||
  std::cout << GridLogMessage << "algebra dimension is " << this_algebra_dim << std::endl;
 | 
					          Sp_TwoIndex<this_nc, S>::base(a, eij_c);
 | 
				
			||||||
  realA = Sp_TwoIndex<this_nc, AntiSymmetric>::Dimension + Sp_TwoIndex<this_nc, Symmetric>::Dimension;
 | 
					          e_sum = eij_c - realS * transpose(eij_c);
 | 
				
			||||||
  assert ( realA == this_nc * this_nc - 1); // Nc x Nc = dim(2indxS) + dim(2indxAS) + dim(singlet)
 | 
					          std::cout << GridLogMessage << "e_ab - (" << S << " * e_ab^T ) = " << norm2(e_sum) << std::endl;
 | 
				
			||||||
 | 
					          assert(norm2(e_sum) < 1e-8);
 | 
				
			||||||
  std::cout << GridLogMessage << "checking base is symmetric " << std::endl;
 | 
					            
 | 
				
			||||||
  for (int a=0; a < this_irrep_dim; a++)
 | 
					      }
 | 
				
			||||||
  {
 | 
					      std::cout << GridLogMessage << "Checking Tr (e^(ab) Omega ) = 0 and Tr (e^(ab) e^(cd) = delta^((ab)(cd)) ) " << std::endl;
 | 
				
			||||||
      Sp_TwoIndex<this_nc, Symmetric>::base(a, eij_c);
 | 
					      for (int a=0; a < Sp_TwoIndex<this_nc, S>::Dimension; a++) {
 | 
				
			||||||
      e_sum = eij_c - transpose(eij_c);
 | 
					          Sp_TwoIndex<this_nc, S>::base(a, eij_a);
 | 
				
			||||||
      std::cout << GridLogMessage << "e_ab - e_ab^T " << norm2(e_sum) << std::endl;
 | 
					          realA = norm2(trace(Omega*eij_a));
 | 
				
			||||||
      assert(norm2(e_sum) < 1e-8);
 | 
					          std::cout << GridLogMessage << "Checkig Omega-trace for e_{ab=" << a << "} " << std::endl;
 | 
				
			||||||
  }
 | 
					          //std::cout << GridLogMessage << "Tr ( Omega e_{ab=" << a << "} ) = " << realA << std::endl;
 | 
				
			||||||
  std::cout << GridLogMessage << "Checking Tr (e^(ab) Omega ) = 0 and Tr (e^(ab) e^(cd) = delta^((ab)(cd)) ) " << std::endl;
 | 
					          assert(realA < 1e-8);
 | 
				
			||||||
  for (int a=0; a < Sp_TwoIndex<this_nc, Symmetric>::Dimension; a++) {
 | 
					          for (int b=0; b < Sp_TwoIndex<this_nc, S>::Dimension; b++) {
 | 
				
			||||||
      Sp_TwoIndex<this_nc, Symmetric>::base(a, eij_a);
 | 
					              Sp_TwoIndex<this_nc, S>::base(b, eij_b);
 | 
				
			||||||
      realA = norm2(trace(Omega*eij_a));
 | 
					              auto d_ab = TensorRemove(trace(eij_a * eij_b));
 | 
				
			||||||
      std::cout << GridLogMessage << "Omega trace for (ab) = " << a << std::endl;
 | 
					    #if verbose
 | 
				
			||||||
      assert(realA == 0);
 | 
					              std::cout << GridLogMessage << "Tr( e_{ab=" << a << "} e_{cd=" << b << "} ) = " << d_ab << std::endl;
 | 
				
			||||||
      for (int b=0; b < Sp_TwoIndex<this_nc, Symmetric>::Dimension; b++) {
 | 
					    #endif
 | 
				
			||||||
          Sp_TwoIndex<this_nc, Symmetric>::base(b, eij_b);
 | 
					              std::cout << GridLogMessage << "Checking orthonormality for e_{ab = " << a << "} " << std::endl;
 | 
				
			||||||
          auto d_ab = TensorRemove(trace(eij_a * eij_b));
 | 
					              if (a==b) {
 | 
				
			||||||
#if verbose
 | 
					                  assert(real(d_ab) - realS < 1e-8);
 | 
				
			||||||
          std::cout << GridLogMessage << "Tr( e_{ab=" << a << "} e_{cd=" << b << "} ) = " << d_ab << std::endl;
 | 
					                  assert(imag(d_ab) < 1e-8);
 | 
				
			||||||
#endif
 | 
					              } else {
 | 
				
			||||||
          std::cout << GridLogMessage << "Orthonormality for (ab) = " << a << std::endl;
 | 
					                  assert(real(d_ab) < 1e-8);
 | 
				
			||||||
          if (a==b) {
 | 
					                  assert(imag(d_ab) < 1e-8);
 | 
				
			||||||
              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 = 0;
 | 
				
			||||||
  int sum_im = 0;
 | 
					      int sum_im = 0;
 | 
				
			||||||
  Vector<Matrix> ta_fund(this_algebra_dim);
 | 
					      Vector<Matrix> ta_fund(this_algebra_dim);
 | 
				
			||||||
  Vector<Matrix> eij(this_irrep_dim);
 | 
					      Vector<Matrix> eij(this_irrep_dim);
 | 
				
			||||||
  Matrix tmp_l;
 | 
					      Matrix tmp_l;
 | 
				
			||||||
  Matrix tmp_r;
 | 
					      Matrix tmp_r;
 | 
				
			||||||
  for (int n = 0; n < this_algebra_dim; n++)
 | 
					      for (int n = 0; n < this_algebra_dim; n++)
 | 
				
			||||||
  {
 | 
					      {
 | 
				
			||||||
      Sp<this_nc>::generator(n, ta_fund[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;
 | 
					 | 
				
			||||||
      for (int a = 0; a < this_irrep_dim; a++)
 | 
					      for (int a = 0; a < this_irrep_dim; a++)
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
      
 | 
					          Sp_TwoIndex<this_nc, S>::base(a, eij[a]);
 | 
				
			||||||
          tmp_l = adj(eij[a])*ta_fund[gen_id]*eij[a];
 | 
					      }
 | 
				
			||||||
          tmp_r = adj(eij[a])*eij[a]*transpose(ta_fund[gen_id]);
 | 
					      for (int gen_id = 0; gen_id < this_algebra_dim; gen_id++)
 | 
				
			||||||
#if verbose
 | 
					      {
 | 
				
			||||||
          std::cout << GridLogMessage << " as_indx = " << a << " eDag T_F e = " << std::endl << tmp_l << std::endl;
 | 
					          Complex iTr;
 | 
				
			||||||
          std::cout << GridLogMessage << " as_indx = " << a << " eDag e T_F^T = " << std::endl << tmp_r << std::endl;
 | 
					          sum = 0;
 | 
				
			||||||
#endif
 | 
					          sum_im = 0;
 | 
				
			||||||
          std::cout << GridLogMessage << " as_indx = " << a << " Tr(sum) = " << TensorRemove(trace(tmp_l+tmp_r)) << std::endl;
 | 
					          std::cout << GridLogMessage <<  "generator number " << gen_id << std::endl;
 | 
				
			||||||
          sum += real(TensorRemove(trace(tmp_l+tmp_r)));
 | 
					          for (int a = 0; a < this_irrep_dim; a++)
 | 
				
			||||||
          sum_im += imag(TensorRemove(trace(tmp_l+tmp_r)));
 | 
					          {
 | 
				
			||||||
 | 
					          
 | 
				
			||||||
 | 
					              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) {
 | 
					int main(int argc, char** argv) {
 | 
				
			||||||
  std::cout << GridLogMessage << "Checking AntiSymmetric base " << std::endl;
 | 
					    check_dimensions<2>();
 | 
				
			||||||
  antisymm_base();
 | 
					    check_dimensions<4>();
 | 
				
			||||||
  std::cout << GridLogMessage << "*************** " << std::endl;
 | 
					    check_dimensions<6>();
 | 
				
			||||||
  std::cout << GridLogMessage << "Checking Symmetric base " << std::endl;
 | 
					    check_dimensions<8>();
 | 
				
			||||||
  symm_base();
 | 
					    
 | 
				
			||||||
 | 
					    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>();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,99 +2,52 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
using namespace Grid;
 | 
					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) {
 | 
					int main(int argc, char** argv) {
 | 
				
			||||||
  Grid_init(&argc, &argv);
 | 
					  Grid_init(&argc, &argv);
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
  std::cout << GridLogMessage << "*********************************************"
 | 
					  run_checks<2>(1); //  check and print Nc=2
 | 
				
			||||||
              << std::endl;
 | 
					  run_checks<4>(1); //  check and print Nc=4
 | 
				
			||||||
  std::cout << GridLogMessage << "* Generators for Sp(2) (print and test)" << std::endl;
 | 
					  run_checks<6>();  //  check Nc=6
 | 
				
			||||||
  std::cout << GridLogMessage << "*********************************************"
 | 
					  run_checks<8>();  //  check Nc=8
 | 
				
			||||||
              << 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();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Grid_finalize();
 | 
					  Grid_finalize();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user