25 void polar_dec(LatticeColorMatrix&
c, LatticeColorMatrix& v,
26 LatticeReal&
alpha,
const Real& JacAccu,
int JacMax)
28 LatticeColorMatrix u_tmp;
29 LatticeColorMatrix w_tmp;
30 LatticeColorMatrix v_tmp;
32 multi2d<LatticeComplex> mat1(Nc, Nc);
33 multi2d<LatticeComplex> mat2(Nc, Nc);
39 multi1d<LatticeReal> diag(Nc);
44 LatticeReal diff_diag;
68 Real acc_sq = JacAccu * JacAccu / Real(100);
73 rescale = real(trace(u_tmp));
79 for(
int i=0;
i < Nc; ++
i)
80 for(
int j=0;
j < Nc; ++
j)
81 mat1[
i][
j] = peekColor(u_tmp,
i,
j);
83 for(
int i=0;
i<Nc;
i++)
85 for(
int j=0;
j<
i;
j++)
91 diag[
i] = real(mat1[
i][
i]);
98 i_rot = Layout::vol();
100 while ( iter < JacMax && i_rot > 0 )
105 for(
int j = 1;
j < Nc;
j++)
106 for(
int i = 0;
i <
j;
i++)
108 dd = real(mat1[
i][
j] * mat1[
j][
i]);
109 lr1 = fabs(diag[
i] * diag[
j] * acc_sq);
112 n_rot = toInt(
sum(where(l_rot, LatticeInteger(1), LatticeInteger(0))));
119 diff_diag = diag[
j] - diag[
i];
121 lr2 = fabs(diff_diag);
125 lr1 = dd / diff_diag;
130 lr1 = diff_diag / dd;
131 LatticeReal theta = 0.5 * lr1;
132 lr1 = fabs(theta) + sqrt(1 + theta * theta);
139 copymask(tt, lb3, LatticeReal(-tt));
141 lr1 = 1 / sqrt(1 + tt*tt);
150 al1 += lr1 * diag[
j];
151 al2 += lr1 * diag[
i];
162 v12 = mat1[
j][
i] * lr1;
169 for(
int k = 0;
k < Nc;
k++)
170 if(
k !=
i &&
k !=
j )
172 lc1 = mat1[
k][
i] * v11 - mat1[
k][
j] * v12;
173 lc2 = mat1[
k][
j] * v11 - mat1[
k][
i] * v21;
176 copymask(mat1[
i][
k], l_rot, LatticeComplex(adj(lc1)));
177 copymask(mat1[
j][
k], l_rot, LatticeComplex(adj(lc2)));
181 for(
int k = 0;
k < Nc;
k++)
183 lc1 = mat2[
i][
k] * v11 + mat2[
j][
k] * v21;
184 lc2 = mat2[
j][
k] * v11 + mat2[
i][
k] * v12;
193 for(
int i=0;
i < Nc; ++
i)
194 for(
int j=0;
j < Nc; ++
j)
195 pokeColor(w_tmp, mat2[
i][
j],
i,
j);
202 printf(
"Warning: %d rotation matrices not unitary\n",
numbad);
209 for(
int i=0;
i<Nc;
i++)
211 for(
int j=0;
j<
i;
j++)
213 off_d += norm2(mat1[
j][
i]);
217 numbad += toInt(
sum(where(diag[
i] <= lr1, LatticeInteger(1), LatticeInteger(0))));
218 mat1[
i][
i] = cmplx(diag[
i],lr1);
221 for(
int i=0;
i < Nc; ++
i)
222 for(
int j=0;
j < Nc; ++
j)
223 pokeColor(v, mat1[
i][
j],
i,
j);
226 v = adj(w_tmp) * v_tmp - u_tmp;
227 diff_sq = norm2(v) /
Double(Layout::vol());
228 off_d /=
Double(Layout::vol());
231 QDPIO::cout <<
"Warning: " <<
numbad <<
" C matrices have zero determiant" << std::endl;
233 push(nml_out,
"Bad_C_matrices");
240 for(
int i=0;
i<Nc;
i++)
242 diag[
i] = sqrt(diag[
i] * rescale);
244 mat1[
i][
i] = cmplx(lr2,lr1);
247 for(
int i=0;
i < Nc; ++
i)
248 for(
int j=0;
j < Nc; ++
j)
249 pokeColor(v, mat1[
i][
j],
i,
j);
252 v = adj(w_tmp) * u_tmp;
256 for(
int i=0;
i<Nc;
i++)
258 mat1[
i][
i] = cmplx(diag[
i],lr1);
261 for(
int i=0;
i < Nc; ++
i)
262 for(
int j=0;
j < Nc; ++
j)
263 pokeColor(
c, mat1[
i][
j],
i,
j);
266 c = adj(w_tmp) * v_tmp;
270 v_tmp -= adj(u_tmp) * u_tmp;
271 unit_test = norm2(v_tmp);
272 unit_test /=
Double(Layout::vol());
277 for(
int i=0;
i < Nc; ++
i)
278 for(
int j=0;
j < Nc; ++
j)
279 mat1[
i][
j] = peekColor(u_tmp,
i,
j);
282 for(
int j = 0;
j < Nc;
j++)
284 for(
int i = 0;
i <=
j;
i++)
287 for(
int k = 0;
k <
i;
k++)
288 lc1 -= mat1[
k][
i] * mat1[
j][
k];
293 for(
int i = (
j+1);
i < Nc;
i++)
296 for(
int k = 0;
k <
j;
k++)
297 lc1 -= mat1[
k][
i] * mat1[
j][
k];
299 lc2 = adj(mat1[
j][
j]) * mat1[
j][
j];
303 lc1 = adj(mat1[
j][
j]) * lc2;
309 lc1 = mat1[0][0] * mat1[1][1];
310 for(
int k = 2;
k < Nc;
k++)
312 lc2 = mat1[
k][
k] * lc1;
317 alpha = atan2(lr2, lr1);
320 lr2 = real(trace(adj(lc1) * lc1));
322 det_diff = norm2(lr1) /
Double(Layout::vol());
335 lc1 = cmplx(lr1,lr2);
342 XMLBufferWriter xml_out;
343 push(xml_out,
"Diagonalization_test");
344 write(xml_out,
"iter",iter);
345 write(xml_out,
"off_d",off_d);
346 write(xml_out,
"diff_sq", diff_sq);
347 write(xml_out,
"unit_test", unit_test);
348 write(xml_out,
"det_diff", det_diff);
355 QDPIO::cout <<
"polar_dec::iter " << iter <<
"\n" ;
356 QDPIO::cout <<
"polar_dec::off_d " << off_d <<
"\n" ;
357 QDPIO::cout <<
"polar_dec::diff_sq " << diff_sq <<
"\n" ;
358 QDPIO::cout <<
"polar_dec::unit_test " << unit_test <<
"\n" ;
359 QDPIO::cout <<
"polar_dec::det_diff " << det_diff<<
"\n" ;
360 QDPIO::cout <<
"polar_dec::numbad " <<
numbad<<
"\n" ;
Primary include file for CHROMA library code.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams ¶m)
Writer parameters.
void polar_dec(LatticeColorMatrix &c, LatticeColorMatrix &v, LatticeReal &alpha, const Real &JacAccu, int JacMax)
Decompose a complex matrix as C = exp(i\alpha) V P.
static const LatticeInteger & alpha(const int dim)
Asqtad Staggered-Dirac operator.
push(xml_out,"Condensates")
void reunit(LatticeColorMatrixF3 &xa)
FloatingPoint< double > Double
Decompose a complex matrix as .
copymask(lcoord, lbit, ltmp_1, REPLACE)
Reunitarize in place a color matrix to SU(N)