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