mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-11-03 21:44:33 +00:00 
			
		
		
		
	Merge in Alessandro's changes [test fails]
This commit is contained in:
		@@ -303,7 +303,6 @@ class GaugeGroup {
 | 
			
		||||
  template <typename LatticeMatrixType>
 | 
			
		||||
  static void taProj(const LatticeMatrixType &in, LatticeMatrixType &out) {
 | 
			
		||||
    taProj(in, out, group_name());
 | 
			
		||||
    //out = Ta(in);
 | 
			
		||||
  }
 | 
			
		||||
    
 | 
			
		||||
  template <typename LatticeMatrixType>
 | 
			
		||||
@@ -337,32 +336,20 @@ class GaugeGroup {
 | 
			
		||||
      ProjectOnGaugeGroup(Umu, group_name());
 | 
			
		||||
  }
 | 
			
		||||
    
 | 
			
		||||
    template <class vtype>
 | 
			
		||||
    static void ProjectOnGaugeGroup(iScalar<vtype> &r) {
 | 
			
		||||
  template <class vtype>
 | 
			
		||||
  static void ProjectOnGaugeGroup(iScalar<vtype> &r) {
 | 
			
		||||
      ProjectOnGaugeGroup(r, group_name());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class vtype, int N>
 | 
			
		||||
    static void ProjectOnGaugeGroup(iVector<vtype,N> &r) {
 | 
			
		||||
      r = ProjectOnGaugeGroup(r, group_name());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template <class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
			
		||||
    static void ProjectOnGaugeGroup(iMatrix<vtype,N> &arg) {
 | 
			
		||||
      arg = ProjectOnGaugeGroup(arg, group_name());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
/*
 | 
			
		||||
  template <int N>        // reunitarise, resimplectify...
 | 
			
		||||
  static void ProjectOnGaugeGroup(iVector<iScalar<iMatrix<vComplexD, N> >, Nd> &U) {
 | 
			
		||||
      ProjectOnGaugeGroup(U, group_name());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  template <int N>        // reunitarise, resimplectify...
 | 
			
		||||
  static void ProjectOnGaugeGroup(iScalar<iScalar<iMatrix<vComplexD, N> > > &Umu) {
 | 
			
		||||
      ProjectOnGaugeGroup(Umu, group_name());
 | 
			
		||||
  }*/
 | 
			
		||||
  template <class vtype, int N>
 | 
			
		||||
  static void ProjectOnGaugeGroup(iVector<vtype,N> &r) {
 | 
			
		||||
      ProjectOnGaugeGroup(r, group_name());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  template <class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
			
		||||
  static void ProjectOnGaugeGroup(iMatrix<vtype,N> &arg) {
 | 
			
		||||
      ProjectOnGaugeGroup(arg, group_name());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  template <int N>       // reunitarise, resimplectify... previously ProjectSUn
 | 
			
		||||
  static void ProjectGn(Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu) {
 | 
			
		||||
@@ -416,7 +403,6 @@ LatticeComplexD Determinant(
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template <int N>
 | 
			
		||||
static void ProjectSUn(
 | 
			
		||||
    Lattice<iScalar<iScalar<iMatrix<vComplexD, N> > > > &Umu) {
 | 
			
		||||
@@ -445,7 +431,6 @@ static void ProjectSUn(
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Explicit specialisation for SU(3).
 | 
			
		||||
// Explicit specialisation for SU(3).
 | 
			
		||||
static void ProjectSU3(
 | 
			
		||||
    Lattice<iScalar<iScalar<iMatrix<vComplexD, 3> > > > &Umu) {
 | 
			
		||||
 
 | 
			
		||||
@@ -68,8 +68,7 @@ public:
 | 
			
		||||
    for (int a = 0; a < Dimension; a++) {
 | 
			
		||||
      tmp = ta[a] * ta[Index] - ta[Index] * ta[a];
 | 
			
		||||
      for (int b = 0; b < (ncolour * ncolour - 1); b++) {
 | 
			
		||||
        iSUnMatrix<cplx> tmp1 =
 | 
			
		||||
	  2.0 * tmp * ta[b];  // 2.0 from the normalization
 | 
			
		||||
        iSUnMatrix<cplx> tmp1 = 2.0 * tmp * ta[b];  // 2.0 from the normalization
 | 
			
		||||
        Complex iTr = TensorRemove(timesI(trace(tmp1)));
 | 
			
		||||
        //iAdjTa()()(b, a) = iTr;
 | 
			
		||||
        iAdjTa()()(a, b) = iTr;
 | 
			
		||||
 
 | 
			
		||||
@@ -126,8 +126,7 @@ public:
 | 
			
		||||
 | 
			
		||||
  template <class cplx>
 | 
			
		||||
  static void generator(int Index, iSUnTwoIndexMatrix<cplx> &i2indTa) {
 | 
			
		||||
    Vector<iSUnMatrix<cplx> > ta(
 | 
			
		||||
								ncolour * ncolour - 1);
 | 
			
		||||
    Vector<iSUnMatrix<cplx> > ta(ncolour * ncolour - 1);
 | 
			
		||||
    Vector<iSUnMatrix<cplx> > eij(Dimension);
 | 
			
		||||
    iSUnMatrix<cplx> tmp;
 | 
			
		||||
    i2indTa = Zero();
 | 
			
		||||
 
 | 
			
		||||
@@ -66,8 +66,6 @@ template<class vtype,int N> accelerator_inline iMatrix<vtype,N> Ta(const iMatrix
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// for sp2n can't be as simple as Ta. We do a Gram-Schmidt
 | 
			
		||||
 | 
			
		||||
template<class vtype> accelerator_inline iScalar<vtype> SpTa(const iScalar<vtype>&r)
 | 
			
		||||
{
 | 
			
		||||
  iScalar<vtype> ret;
 | 
			
		||||
@@ -82,77 +80,47 @@ template<class vtype,int N> accelerator_inline iVector<vtype,N> SpTa(const iVect
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
template<class vtype,int N> accelerator_inline iMatrix<vtype,N> SpTa(const iMatrix<vtype,N> &arg)
 | 
			
		||||
template<class vtype,int N, typename std::enable_if< GridTypeMapper<vtype>::TensorLevel == 0 >::type * =nullptr>
 | 
			
		||||
accelerator_inline iMatrix<vtype,N> SpTa(const iMatrix<vtype,N> &arg)
 | 
			
		||||
{
 | 
			
		||||
    iMatrix<vtype,N> ret(arg);
 | 
			
		||||
    vtype nrm;
 | 
			
		||||
    vtype inner;
 | 
			
		||||
    vtype tmp;
 | 
			
		||||
  // Generalises Ta to Sp2n
 | 
			
		||||
  // Applies the following projections
 | 
			
		||||
  // P_{antihermitian} P_{antihermitian-Sp-algebra} P_{traceless}
 | 
			
		||||
  // where the ordering matters
 | 
			
		||||
  // P_{traceless} subtracts the trace
 | 
			
		||||
  // P_{antihermitian-Sp-algebra} provides the block structure of the algebra based on U = exp(T) i.e. anti-hermitian generators
 | 
			
		||||
  // P_{antihermitian} does in-adj(in) / 2
 | 
			
		||||
  iMatrix<vtype,N> ret(arg);
 | 
			
		||||
  double factor = (1.0/(double)N);
 | 
			
		||||
  vtype nrm;
 | 
			
		||||
  nrm = 0.5;
 | 
			
		||||
    
 | 
			
		||||
    for(int c1=0;c1<N/2;c1++)
 | 
			
		||||
    {
 | 
			
		||||
  ret = arg - (trace(arg)*factor);
 | 
			
		||||
    
 | 
			
		||||
        for (int b=0; b<c1; b++)                  // remove the b-rows from U_c1
 | 
			
		||||
        {
 | 
			
		||||
            decltype(ret._internal[b][b]*ret._internal[b][b]) pr;
 | 
			
		||||
            decltype(ret._internal[b][b]*ret._internal[b][b]) prn;
 | 
			
		||||
            zeroit(pr);
 | 
			
		||||
            zeroit(prn);
 | 
			
		||||
  for(int c1=0;c1<N/2;c1++)
 | 
			
		||||
  {
 | 
			
		||||
      for(int c2=0;c2<N/2;c2++)
 | 
			
		||||
      {
 | 
			
		||||
          ret._internal[c1][c2] = nrm*(conjugate(ret._internal[c1+N/2][c2+N/2]) + ret._internal[c1][c2]); // new[up-left] = old[up-left]+old*[down-right]
 | 
			
		||||
          ret._internal[c1][c2+N/2] = nrm*(ret._internal[c1][c2+N/2] - conjugate(ret._internal[c1+N/2][c2])); // new[up-right] = old[up-right]-old*[down-left]
 | 
			
		||||
      }
 | 
			
		||||
      for(int c2=N/2;c2<N;c2++)
 | 
			
		||||
      {
 | 
			
		||||
          ret._internal[c1+N/2][c2-N/2] = -conjugate(ret._internal[c1][c2]);  //  reconstructs lower blocks
 | 
			
		||||
          ret._internal[c1+N/2][c2] = conjugate(ret._internal[c1][c2-N/2]);   //  from upper blocks
 | 
			
		||||
      }
 | 
			
		||||
  }
 | 
			
		||||
    
 | 
			
		||||
            for(int c=0; c<N; c++)
 | 
			
		||||
            {
 | 
			
		||||
                pr += conjugate(ret._internal[c1][c])*ret._internal[b][c];        // <U_c1 | U_b >
 | 
			
		||||
                prn += conjugate(ret._internal[c1][c])*ret._internal[b+N/2][c];   // <U_c1 | U_{b+N} >
 | 
			
		||||
            }
 | 
			
		||||
  ret = (ret - adj(ret))*0.5;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            for(int c=0; c<N; c++)
 | 
			
		||||
            {
 | 
			
		||||
                ret._internal[c1][c] -= (conjugate(pr) * ret._internal[b][c] + conjugate(prn) * ret._internal[b+N/2][c] );    //  U_c1 -= (  <U_c1 | U_b > U_b + <U_c1 | U_{b+N} > U_{b+N}  )
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
      
 | 
			
		||||
        zeroit(inner);
 | 
			
		||||
        for(int c2=0;c2<N;c2++)
 | 
			
		||||
        {
 | 
			
		||||
            inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        nrm = sqrt(inner);
 | 
			
		||||
        nrm = 1.0/nrm;
 | 
			
		||||
        for(int c2=0;c2<N;c2++)
 | 
			
		||||
        {
 | 
			
		||||
            ret._internal[c1][c2]*= nrm;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        for(int c2=0;c2<N/2;c2++)
 | 
			
		||||
        {
 | 
			
		||||
            tmp = conjugate(ret._internal[c1][c2]);       // (up-left)* of the old matrix
 | 
			
		||||
            ret._internal[c1+N/2][c2+N/2] = -tmp;          // down right in the new matrix = -(up-left)* of the old matrix
 | 
			
		||||
        }
 | 
			
		||||
           
 | 
			
		||||
        for(int c2=N/2;c2<N;c2++)
 | 
			
		||||
        {
 | 
			
		||||
            tmp = conjugate(ret._internal[c1][c2]);   // (up-right)* of the old
 | 
			
		||||
            ret._internal[c1+N/2][c2-N/2] = tmp;     // down left in the new matrix = (up-right)* of the old
 | 
			
		||||
        }
 | 
			
		||||
      
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
  
 | 
			
		||||
  return Ta(ret);
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/////////////////////////////////////////////// 
 | 
			
		||||
// ProjectOnGroup function for scalar, vector, matrix 
 | 
			
		||||
// Projects on orthogonal, unitary group
 | 
			
		||||
/////////////////////////////////////////////// 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
template<class vtype> accelerator_inline iScalar<vtype> ProjectOnGroup(const iScalar<vtype>&r)
 | 
			
		||||
{
 | 
			
		||||
  iScalar<vtype> ret;
 | 
			
		||||
@@ -244,58 +212,52 @@ accelerator_inline iMatrix<vtype,N> ProjectOnSpGroup(const iMatrix<vtype,N> &arg
 | 
			
		||||
  iMatrix<vtype,N> ret(arg);
 | 
			
		||||
  vtype nrm;
 | 
			
		||||
  vtype inner;
 | 
			
		||||
  vtype tmp;
 | 
			
		||||
  
 | 
			
		||||
  for(int c1=0;c1<N/2;c1++)
 | 
			
		||||
  {
 | 
			
		||||
      
 | 
			
		||||
      for (int b=0; b<c1; b++)                  // remove the b-rows from U_c1
 | 
			
		||||
    for (int b=0; b<c1; b++)                  // remove the b-rows from U_c1
 | 
			
		||||
    {
 | 
			
		||||
      decltype(ret._internal[b][b]*ret._internal[b][b]) pr;
 | 
			
		||||
      decltype(ret._internal[b][b]*ret._internal[b][b]) prn;
 | 
			
		||||
      zeroit(pr);
 | 
			
		||||
      zeroit(prn);
 | 
			
		||||
          
 | 
			
		||||
      for(int c=0; c<N; c++)
 | 
			
		||||
      {
 | 
			
		||||
          decltype(ret._internal[b][b]*ret._internal[b][b]) pr;
 | 
			
		||||
          decltype(ret._internal[b][b]*ret._internal[b][b]) prn;
 | 
			
		||||
          zeroit(pr);
 | 
			
		||||
          zeroit(prn);
 | 
			
		||||
          
 | 
			
		||||
          for(int c=0; c<N; c++)
 | 
			
		||||
          {
 | 
			
		||||
              pr += conjugate(ret._internal[c1][c])*ret._internal[b][c];        // <U_c1 | U_b >
 | 
			
		||||
              prn += conjugate(ret._internal[c1][c])*ret._internal[b+N/2][c];   // <U_c1 | U_{b+N} >
 | 
			
		||||
          }
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
          for(int c=0; c<N; c++)
 | 
			
		||||
          {
 | 
			
		||||
              ret._internal[c1][c] -= (conjugate(pr) * ret._internal[b][c] + conjugate(prn) * ret._internal[b+N/2][c] );    //  U_c1 -= (  <U_c1 | U_b > U_b + <U_c1 | U_{b+N} > U_{b+N}  )
 | 
			
		||||
          }
 | 
			
		||||
      }
 | 
			
		||||
    
 | 
			
		||||
      zeroit(inner);
 | 
			
		||||
      for(int c2=0;c2<N;c2++)
 | 
			
		||||
      {
 | 
			
		||||
          inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
			
		||||
      }
 | 
			
		||||
      
 | 
			
		||||
      nrm = sqrt(inner);
 | 
			
		||||
      nrm = 1.0/nrm;
 | 
			
		||||
      for(int c2=0;c2<N;c2++)
 | 
			
		||||
      {
 | 
			
		||||
          ret._internal[c1][c2]*= nrm;
 | 
			
		||||
        pr += conjugate(ret._internal[c1][c])*ret._internal[b][c];        // <U_c1 | U_b >
 | 
			
		||||
        prn += conjugate(ret._internal[c1][c])*ret._internal[b+N/2][c];   // <U_c1 | U_{b+N} >
 | 
			
		||||
      }
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
      for(int c2=0;c2<N/2;c2++)
 | 
			
		||||
      for(int c=0; c<N; c++)
 | 
			
		||||
      {
 | 
			
		||||
          tmp = conjugate(ret._internal[c1][c2]);       // (up-left)* of the old matrix
 | 
			
		||||
          ret._internal[c1+N/2][c2+N/2] = tmp;          // down right in the new matrix = (up-left)* of the old matrix
 | 
			
		||||
        ret._internal[c1][c] -= (conjugate(pr) * ret._internal[b][c] + conjugate(prn) * ret._internal[b+N/2][c] );    //  U_c1 -= (  <U_c1 | U_b > U_b + <U_c1 | U_{b+N} > U_{b+N}  )
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
      for(int c2=N/2;c2<N;c2++)
 | 
			
		||||
      {
 | 
			
		||||
          tmp = conjugate(ret._internal[c1][c2]);   // (up-right)* of the old
 | 
			
		||||
          ret._internal[c1+N/2][c2-N/2] = -tmp;     // down left in the new matrix = -(up-right)* of the old
 | 
			
		||||
      }
 | 
			
		||||
    zeroit(inner);
 | 
			
		||||
    for(int c2=0;c2<N;c2++)
 | 
			
		||||
    {
 | 
			
		||||
      inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
 | 
			
		||||
    }
 | 
			
		||||
      
 | 
			
		||||
    nrm = sqrt(inner);
 | 
			
		||||
    nrm = 1.0/nrm;
 | 
			
		||||
    for(int c2=0;c2<N;c2++)
 | 
			
		||||
    {
 | 
			
		||||
      ret._internal[c1][c2]*= nrm;
 | 
			
		||||
    }
 | 
			
		||||
      
 | 
			
		||||
    for(int c2=0;c2<N/2;c2++)
 | 
			
		||||
    {
 | 
			
		||||
      ret._internal[c1+N/2][c2+N/2] = conjugate(ret._internal[c1][c2]);          // down right in the new matrix = (up-left)* of the old matrix
 | 
			
		||||
    }
 | 
			
		||||
      
 | 
			
		||||
    for(int c2=N/2;c2<N;c2++)
 | 
			
		||||
    {
 | 
			
		||||
      ret._internal[c1+N/2][c2-N/2] = -conjugate(ret._internal[c1][c2]);;     // down left in the new matrix = -(up-right)* of the old
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -144,10 +144,8 @@ bool is_element_of_sp2n_algebra(T U) {
 | 
			
		||||
 | 
			
		||||
  aux = U - adj(U);
 | 
			
		||||
  std::cout << GridLogMessage << "T - Tda = " << norm2(aux) << std::endl;
 | 
			
		||||
  assert(norm2(aux) < 1e-8);
 | 
			
		||||
  aux = U + adj(U);
 | 
			
		||||
  std::cout << GridLogMessage << "T + Tda = " << norm2(aux) << std::endl;
 | 
			
		||||
  assert(norm2(aux) < 1e-8);
 | 
			
		||||
 | 
			
		||||
  std::cout << GridLogMessage << "Check that Omega U Omega = conj(U)"
 | 
			
		||||
            << std::endl;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,14 +10,14 @@ int main(int argc, char** argv) {
 | 
			
		||||
  //latt, GridDefaultSimd(Nd, vComplex::Nsimd()), GridDefaultMpi());
 | 
			
		||||
  //GridRedBlackCartesian* rbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(grid);
 | 
			
		||||
    
 | 
			
		||||
    std::cout << GridLogMessage << "*********************************************"
 | 
			
		||||
  std::cout << GridLogMessage << "*********************************************"
 | 
			
		||||
              << std::endl;
 | 
			
		||||
    std::cout << GridLogMessage << "* Generators for Sp(2)" << std::endl;
 | 
			
		||||
    std::cout << GridLogMessage << "*********************************************"
 | 
			
		||||
  std::cout << GridLogMessage << "* Generators for Sp(2)" << std::endl;
 | 
			
		||||
  std::cout << GridLogMessage << "*********************************************"
 | 
			
		||||
              << std::endl;
 | 
			
		||||
      
 | 
			
		||||
    Sp2::printGenerators();
 | 
			
		||||
    Sp2::testGenerators();
 | 
			
		||||
  Sp2::printGenerators();
 | 
			
		||||
  Sp2::testGenerators();
 | 
			
		||||
  
 | 
			
		||||
  std::cout << GridLogMessage << "*********************************************"
 | 
			
		||||
            << std::endl;
 | 
			
		||||
@@ -46,6 +46,5 @@ int main(int argc, char** argv) {
 | 
			
		||||
  Sp8::printGenerators();
 | 
			
		||||
  Sp8::testGenerators(); 
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
  Grid_finalize();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user