CHROMA
rot_colvec.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Rotate a color std::vector
3  */
4 
5 #include "chromabase.h"
6 #include "meas/gfix/polar_dec.h"
7 #include "util/gauge/sunfill.h"
8 
9 namespace Chroma {
10 
11 //! Rotate a color std::vector
12 /*!
13  * \ingroup gfix
14  *
15  * Rotate a color std::vector into the form where the component with index
16  * s_index is real and the component with larger index are zero.
17  * We do this by a series of SU(2) gauge rotations.
18  *
19  * \param g Gauge transformation (Write)
20  * \param psi Input color std::vector field (Read)
21  * \param chi Output color std::vector field (Write)
22  * \param s_index color index (Read)
23  */
24 
25 void rot_colvec(LatticeColorMatrix& g,
26  const LatticeColorVector& psi,
27  LatticeColorVector& chi,
28  int s_index)
29 {
30  multi2d<LatticeComplex> g_e(Nc, Nc);
31  multi1d<LatticeComplex> psi_e(Nc);
32  multi1d<LatticeComplex> chi_e(Nc);
33 
34  START_CODE();
35 
36  if ( s_index < 0 || (s_index > (Nc-2) && Nc > 1) ||
37  (s_index > 0 && Nc == 1) )
38  QDP_error_exit("Illigal value for color index", s_index);
39 
40 
41  if (Nc > 1)
42  {
43  /* Make each site color std::vector unit length, to avoid round-off problems
44  and do the opposite rescaling at the end. */
45  LatticeReal length = sqrt(localNorm2(psi));
46  LatticeReal lr1 = 1 / length;
47 
48  for(int i=0; i < Nc; ++i)
49  psi_e[i] = peekColor(psi, i);
50 
51  for(int i=s_index+1; i<Nc; i++)
52  {
53  chi_e[i] = 0;
54  psi_e[i] *= lr1;
55  }
56  psi_e[s_index] *= lr1;
57 
58  for(int i=0; i<s_index; i++)
59  chi_e[i] = psi_e[i];
60 
61  multi1d<LatticeReal> a(4);
62  LatticeComplex lc1;
63  LatticeReal lr2;
64 
65  for(int i=Nc-2; i>=s_index; i--)
66  {
67  lr1 = sqrt(localNorm2(psi_e[i]) + localNorm2(psi_e[i+1]));
68  lr2 = 1 / lr1;
69 
70  lc1 = LatticeComplex(adj(psi_e[i])) * lr2;
71  a[0] = real(lc1);
72  a[3] = imag(lc1);
73 
74  lc1 = LatticeComplex(adj(psi_e[i+1])) * lr2;
75  a[2] = real(lc1);
76  a[1] = imag(lc1);
77 
78  psi_e[i] = cmplx(lr1,0);
79 
80  if (i == Nc-2)
81  {
82  sunFill(g, a, i, all);
83  }
84  else
85  {
86  LatticeColorMatrix v1, v2;
87  sunFill(v1, a, i, all);
88  v2 = v1 * g;
89  g = v2;
90  }
91  }
92 
93  chi_e[s_index] = psi_e[s_index] * length;
94 
95  for(int i=0; i < Nc; ++i)
96  pokeColor(chi, chi_e[i], i);
97 
98  }
99  else /* ! Nc > 1 */
100  {
101  psi_e[0] = peekColor(psi, 0);
102  LatticeReal lr1 = sqrt(localNorm2(psi_e[0]));
103  chi_e[0] = cmplx(lr1,0);
104  pokeColor(chi, chi_e[0], 0);
105 
106  g_e[0][0] = adj(psi_e[0]) / lr1;
107 
108  pokeColor(g, g_e[0][0], 0, 0);
109  }
110 
111  END_CODE();
112 }
113 
114 } // end namespace Chroma
Primary include file for CHROMA library code.
void sunFill(LatticeColorMatrix &dest, const multi1d< LatticeReal > &r, int su2_index, const Subset &s)
Fill a dest(su2_index) <- r_0,r_1,r_2,r_3 under a subset.
Definition: sunfill.cc:33
void rot_colvec(LatticeColorMatrix &g, const LatticeColorVector &psi, LatticeColorVector &chi, int s_index)
Rotate a color std::vector.
Definition: rot_colvec.cc:25
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
int i
Definition: pbg5p_w.cc:55
multi1d< LatticeFermion > chi(Ncb)
Complex a
Definition: invbicg.cc:95
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Decompose a complex matrix as .
Fill an SU(Nc) matrix with an SU(2) submatrix.