CHROMA
sun_proj.cc
Go to the documentation of this file.
1 // $Id: sun_proj.cc,v 3.2 2007-02-22 21:11:50 bjoo Exp $
2 /*! \file
3  * \ingroup gauge
4  * \author Subsetting added by A. Hart
5  * \param[in] w complex Nc x Nc matrix
6  * \param[out] v the projected SU(Nc) Matrix
7  * \param[in] BlkAccu accuracy in SU(Nc) projection
8  * \param[in] BlkMax max number of iterations in SU(Nc) projection
9  * \param[in] mstag an (un)ordered subset of lattice sites
10  * \brief Project a complex Nc x Nc matrix W onto SU(Nc) by maximizing Tr(VW)
11  *
12  * Project a complex Nc x Nc matrix W onto SU(Nc) by maximizing Tr(VW)
13  */
14 
15 #include "chromabase.h"
16 
17 #include "util/gauge/sun_proj.h"
18 #include "util/gauge/su3proj.h"
19 #include "util/gauge/reunit.h"
20 
21 
22 namespace Chroma
23 {
24 
25  template<typename S>
26  inline
27  void sun_proj_t(const LatticeColorMatrix& w,
28  LatticeColorMatrix& v,
29  const Real& BlkAccu,
30  int BlkMax,
31  const S& mstag)
32  {
33  START_CODE();
34 
35  Double new_tr;
36 
37  /*
38  * Project back to SU(3) by maximizing tr(v w).
39  * This is done by looping proj_iter times over the 3 SU(2) subgroups.
40  */
41 
42  /* I need to get the number of sites in the sublattice. As far as
43  * I know, mstag does not contain information about either the number
44  * of sites it contains, nor of the number of subsets.
45  */
46 
47  LatticeInt count;
48  count = 1;
49  Int numSites = sum(count,mstag);
50  Double norm = Double(1)/(Nc*numSites);
51 
52  /* The initial trace */
53  Double old_tr = sum(real(trace(v * w)),mstag) * norm;
54 
55  int iter = 0;
56  int wrswitch = 0; // Write out iterations?
57 // Double conver = 1.0;
58  Real conver = 1.0;
59 
60  while ( toBool(conver > BlkAccu) && iter < BlkMax )
61  {
62  ++iter;
63 
64  // Loop over SU(2) subgroup index
65  for(int su2_index = 0; su2_index < Nc*(Nc-1)/2; ++su2_index)
66  su3proj(v, w, su2_index, mstag);
67 
68  // Reunitarize: this is the slow bit of the code...
69  reunit(v,mstag);
70 
71  // Calculate the trace
72  new_tr = sum(real(trace(v * w)), mstag) * norm;
73 
74  if( wrswitch == 1 )
75  {
76  QDPIO::cout << "iter = " << iter << std::endl;
77  QDPIO::cout << " old_tr = " << old_tr << std::endl;
78  QDPIO::cout << " new_tr = " << new_tr << std::endl;
79  }
80 
81  // Normalized convergence criterion:
82  conver = fabs((new_tr - old_tr) / old_tr);
83  old_tr = new_tr;
84  }
85 
86 #if 0
87  if ( wrswitch == 1 )
88  {
89 // push(nml,"Final_sun_proj");
90 // write(nml, "iter", iter);
91 // write(nml, "new_tr", new_tr);
92 // pop(nml);
93  QDPIO::cout << "iter = " << iter << std::endl;
94  QDPIO::cout << "new_tr = " << new_tr << std::endl;
95  }
96 #endif
97 
98  END_CODE();
99  }
100 
101  void sun_proj(const LatticeColorMatrix& w,
102  LatticeColorMatrix& v,
103  const Real& BlkAccu,
104  int BlkMax)
105  {
106  sun_proj_t(w, v, BlkAccu, BlkMax, all);
107  }
108 
109  void sun_proj(const LatticeColorMatrix& w,
110  LatticeColorMatrix& v,
111  const Real& BlkAccu,
112  int BlkMax,
113  const Subset& mstag)
114  {
115  sun_proj_t(w, v, BlkAccu, BlkMax, mstag);
116  }
117 
118 }
Primary include file for CHROMA library code.
int su2_index
Definition: cool.cc:27
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
void sun_proj_t(const LatticeColorMatrix &w, LatticeColorMatrix &v, const Real &BlkAccu, int BlkMax, const S &mstag)
Definition: sun_proj.cc:27
void su3proj(LatticeColorMatrix &u, const LatticeColorMatrix &w, int su2_index)
Definition: su3proj.cc:76
void sun_proj(const LatticeColorMatrix &w, LatticeColorMatrix &v, const Real &BlkAccu, int BlkMax)
Definition: sun_proj.cc:101
void reunit(LatticeColorMatrixF3 &xa)
Definition: reunit.cc:467
START_CODE()
int count
Definition: octave.h:14
FloatingPoint< double > Double
Definition: gtest.h:7351
Double sum
Definition: qtopcor.cc:37
int norm
Definition: qtopcor.cc:35
Reunitarize in place a color matrix to SU(N)
Project a GL(3,C) color matrix onto SU(3)
Project a complex Nc x Nc matrix W onto SU(Nc) by maximizing Tr(VW)