Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_CloverTerm_eo_impl.cpp
Go to the documentation of this file.
1 
15 
17 #include "Solver/solver_CG.h"
18 
19 namespace Imp {
20 #if defined USE_GROUP_SU3
22 #elif defined USE_GROUP_SU2
24 #elif defined USE_GROUP_SU_N
26 #endif
27 
28 //====================================================================
29 
30  const std::string Fopr_CloverTerm_eo::class_name = "Imp::Fopr_CloverTerm_eo";
31 
32 //====================================================================
33  void Fopr_CloverTerm_eo::init(const std::string repr)
34  {
35  m_repr = repr;
36 
40  m_NinF = 2 * m_Nc * m_Nd;
42  m_Nvol2 = m_Nvol / 2;
43 
44  m_boundary.resize(m_Ndim);
45 
46  m_Ueo = 0;
47 
48  m_GM.resize(m_Ndim + 1);
49  m_SG.resize(m_Ndim * m_Ndim);
50 
51  unique_ptr<GammaMatrixSet> gmset(GammaMatrixSet::New(m_repr));
52 
53  m_GM[0] = gmset->get_GM(gmset->GAMMA1);
54  m_GM[1] = gmset->get_GM(gmset->GAMMA2);
55  m_GM[2] = gmset->get_GM(gmset->GAMMA3);
56  m_GM[3] = gmset->get_GM(gmset->GAMMA4);
57  m_GM[4] = gmset->get_GM(gmset->GAMMA5);
58 
59  m_SG[sg_index(0, 1)] = gmset->get_GM(gmset->SIGMA12);
60  m_SG[sg_index(1, 2)] = gmset->get_GM(gmset->SIGMA23);
61  m_SG[sg_index(2, 0)] = gmset->get_GM(gmset->SIGMA31);
62  m_SG[sg_index(3, 0)] = gmset->get_GM(gmset->SIGMA41);
63  m_SG[sg_index(3, 1)] = gmset->get_GM(gmset->SIGMA42);
64  m_SG[sg_index(3, 2)] = gmset->get_GM(gmset->SIGMA43);
65 
66  m_SG[sg_index(1, 0)] = m_SG[sg_index(0, 1)].mult(-1);
67  m_SG[sg_index(2, 1)] = m_SG[sg_index(1, 2)].mult(-1);
68  m_SG[sg_index(0, 2)] = m_SG[sg_index(2, 0)].mult(-1);
69  m_SG[sg_index(0, 3)] = m_SG[sg_index(3, 0)].mult(-1);
70  m_SG[sg_index(1, 3)] = m_SG[sg_index(3, 1)].mult(-1);
71  m_SG[sg_index(2, 3)] = m_SG[sg_index(3, 2)].mult(-1);
72 
73  m_SG[sg_index(0, 0)] = gmset->get_GM(gmset->UNITY);
74  m_SG[sg_index(1, 1)] = gmset->get_GM(gmset->UNITY);
75  m_SG[sg_index(2, 2)] = gmset->get_GM(gmset->UNITY);
76  m_SG[sg_index(3, 3)] = gmset->get_GM(gmset->UNITY);
77  // these 4 gamma matrices are actually not used.
78 
79  m_fee_inv = new Field_F(m_Nvol2, m_Nc * m_Nd);
80  m_foo_inv = new Field_F(m_Nvol2, m_Nc * m_Nd);
81 
82  m_vf.reset(m_Nvol2, 1);
83  m_ff.reset(m_Nvol2, 1);
84  }
85 
86 
87 //====================================================================
89  {
90  delete m_foo_inv;
91  delete m_fee_inv;
92  }
93 
94 
95 //====================================================================
97  {
98  const string str_vlevel = params.get_string("verbose_level");
99 
100  m_vl = vout.set_verbose_level(str_vlevel);
101 
102  //- fetch and check input parameters
103  double kappa, cSW;
104  std::vector<int> bc;
105 
106  int err = 0;
107  err += params.fetch_double("hopping_parameter", kappa);
108  err += params.fetch_double("clover_coefficient", cSW);
109  err += params.fetch_int_vector("boundary_condition", bc);
110 
111  if (err) {
112  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
113  exit(EXIT_FAILURE);
114  }
115 
116  set_parameters(kappa, cSW, bc);
117  }
118 
119 
120 //====================================================================
121  void Fopr_CloverTerm_eo::set_parameters(const double kappa, const double cSW,
122  const std::vector<int> bc)
123  {
124  //- print input parameters
125  vout.general(m_vl, "%s:\n", class_name.c_str());
126  vout.general(m_vl, " kappa = %12.8f\n", kappa);
127  vout.general(m_vl, " cSW = %12.8f\n", cSW);
128  for (int mu = 0; mu < m_Ndim; ++mu) {
129  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
130  }
131 
132  //- range check
133  // NB. kappa,cSW == 0 is allowed.
134  assert(bc.size() == m_Ndim);
135 
136  //- store values
137  m_kappa = kappa;
138  m_cSW = cSW;
139 
140  // m_boundary.resize(m_Ndim); // already resized in init.
141  m_boundary = bc;
142  }
143 
144 
145 //====================================================================
147  {
148  m_Ueo = (Field_G *)Ueo;
149 
150  set_csw();
151  solve_csw_inv();
152  }
153 
154 
155 //====================================================================
157  {
158  const double eps2 = CommonParameters::epsilon_criterion2();
159 
160 #if 1
161  Parameters params_solver;
162 
163  params_solver.set_string("solver_type", "CG");
164  params_solver.set_int("maximum_number_of_iteration", 100);
165  params_solver.set_int("maximum_number_of_restart", 40);
166  params_solver.set_double("convergence_criterion_squared", 1.0e-30);
167  params_solver.set_string("use_initial_guess", "false");
168  //- NB. set VerboseLevel to CRUCIAL to suppress frequent messages.
169  params_solver.set_string("verbose_level", "Crucial");
170 #else
171  //
172 #endif
173 
174 
175 
177 
178 #if 1
179  solver->set_parameters(params_solver);
180 #else
181  const int Niter = 100;
182  const int Nrestart = 40;
183  const double Stopping_condition = 1.0e-30;
184 
185  solver->set_parameters(Niter, Nrestart, Stopping_condition);
187 #endif
188 
189  for (int ispin = 0; ispin < m_Nd; ++ispin) {
190  for (int icolor = 0; icolor < m_Nc; ++icolor) {
191  int spin_color = icolor + m_Nc * ispin;
192 
193  Field_F w(m_Nvol2);
194  w.set(0.0);
195  for (int isite = 0; isite < m_Nvol2; ++isite) {
196  w.set_ri(icolor, ispin, isite, 0, 1, 0);
197  }
198 
199  if (m_cSW * m_cSW < eps2) {
200  m_fee_inv->setpart_ex(spin_color, w, 0);
201  m_foo_inv->setpart_ex(spin_color, w, 0);
202  } else {
203  Field_F w2(m_Nvol2);
204  int Nconv;
205  double diff;
206  set_mode("even");
207  solver->solve(w2, w, Nconv, diff);
208  m_fee_inv->setpart_ex(spin_color, w2, 0);
209  vout.detailed(m_vl, " Nconv,diff = %d %12.4e\n", Nconv, diff);
210 
211  set_mode("odd");
212  solver->solve(w2, w, Nconv, diff);
213  m_foo_inv->setpart_ex(spin_color, w2, 0);
214  vout.detailed(m_vl, " Nconv,diff = %d %12.4e\n", Nconv, diff);
215  }
216  }
217  }
218 
219  // redefine the inverse matrix with its dagger.
220  for (int ics = 0; ics < m_Nc * m_Nd; ++ics) {
221  for (int site = 0; site < m_Nvol2; ++site) {
222  for (int id = 0; id < m_Nd; ++id) {
223  for (int ic = 0; ic < m_Nc; ++ic) {
224  double re = m_foo_inv->cmp_r(ic, id, site, ics);
225  double im = m_foo_inv->cmp_i(ic, id, site, ics);
226 
227  m_foo_inv->set_ri(ic, id, site, ics, re, -im);
228 
229  re = m_fee_inv->cmp_r(ic, id, site, ics);
230  im = m_fee_inv->cmp_i(ic, id, site, ics);
231 
232  m_fee_inv->set_ri(ic, id, site, ics, re, -im);
233  }
234  }
235  }
236  }
237  }
238 
239 
240 //====================================================================
242  const Field& f, const int ieo)
243  {
244  // multiplies [ 1 - csw kappa sigma_{mu nu} F_{mu nu} ]^{-1}
245  if (m_repr == "Dirac") {
246  mult_csw_inv_dirac(v, f, ieo);
247  } else if (m_repr == "Chiral") {
248  mult_csw_inv_chiral(v, f, ieo);
249  }
250  }
251 
252 
253 //====================================================================
255  const Field& f, const int ieo)
256  {
257  // multiplies [ 1 - csw kappa sigma_{mu nu} F_{mu nu} ]^{-1}
258  const int Nvc = 2 * m_Nc;
259 
260  const double *v1 = f.ptr(0);
261  double *v2 = v.ptr(0);
262 
263  double *csw_inv = 0;
264 
265  if (ieo == 0) {
266  csw_inv = m_fee_inv->ptr(0);
267  } else if (ieo == 1) {
268  csw_inv = m_foo_inv->ptr(0);
269 
270  /*
271  } else {
272  vout.crucial(m_vl, "Error at %s: wrong parameter, ieo = %d.\n",
273  class_name.c_str(), ieo);
274  exit(EXIT_FAILURE);
275  */
276  }
277 
278  // threadding applied.
279  const int Nthread = ThreadManager_OpenMP::get_num_threads();
280  const int i_thread = ThreadManager_OpenMP::get_thread_id();
281  const int is = m_Nvol2 * i_thread / Nthread;
282  const int ns = m_Nvol2 * (i_thread + 1) / Nthread;
283 
284  const int Nd2 = m_Nd / 2;
285  for (int site = is; site < ns; ++site) {
286  for (int icd = 0; icd < m_Nc * Nd2; ++icd) {
287  int iv2 = 2 * icd + m_NinF * site;
288  v2[iv2] = 0.0;
289  v2[iv2 + 1] = 0.0;
290  for (int jd = 0; jd < m_Nd; ++jd) {
291  int jcd = Nvc * jd;
292  int iv = jcd + m_NinF * site;
293  int ig = jcd + m_NinF * (site + m_Nvol2 * icd);
294 
295  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
296  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
297  }
298  }
299 
300  for (int icd = 0; icd < m_Nc * Nd2; ++icd) {
301  int iv2 = 2 * (icd + m_Nc * Nd2) + m_NinF * site;
302  v2[iv2] = 0.0;
303  v2[iv2 + 1] = 0.0;
304  for (int jd = 0; jd < m_Nd; ++jd) {
305  int jd2 = (jd + Nd2) % m_Nd;
306  int iv = Nvc * jd + m_NinF * site;
307  int ig = Nvc * jd2 + m_NinF * (site + m_Nvol2 * icd);
308 
309  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
310  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
311  }
312  }
313  }
314 #pragma omp barrier
315  }
316 
317 
318 //====================================================================
320  const Field& f, const int ieo)
321  {
322  // multiplies [ 1 - csw kappa sigma_{mu nu} F_{mu nu} ]^{-1}
323  const int Nvc = 2 * m_Nc;
324 
325  const double *v1 = f.ptr(0);
326  double *v2 = v.ptr(0);
327 
328  double *csw_inv = 0;
329 
330  if (ieo == 0) {
331  csw_inv = m_fee_inv->ptr(0);
332  } else if (ieo == 1) {
333  csw_inv = m_foo_inv->ptr(0);
334 
335  /*
336  } else {
337  vout.crucial(m_vl, "Error at %s: wrong parameter, ieo = %d.\n",
338  class_name.c_str(), ieo);
339  exit(EXIT_FAILURE);
340  */
341  }
342 
343  // threadding applied.
344  const int Nthread = ThreadManager_OpenMP::get_num_threads();
345  const int i_thread = ThreadManager_OpenMP::get_thread_id();
346  const int is = m_Nvol2 * i_thread / Nthread;
347  const int ns = m_Nvol2 * (i_thread + 1) / Nthread;
348 
349  for (int site = is; site < ns; ++site) {
350  for (int icd = 0; icd < m_Nc * m_Nd / 2; ++icd) {
351  int iv2 = 2 * icd + m_NinF * site;
352  v2[iv2] = 0.0;
353  v2[iv2 + 1] = 0.0;
354 
355  for (int jd = 0; jd < m_Nd / 2; ++jd) {
356  int jcd = Nvc * jd;
357  int iv = jcd + m_NinF * site;
358  int ig = jcd + m_NinF * (site + m_Nvol2 * icd);
359 
360  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
361  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
362  }
363  }
364 
365  for (int icd = m_Nc * m_Nd / 2; icd < m_Nc * m_Nd; ++icd) {
366  int iv2 = 2 * icd + m_NinF * site;
367  v2[iv2] = 0.0;
368  v2[iv2 + 1] = 0.0;
369 
370  for (int jd = m_Nd / 2; jd < m_Nd; ++jd) {
371  int jcd = Nvc * jd;
372  int iv = jcd + m_NinF * site;
373  int ig = jcd + m_NinF * (site + m_Nvol2 * icd);
374 
375  v2[iv2] += mult_uv_r(&csw_inv[ig], &v1[iv], m_Nc);
376  v2[iv2 + 1] += mult_uv_i(&csw_inv[ig], &v1[iv], m_Nc);
377  }
378  }
379  }
380 #pragma omp barrier
381  }
382 
383 
384 //====================================================================
385  std::vector<double> Fopr_CloverTerm_eo::csmatrix(const int& site)
386  {
387  std::vector<double> matrix(m_Nc * m_Nc * m_Nd * m_Nd * 2);
388 
389  for (int ispin = 0; ispin < m_Nd / 2; ++ispin) {
390  for (int icolor = 0; icolor < m_Nc; ++icolor) {
391  int ics = icolor + ispin * m_Nc;
392 
393  for (int jspin = 0; jspin < m_Nd; ++jspin) {
394  int js2 = (jspin + m_Nd / 2) % m_Nd;
395 
396  for (int jcolor = 0; jcolor < m_Nc; ++jcolor) {
397  int cs1 = jcolor + m_Nc * (jspin + m_Nd * ics);
398  int cs2 = jcolor + m_Nc * (jspin + m_Nd * (ics + m_Nc * m_Nd / 2));
399  int cc = jcolor + icolor * m_Nc;
400  int ss1 = jspin + ispin * m_Nd;
401  int ss2 = js2 + ispin * m_Nd;
402 
403  int cs1_r = 2 * cs1;
404  int cs1_i = 2 * cs1 + 1;
405 
406  matrix[cs1_r] = m_T.cmp_r(cc, site, ss1);
407  matrix[cs1_i] = m_T.cmp_i(cc, site, ss1);
408 
409  int cs2_r = 2 * cs2;
410  int cs2_i = 2 * cs2 + 1;
411 
412  matrix[cs2_r] = m_T.cmp_r(cc, site, ss2);
413  matrix[cs2_i] = m_T.cmp_i(cc, site, ss2);
414  }
415  }
416  }
417  }
418 
419  return matrix;
420  }
421 
422 
423 //====================================================================
424  void Fopr_CloverTerm_eo::D(Field& v, const Field& f, const int ieo)
425  {
426  // multiplies [ 1 - csw kappa sigma_{mu nu} F_{mu nu} ]
427  if (m_repr == "Dirac") {
428  D_dirac(v, f, ieo);
429  } else if (m_repr == "Chiral") {
430  D_chiral(v, f, ieo);
431  }
432  }
433 
434 
435 //====================================================================
436  void Fopr_CloverTerm_eo::D_dirac(Field& v, const Field& f, const int ieo)
437  {
438  // multiplies [ 1 - csw kappa sigma_{mu nu} F_{mu nu} ]
439 
440  // assert(f.nvol() == m_Nvol2);
441  // assert(f.nex() == 1);
442  // assert(v.nvol() == m_Nvol2);
443  // assert(v.nex() == 1);
444 
445  const double *fp = f.ptr(0);
446  double *vp = v.ptr(0);
447  double *tp = m_T.ptr(0, m_Nvol2 * ieo, 0);
448 
449  const int Nthread = ThreadManager_OpenMP::get_num_threads();
450  const int i_thread = ThreadManager_OpenMP::get_thread_id();
451  const int is = m_Nvol2 * i_thread / Nthread;
452  const int ns = m_Nvol2 * (i_thread + 1) / Nthread;
453 
454  const int Nvc = 2 * m_Nc;
455  const int Nd2 = m_Nd / 2;
456  const int NinF = 2 * m_Nc * m_Nd;
457  const int NinG = 2 * m_Nc * m_Nc;
458 
459  for (int site = is; site < ns; ++site) {
460  for (int id = 0; id < Nd2; ++id) {
461  for (int ic = 0; ic < m_Nc; ++ic) {
462  int icd = ic + m_Nc * id;
463 
464  int iv2 = 2 * icd + NinF * site;
465  vp[iv2] = 0.0;
466  vp[iv2 + 1] = 0.0;
467  for (int jd = 0; jd < m_Nd; ++jd) {
468  int iv = Nvc * jd + NinF * site;
469  int ig = Nvc * ic + NinG * (site + m_Nvol * (id * m_Nd + jd));
470 
471  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
472  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
473  }
474 
475  iv2 += Nvc * Nd2;
476  vp[iv2] = 0.0;
477  vp[iv2 + 1] = 0.0;
478  for (int jd = 0; jd < m_Nd; ++jd) {
479  int jd2 = (2 + jd) % m_Nd;
480  int iv = Nvc * jd + NinF * site;
481  int ig = Nvc * ic + NinG * (site + m_Nvol * (id * m_Nd + jd2));
482 
483  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
484  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
485  }
486  }
487  }
488  }
489 #pragma omp barrier
490  }
491 
492 
493 //====================================================================
495  const Field& f, const int ieo)
496  {
497  // multiplies [ 1 - csw kappa sigma_{mu nu} F_{mu nu} ]
498 
499  const double *fp = f.ptr(0);
500  double *vp = v.ptr(0);
501  double *tp = m_T.ptr(0, m_Nvol2 * ieo, 0);
502 
503  const int Nthread = ThreadManager_OpenMP::get_num_threads();
504  const int i_thread = ThreadManager_OpenMP::get_thread_id();
505  const int is = m_Nvol2 * i_thread / Nthread;
506  const int ns = m_Nvol2 * (i_thread + 1) / Nthread;
507 
508  const int Nvc = 2 * m_Nc;
509  const int Nd2 = m_Nd / 2;
510  const int NinF = 2 * m_Nc * m_Nd;
511  const int NinG = 2 * m_Nc * m_Nc;
512 
513  for (int site = is; site < ns; ++site) {
514  for (int id = 0; id < Nd2; ++id) {
515  for (int ic = 0; ic < m_Nc; ++ic) {
516  int icd = ic + m_Nc * id;
517 
518  int iv2 = 2 * icd + NinF * site;
519  vp[iv2] = 0.0;
520  vp[iv2 + 1] = 0.0;
521  for (int jd = 0; jd < Nd2; ++jd) {
522  int iv = Nvc * jd + NinF * site;
523  int ig = Nvc * ic + NinG * (site + m_Nvol * (id * Nd2 + jd));
524 
525  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
526  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
527  }
528 
529  iv2 += Nvc * Nd2;
530  vp[iv2] = 0.0;
531  vp[iv2 + 1] = 0.0;
532  for (int jd = 0; jd < Nd2; ++jd) {
533  int iv = Nvc * (Nd2 + jd) + NinF * site;
534  int ig = Nvc * ic + NinG * (site + m_Nvol * (m_Nd + id * Nd2 + jd));
535 
536  vp[iv2] += mult_uv_r(&tp[ig], &fp[iv], m_Nc);
537  vp[iv2 + 1] += mult_uv_i(&tp[ig], &fp[iv], m_Nc);
538  }
539  }
540  }
541  }
542 #pragma omp barrier
543  }
544 
545 
546 //====================================================================
548  const Field_F& w, const int mu, const int nu)
549  {
550  assert(mu != nu);
551  mult_iGM(v, m_SG[sg_index(mu, nu)], w);
552  }
553 
554 
555 //====================================================================
557  {
558  if (m_repr == "Dirac") {
559  set_csw_dirac();
560  } else if (m_repr == "Chiral") {
561  set_csw_chiral();
562  } else {
563  vout.crucial(m_vl, "Error at %s: unsupported gamma matrix repr. %s.\n",
564  class_name.c_str(), m_repr.c_str());
565  exit(EXIT_FAILURE);
566  }
567  }
568 
569 
570 //====================================================================
572  {
573  // The clover term in the Dirac representation is as spin-space
574  // matrix
575  // [ P Q ]
576  // [ Q P ],
577  // where P and Q are 2x2 block matrices as
578  // P = [ iF(1,2) F(3,1) + iF(2,3) ]
579  // [-F(3,1) + iF(2,3) - iF(1,2) ]
580  // and
581  // Q = [ - iF(4,3) -F(4,2) - iF(4,1) ]
582  // [ F(4,2) - iF(4,1) iF(4,3) ]
583  // up to the coefficient.
584  // in the following what defined is
585  // [ P Q ] = [ T(0) T(1) T(2) T(3) ]
586  // [ T(4) T(5) T(6) T(7) ].
587 
588  m_T.set(0.0);
589 
590  //- sigma23
591  Field_G F;
592  set_fieldstrength(F, 1, 2);
593  F.xI();
594  axpy(m_T, 1, 1.0, F, 0);
595  axpy(m_T, 4, 1.0, F, 0);
596 
597  //- sigma31
598  set_fieldstrength(F, 2, 0);
599  axpy(m_T, 1, 1.0, F, 0);
600  axpy(m_T, 4, -1.0, F, 0);
601 
602  //- sigma12
603  set_fieldstrength(F, 0, 1);
604  F.xI();
605  axpy(m_T, 0, 1.0, F, 0);
606  axpy(m_T, 5, -1.0, F, 0);
607 
608  //- sigma41
609  set_fieldstrength(F, 3, 0);
610  F.xI();
611  axpy(m_T, 3, -1.0, F, 0);
612  axpy(m_T, 6, -1.0, F, 0);
613 
614  //- sigma42
615  set_fieldstrength(F, 3, 1);
616  axpy(m_T, 3, -1.0, F, 0);
617  axpy(m_T, 6, 1.0, F, 0);
618 
619  //- sigma43
620  set_fieldstrength(F, 3, 2);
621  F.xI();
622  axpy(m_T, 2, -1.0, F, 0);
623  axpy(m_T, 7, 1.0, F, 0);
624 
625  scal(m_T, -m_kappa * m_cSW);
626 
627  Field_G Unity;
628  Unity.set_unit();
629  axpy(m_T, 0, 1.0, Unity, 0);
630  axpy(m_T, 5, 1.0, Unity, 0);
631  }
632 
633 
634 //====================================================================
636  {
637  // The clover term in the Dirac representation is
638  // as spin-space matrix
639  // [ P+Q 0 ]
640  // [ 0 P-Q ],
641  // where P and Q are 2x2 block matrices as
642  // [ iF(1,2) | F(3,1) + iF(2,3) ]
643  // P = [ -----------------+------------------ ]
644  // [-F(3,1) + iF(2,3) | - iF(1,2) ]
645  // and
646  // [ - iF(4,3) | -F(4,2) - iF(4,1) ]
647  // Q = [ -----------------+------------------ ]
648  // [ F(4,2) - iF(4,1) | iF(4,3) ]
649  // up to the coefficient.
650  // in the following what defined is
651  // [ T(0) | T(1) ] [ T(4) | T(5) ]
652  // P+Q = [ -----+----- ] P - Q = [ -----+----- ]
653  // [ T(2) | T(3) ] [ T(6) | T(7) ]
654 
655  m_T.set(0.0);
656 
657  Field_G F;
658 
659  //- sigma23
660  set_fieldstrength(F, 1, 2);
661  F.xI();
662  axpy(m_T, 1, 1.0, F, 0);
663  axpy(m_T, 2, 1.0, F, 0);
664  axpy(m_T, 5, 1.0, F, 0);
665  axpy(m_T, 6, 1.0, F, 0);
666 
667  //- sigma31
668  set_fieldstrength(F, 2, 0);
669  axpy(m_T, 1, 1.0, F, 0);
670  axpy(m_T, 2, -1.0, F, 0);
671  axpy(m_T, 5, 1.0, F, 0);
672  axpy(m_T, 6, -1.0, F, 0);
673 
674  //- sigma12
675  set_fieldstrength(F, 0, 1);
676  F.xI();
677  axpy(m_T, 0, 1.0, F, 0);
678  axpy(m_T, 3, -1.0, F, 0);
679  axpy(m_T, 4, 1.0, F, 0);
680  axpy(m_T, 7, -1.0, F, 0);
681 
682  //- sigma41
683  set_fieldstrength(F, 3, 0);
684  F.xI();
685  axpy(m_T, 1, -1.0, F, 0);
686  axpy(m_T, 2, -1.0, F, 0);
687  axpy(m_T, 5, 1.0, F, 0);
688  axpy(m_T, 6, 1.0, F, 0);
689 
690  //- sigma42
691  set_fieldstrength(F, 3, 1);
692  axpy(m_T, 1, -1.0, F, 0);
693  axpy(m_T, 2, 1.0, F, 0);
694  axpy(m_T, 5, 1.0, F, 0);
695  axpy(m_T, 6, -1.0, F, 0);
696 
697  //- sigma43
698  set_fieldstrength(F, 3, 2);
699  F.xI();
700  axpy(m_T, 0, -1.0, F, 0);
701  axpy(m_T, 3, 1.0, F, 0);
702  axpy(m_T, 4, 1.0, F, 0);
703  axpy(m_T, 7, -1.0, F, 0);
704 
705  scal(m_T, -m_kappa * m_cSW);
706 
707  Field_G Unity;
708  Unity.set_unit();
709  axpy(m_T, 0, 1.0, Unity, 0);
710  axpy(m_T, 3, 1.0, Unity, 0);
711  axpy(m_T, 4, 1.0, Unity, 0);
712  axpy(m_T, 7, 1.0, Unity, 0);
713  }
714 
715 
716 //====================================================================
718  const int mu, const int nu)
719  {
720  // Staple_eo staple;
721  unique_ptr<Staple> staple(Staple::New("EvenOdd"));
722 
723  Field_G Cup;
724  staple->upper(Cup, *m_Ueo, mu, nu);
725 
726  Field_G Cdn;
727  staple->lower(Cdn, *m_Ueo, mu, nu);
728 
729  Field_G Umu;
730  Umu.setpart_ex(0, *m_Ueo, mu);
731 
732  Field_G w;
733  for (int site = 0; site < m_Nvol; ++site) {
734  w.set_mat(site, 0, Umu.mat(site) * Cup.mat_dag(site));
735  }
736 
737  Field_G v2;
738  for (int site = 0; site < m_Nvol; ++site) {
739  v2.set_mat(site, 0, Umu.mat(site) * Cdn.mat_dag(site));
740  }
741 
742  axpy(w, -1.0, v2);
743 
744  Field_G v;
745  for (int site = 0; site < m_Nvol; ++site) {
746  v.set_mat(site, 0, Cup.mat_dag(site) * Umu.mat(site));
747  }
748 
749  for (int site = 0; site < m_Nvol; ++site) {
750  v2.set_mat(site, 0, Cdn.mat_dag(site) * Umu.mat(site));
751  }
752 
753  axpy(v, -1.0, v2);
754 
755  m_shift_eo.forward(v2, v, mu);
756 
757  axpy(w, 1.0, v2);
758 
759  for (int site = 0; site < m_Nvol; ++site) {
760  Fst.set_mat(site, 0, w.mat(site).ah());
761  }
762 
763  scal(Fst, 0.25);
764  }
765 
766 
767 //====================================================================
769  const int mu, const int nu)
770  {
771  const int nex_finv = m_fee_inv->nex();
772 
773  assert(tr_sigma_inv.nvol() == m_Nvol);
774  assert(tr_sigma_inv.nex() == 1);
775 
776  Field_F sigma_inv(m_Nvol, nex_finv);
777  {
778  Field_F sigma_eo_inv(m_Nvol2, nex_finv);
779  mult_isigma(sigma_eo_inv, *m_fee_inv, mu, nu);
780  m_idx.reverseField(sigma_inv, sigma_eo_inv, 0);
781 
782  mult_isigma(sigma_eo_inv, *m_foo_inv, mu, nu);
783  m_idx.reverseField(sigma_inv, sigma_eo_inv, 1);
784  }
785 
786  for (int isite = 0; isite < m_Nvol; ++isite) {
787  for (int ispin = 0; ispin < m_Nd; ++ispin) {
788  for (int icolor = 0; icolor < m_Nc; ++icolor) {
789  Vec_SU_N v = sigma_inv.vec(ispin, isite, icolor + m_Nc * ispin);
790 
791  for (int jcolor = 0; jcolor < m_Nc; ++jcolor) {
792  int cc = icolor + m_Nc * jcolor;
793 
794  tr_sigma_inv.set_r(cc, isite, 0, v.r(jcolor));
795  tr_sigma_inv.set_i(cc, isite, 0, v.i(jcolor));
796  }
797  }
798  }
799  }
800  }
801 
802 
803 //====================================================================
805  {
806  // Counting of floating point operations in giga unit.
807  // The following counting explicitly depends on the implementation
808  // and to be recalculated when the code is modified.
809  // Present counting is based on rev.1107. [24 Aug 2014 H.Matsufuru]
810 
811  const int Nvol = CommonParameters::Nvol();
812  const int NPE = CommonParameters::NPE();
813 
814  int flop_site = 0; // superficial initialization
815 
816  if (m_repr == "Dirac") {
817  flop_site = 8 * m_Nc * m_Nc * m_Nd * m_Nd;
818  } else if (m_repr == "Chiral") {
819  flop_site = 4 * m_Nc * m_Nc * m_Nd * m_Nd;
820  }
821 
822  const double gflop = flop_site * ((Nvol / 2) * (NPE / 1.0e+9));
823 
824  return gflop;
825  }
826 
827 
828 //====================================================================
829 }
830 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:433
void mult_csw_inv_dirac(Field &, const Field &, const int ieo)
void D(Field &v, const Field &f, const int ieo)
BridgeIO vout
Definition: bridgeIO.cpp:503
double cmp_i(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:100
void detailed(const char *format,...)
Definition: bridgeIO.cpp:216
static int get_num_threads()
returns available number of threads.
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
virtual void upper(Field_G &, const Field_G &, const int mu, const int nu)=0
constructs upper staple in mu-nu plane.
double r(const int c) const
Definition: vec_SU_N.h:65
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
virtual void lower(Field_G &, const Field_G &, const int mu, const int nu)=0
constructs lower staple in mu-nu plane.
void set_mode(const std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
std::vector< GammaMatrix > m_SG
void general(const char *format,...)
Definition: bridgeIO.cpp:197
GammaMatrix get_GM(GMspecies spec)
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
int solver(const std::string &)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
Definition: solver_CG.cpp:112
std::vector< GammaMatrix > m_GM
Gamma Matrix and Sigma_{mu,nu} = -i [Gamma_mu, Gamma_nu] /2.
Container of Field-type object.
Definition: field.h:45
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:127
double cmp_i(const int cc, const int site, const int mn=0) const
Definition: field_G.h:92
Class for parameters.
Definition: parameters.h:46
Standard Conjugate Gradient solver algorithm.
Definition: solver_CG.h:38
void set_csw_chiral()
explicit implementation for Chiral representation (for Imp-version).
static int get_thread_id()
returns thread id.
Wilson-type fermion field.
Definition: field_F.h:37
void trSigmaInv(Field_G &, const int mu, const int nu)
int sg_index(const int mu, const int nu)
void set_unit()
Definition: field_G_imp.cpp:37
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
void set_fieldstrength(Field_G &, const int, const int)
SU(N) gauge field.
Definition: field_G.h:38
static double epsilon_criterion2()
void reset(int Nvol, int Nex)
Definition: field_F.h:80
void mult_csw_inv_chiral(Field &, const Field &, const int ieo)
void mult_iGM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication (i is multiplied)
double i(const int c) const
Definition: vec_SU_N.h:67
void set_parameters(const Parameters &params)
Definition: solver_CG.cpp:25
void set_ri(const int cc, const int s, const int site, const int e, const double re, const double im)
Definition: field_F.h:116
Bridge::VerboseLevel m_vl
Definition: fopr.h:127
double flop_count()
returns number of floating point operations.
void set_i(const int cc, const int site, const int mn, const double im)
Definition: field_G.h:102
Mat_SU_N & ah()
antihermitian
Definition: mat_SU_N.h:357
void init(const std::string repr)
int nex() const
Definition: field.h:128
std::vector< double > csmatrix(const int &)
void mult_isigma(Field_F &, const Field_F &, const int mu, const int nu)
void set_r(const int cc, const int site, const int mn, const double re)
Definition: field_G.h:97
void mult_csw_inv(Field &, const Field &, const int ieo)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
static const std::string class_name
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:112
void set_config(Field *Ueo)
setting pointer to the gauge configuration.
void forward(Field &, const Field &, const int mu)
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
void set_csw_dirac()
explicit implementation for Dirac representation (for Imp-version).
double cmp_r(const int cc, const int site, const int mn=0) const
Definition: field_G.h:87
Field_G m_T
m_T = 1 - kappa c_SW sigma F / 2
void D_dirac(Field &v, const Field &f, const int ieo)
explicit implementation for Dirac representation (for Imp-version).
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:197
void set_parameter_verboselevel(const Bridge::VerboseLevel vl)
Definition: solver.h:53
string get_string(const string &key) const
Definition: parameters.cpp:221
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
void set_mat(const int site, const int mn, const Mat_SU_N &U)
Definition: field_G.h:160
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131
void D_chiral(Field &v, const Field &f, const int ieo)
explicit implementation for Chiral representation (for Imp-version).
void xI()
Definition: field_G.h:184
double cmp_r(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:94