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