Bridge++  Ver. 2.0.2
afopr_Domainwall_eo-tmpl.h
Go to the documentation of this file.
1 
11 
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <assert.h>
15 using namespace std;
16 
20 
21 template<typename AFIELD>
23  = "AFopr_Domainwall_eo";
24 
25 //====================================================================
26 template<typename AFIELD>
28 {
29  int Nc = CommonParameters::Nc();
30  int Nd = CommonParameters::Nd();
31  m_NinF = 2 * Nc * Nd;
32 
33  m_Nvol = CommonParameters::Nvol();
34  m_Nvol2 = m_Nvol / 2;
35  m_Ndim = CommonParameters::Ndim();
36 
37  // setup verbose level
38  string vlevel = params.get_string("verbose_level");
39  m_vl = vout.set_verbose_level(vlevel);
40 
41  vout.general(m_vl, "%s: Initialization start\n", class_name.c_str());
42  int err = 0;
43 
44  // setup kernel operator
45  std::string kernel_type;
46  err += params.fetch_string("kernel_type", kernel_type);
47  if (err > 0) {
48  vout.crucial(m_vl, "Error at %s: kernel_type is not specified.\n",
49  class_name.c_str());
50  exit(EXIT_FAILURE);
51  }
52  kernel_type += "_eo";
53 
54  Parameters params_kernel = params;
55  double M0;
56  err += params.fetch_double("domain_wall_height", M0);
57  if (err > 0) {
58  vout.crucial(m_vl, "Error at %s: domain_wall_height is not specified.\n",
59  class_name.c_str());
60  exit(EXIT_FAILURE);
61  }
62  m_M0 = real_t(M0);
63 
64  double kappa = 1.0 / (8.0 - 2.0 * M0);
65  params_kernel.set_double("hopping_parameter", kappa);
66 
67  // Factory is assumed to work
68  m_foprw = AFopr<AFIELD>::New(kernel_type, params_kernel);
69  m_foprw->set_mode("D");
70 
71  m_Ns = 0;
72 
73  set_parameters(params);
74 
75  m_w4.reset(m_NinF, m_Nvol2, 1);
76  m_v4.reset(m_NinF, m_Nvol2, 1);
77  m_y4.reset(m_NinF, m_Nvol2, 1);
78  m_t4.reset(m_NinF, m_Nvol2, 1);
79 
80  if (needs_convert()) {
81  m_w4lex.reset(m_NinF, m_Nvol, 1);
82  m_v4lex.reset(m_NinF, m_Nvol, 1);
83  }
84 
85  m_index_eo = new Index_eo_Domainwall<AFIELD>;
86 
87 }
88 
89 
90 //====================================================================
91 template<typename AFIELD>
93 {
94  delete m_foprw;
95  delete m_index_eo;
96 }
97 
98 
99 //====================================================================
100 template<typename AFIELD>
102  const Parameters& params)
103 {
104  const string str_vlevel = params.get_string("verbose_level");
105  m_vl = vout.set_verbose_level(str_vlevel);
106 
107  //- fetch and check input parameters
108  string gmset_type;
109  double mq, M0;
110  int Ns;
111  std::vector<int> bc;
112  double b, c;
113 
114  int err_optional = 0;
115  err_optional += params.fetch_string("gamma_matrix_type", gmset_type);
116 
117  int err = 0;
118  err += params.fetch_double("quark_mass", mq);
119  err += params.fetch_double("domain_wall_height", M0);
120  err += params.fetch_int("extent_of_5th_dimension", Ns);
121  err += params.fetch_int_vector("boundary_condition", bc);
122  err += params.fetch_double("coefficient_b", b);
123  err += params.fetch_double("coefficient_c", c);
124 
125  if (err) {
126  vout.crucial(m_vl, "Error at %s: input parameter not found.\n",
127  class_name.c_str());
128  exit(EXIT_FAILURE);
129  }
130 
131  set_parameters(real_t(mq), real_t(M0), Ns, bc, real_t(b), real_t(c));
132 
133  if (real_t(M0) != m_M0) set_kernel_parameters(params);
134 }
135 
136 
137 //====================================================================
138 template<typename AFIELD>
140  const real_t mq,
141  const real_t M0,
142  const int Ns,
143  const std::vector<int> bc,
144  const real_t b,
145  const real_t c)
146 {
147  m_M0 = real_t(M0);
148  m_mq = real_t(mq);
149  m_Ns = Ns;
150 
151  m_boundary.resize(m_Ndim);
152  assert(bc.size() == m_Ndim);
153  for (int mu = 0; mu < m_Ndim; ++mu) {
154  m_boundary[mu] = bc[mu];
155  }
156 
157  if (m_b.size() != m_Ns) {
158  m_b.resize(m_Ns);
159  m_c.resize(m_Ns);
160  }
161  for (int is = 0; is < m_Ns; ++is) {
162  m_b[is] = real_t(b);
163  m_c[is] = real_t(c);
164  }
165 
166  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
167  vout.general(m_vl, " mq = %8.4f\n", m_mq);
168  vout.general(m_vl, " M0 = %8.4f\n", m_M0);
169  vout.general(m_vl, " Ns = %4d\n", m_Ns);
170  for (int mu = 0; mu < m_Ndim; ++mu) {
171  vout.general(m_vl, " boundary[%d] = %2d\n", mu, m_boundary[mu]);
172  }
173  //vout.general(m_vl, " coefficients b = %16.10f c = %16.10f\n",
174  // m_b[0], m_c[0]);
175  vout.general(m_vl, " coefficients:\n");
176  for (int is = 0; is < m_Ns; ++is) {
177  vout.general(m_vl, " b[%2d] = %16.10f c[%2d] = %16.10f\n",
178  is, m_b[is], is, m_c[is]);
179  }
180 
181 
182  set_precond_parameters();
183 
184  // working 5d vectors.
185  if (m_w1.nex() != Ns) {
186  m_w1.reset(m_NinF, m_Nvol2, m_Ns);
187  m_v1.reset(m_NinF, m_Nvol2, m_Ns);
188  m_v2.reset(m_NinF, m_Nvol2, m_Ns);
189  }
190 }
191 
192 
193 //====================================================================
194 template<typename AFIELD>
196  const Parameters& params)
197 {
198  Parameters params_kernel = params;
199 
200  double M0;
201  params.fetch_double("domain_wall_height", M0);
202 
203  double kappa = 1.0 / (8.0 - 2.0 * M0);
204  params_kernel.set_double("hopping_parameter", kappa);
205 
206  m_foprw->set_parameters(params_kernel);
207 }
208 
209 
210 //====================================================================
211 template<typename AFIELD>
213 {
214  if (m_dp.size() != m_Ns) {
215  m_dp.resize(m_Ns);
216  m_dm.resize(m_Ns);
217  m_e.resize(m_Ns - 1);
218  m_f.resize(m_Ns - 1);
219  }
220 
221  for (int is = 0; is < m_Ns; ++is) {
222  m_dp[is] = 1.0 + m_b[is] * (4.0 - m_M0);
223  m_dm[is] = 1.0 - m_c[is] * (4.0 - m_M0);
224  }
225 
226  m_e[0] = m_mq * m_dm[m_Ns - 1] / m_dp[0];
227  m_f[0] = m_mq * m_dm[0];
228  for (int is = 1; is < m_Ns - 1; ++is) {
229  m_e[is] = m_e[is - 1] * m_dm[is - 1] / m_dp[is];
230  m_f[is] = m_f[is - 1] * m_dm[is] / m_dp[is - 1];
231  }
232 
233  m_g = m_e[m_Ns - 2] * m_dm[m_Ns - 2];
234 }
235 
236 
237 //====================================================================
238 template<typename AFIELD>
240  const std::vector<real_t> vec_b,
241  const std::vector<real_t> vec_c)
242 {
243  if ((vec_b.size() != m_Ns) || (vec_c.size() != m_Ns)) {
244  vout.crucial(m_vl, "%s: size of coefficient vectors incorrect.\n",
245  class_name.c_str());
246  }
247 
248  vout.general(m_vl, "%s: coefficient vectors are set:\n",
249  class_name.c_str());
250 
251  for (int is = 0; is < m_Ns; ++is) {
252  m_b[is] = vec_b[is];
253  m_c[is] = vec_c[is];
254  vout.general(m_vl, "b[%2d] = %16.10f c[%2d] = %16.10f\n",
255  is, m_b[is], is, m_c[is]);
256  }
257 
258  set_precond_parameters();
259 }
260 
261 
262 //====================================================================
263 template<typename AFIELD>
265 {
266  if (!needs_convert()) {
267  vout.crucial(m_vl, "%s: convert is not necessary.\n",
268  class_name.c_str());
269  exit(EXIT_FAILURE);
270  }
271 
272 #pragma omp barrier
273 
274  int Nex = w.nex();
275  for (int ex = 0; ex < Nex; ++ex) {
276  copy(m_w4lex, 0, w, ex);
277  m_foprw->convert(m_v4lex, m_w4lex);
278  copy(v, ex, m_v4lex, 0);
279  }
280 
281 #pragma omp barrier
282 }
283 
284 
285 //====================================================================
286 template<typename AFIELD>
288 {
289  if (!needs_convert()) {
290  vout.crucial(m_vl, "%s: convert is not necessary.\n",
291  class_name.c_str());
292  exit(EXIT_FAILURE);
293  }
294 
295 #pragma omp barrier
296 
297  int Nex = w.nex();
298  for (int ex = 0; ex < Nex; ++ex) {
299  copy(m_v4lex, 0, w, ex);
300  m_foprw->reverse(m_w4lex, m_v4lex);
301  copy(v, ex, m_w4lex, 0);
302  }
303 
304 #pragma omp barrier
305 }
306 
307 
308 //====================================================================
309 template<typename AFIELD>
311 {
312 #pragma omp barrier
313 
314  int ith = ThreadManager::get_thread_id();
315  if (ith == 0) m_mode = mode;
316  vout.paranoiac(m_vl, " mode is set to %s\n", mode.c_str());
317 
318 #pragma omp barrier
319 }
320 
321 
322 //====================================================================
323 template<typename AFIELD>
325 {
326  if (m_mode == "D") {
327  D(v, w);
328  } else if (m_mode == "Ddag") {
329  Ddag(v, w);
330  } else if (m_mode == "DdagD") {
331  DdagD(v, w);
332  } else if (m_mode == "DDdag") {
333  Ddag(m_w1, w);
334  D(v, m_w1);
335  } else if (m_mode == "H") {
336  H(v, w);
337  } else {
338  vout.crucial(m_vl, "mode undeifined in %s.\n", class_name.c_str());
339  vout.crucial(m_vl, "in mult, mode=%s.\n", m_mode.c_str());
340  abort();
341  }
342 }
343 
344 
345 //====================================================================
346 template<typename AFIELD>
348 {
349  if (m_mode == "D") {
350  Ddag(v, w);
351  } else if (m_mode == "Ddag") {
352  D(v, w);
353  } else if (m_mode == "DdagD") {
354  DdagD(v, w);
355  } else if (m_mode == "DDdag") {
356  Ddag(m_w1, w);
357  D(v, m_w1);
358  } else if (m_mode == "H") {
359  Hdag(v, w);
360  } else {
361  vout.crucial(m_vl, "mode undeifined in %s.\n", class_name.c_str());
362  vout.crucial(m_vl, "in mult_dag, mode=%s.\n", m_mode.c_str());
363  abort();
364  }
365 }
366 
367 
368 //====================================================================
369 template<typename AFIELD>
371  std::string mode)
372 {
373  assert(w.check_size(m_NinF, m_Nvol2, m_Ns));
374  assert(v.check_size(m_NinF, m_Nvol2, m_Ns));
375 
376  if (mode == "Deo") {
377  D_eo(v, w, 0);
378  } else if (mode == "Doe") {
379  D_eo(v, w, 1);
380  } else if (mode == "Dee") {
381  D_ee(v, w, 0);
382  } else if (mode == "Doo") {
383  D_ee(v, w, 1);
384  } else if (mode == "Dee_inv") {
385  L_inv(m_v1, w);
386  U_inv(v, m_v1);
387  } else if (mode == "Doo_inv") {
388  L_inv(m_v1, w);
389  U_inv(v, m_v1);
390  } else {
391  std::cout << "mode undeifined in AFopr_Domainwall_eo.\n";
392  abort();
393  }
394 }
395 
396 //====================================================================
397 template<typename AFIELD>
399  // bo = Doo_inv b[odd]
400  // Be = Dee_inv (b[even] - Deo Doo_inv b[odd])
401  // or
402  // bo = Doo_dag_inv b[odd]
403  // Be = b[even] - Doe_dag Doo_dag_inv b[odd]
404  m_index_eo->split(Be, m_w1, b);
405 #pragma omp barrier
406  if(m_mode == "D"){ // D=(1- Dee_inv Deo Doo_inv Doo)
407  L_inv(m_v1, m_w1); // mult(bo, m_w1, "Doo_inv");
408  U_inv(bo, m_v1);
409  D_eo(m_w1, bo, 0); // mult(m_w1, bo, "Deo");
410  axpy(Be, real_t(-1), m_w1);
411  L_inv(m_v1, Be); // mult(Be, Be, "Dee_inv");
412  U_inv(Be, m_v1);
413  } else {
414  Udag_inv(m_v1, m_w1); // Doo_dag_inv
415  Ldag_inv(bo, m_v1);
416  Ddag_eo(m_w1, bo, 0);
417  axpy(Be, real_t(-1), m_w1);
418  }
419 }
420 
421 //====================================================================
422 template<typename AFIELD>
424  {
425  // x[even] = xe
426  // x[odd] = Doo_inv b[odd] - Doo_inv Doe x[even]
427  // = bo - Doo_inv Doe xe
428  // or
429  // x[even] =Dee_dag_inv xe
430  // x[odd] = Doo_dag_inv b[odd] - Doo_dag_inv Deo_dag x[even]
431  // = bo - Doo_dag_inv Doe_dag xe
432 
433  if(m_mode == "D"){ // D=(1- Dee_inv Deo Doo_inv Doo)
434  D_eo(m_w1, xe, 1); // mult(m_w1, xe, "Doe");
435  L_inv(m_v1, m_w1); // mult(m_w1, m_w1, "Doo_inv");
436  U_inv(m_w1, m_v1);
437  aypx(real_t(-1.0), m_w1, bo);
438 #pragma omp barrier
439  m_index_eo->merge(x, xe, m_w1);
440  } else {
441  Udag_inv(m_v1, xe); // Dee_dag_inv
442  Ldag_inv(m_v2, m_v1);
443  Ddag_eo(m_w1, m_v2, 1);
444  Udag_inv(m_v1, m_w1); // Doo_dag_inv
445  Ldag_inv(m_w1, m_v1);
446  aypx(real_t(-1.0), m_w1, bo);
447 #pragma omp barrier
448  m_index_eo->merge(x, m_v2, m_w1);
449  }
450 
451 
452 
453  }
454 
455 //====================================================================
456 template<typename AFIELD>
458 {
459  D_eo(m_v1, w, 1);
460  L_inv(m_v2, m_v1);
461  U_inv(m_v1, m_v2);
462  D_eo(m_v2, m_v1, 0);
463  L_inv(m_v1, m_v2);
464  U_inv(m_v2, m_v1);
465 
466  copy(m_v1, w);
467  axpy(m_v1, real_t(-1.0), m_v2);
468 #pragma omp barrier
469 
470  Udag_inv(v, m_v1);
471  Ldag_inv(m_v2, v);
472  Ddag_eo(v, m_v2, 1);
473  Udag_inv(m_v2, v);
474  Ldag_inv(v, m_v2);
475  Ddag_eo(m_v2, v, 0);
476 
477  copy(v, m_v1);
478  axpy(v, real_t(-1.0), m_v2);
479 #pragma omp barrier
480 }
481 
482 
483 //====================================================================
484 template<typename AFIELD>
486 {
487  D_eo(m_v1, w, 1);
488  L_inv(m_v2, m_v1);
489  U_inv(m_v1, m_v2);
490  D_eo(m_v2, m_v1, 0);
491  L_inv(m_v1, m_v2);
492  U_inv(m_v2, m_v1);
493 
494  copy(v, w);
495  axpy(v, real_t(-1.0), m_v2);
496 #pragma omp barrier
497 }
498 
499 
500 //====================================================================
501 template<typename AFIELD>
503 {
504  D_eo(m_v1, w, 1);
505  L_inv(m_v2, m_v1);
506  U_inv(m_v1, m_v2);
507  D_eo(m_v2, m_v1, 0);
508  L_inv(m_v1, m_v2);
509  U_inv(m_v2, m_v1);
510 
511  copy(m_v1, w);
512  axpy(m_v1, real_t(-1.0), m_v2);
513 #pragma omp barrier
514 
515  mult_gm5R(v, m_v1);
516 
517 }
518 
519 
520 //====================================================================
521 template<typename AFIELD>
523 {
524  assert(w.check_size(m_NinF, m_Nvol2, m_Ns));
525  assert(v.check_size(m_NinF, m_Nvol2, m_Ns));
526 
527  Udag_inv(m_v1, w);
528  Ldag_inv(m_v2, m_v1);
529  Ddag_eo(m_v1, m_v2, 1);
530  Udag_inv(m_v2, m_v1);
531  Ldag_inv(m_v1, m_v2);
532  Ddag_eo(m_v2, m_v1, 0);
533 
534  copy(v, w);
535  axpy(v, real_t(-1.0), m_v2);
536 #pragma omp barrier
537 }
538 
539 
540 //====================================================================
541 template<typename AFIELD>
543 {
544  assert(w.check_size(m_NinF, m_Nvol2, m_Ns));
545  assert(v.check_size(m_NinF, m_Nvol2, m_Ns));
546 
547  mult_gm5R(v, w);
548 
549  Udag_inv(m_v1, v);
550  Ldag_inv(m_v2, m_v1);
551  Ddag_eo(m_v1, m_v2, 1);
552  Udag_inv(m_v2, m_v1);
553  Ldag_inv(m_v1, m_v2);
554  Ddag_eo(m_v2, m_v1, 0);
555 
556  //copy(v, w);
557  axpy(v, real_t(-1.0), m_v2);
558 #pragma omp barrier
559 }
560 
561 
562 //====================================================================
563 template<typename AFIELD>
565 {
566  int Nex = v.nex();
567  assert(Nex == w.nex());
568 
569  // omp barrier at the beginning and end of m_foprw->mult_gm5 is
570  // assumed.
571  if (Nex == 1) {
572  mult_gm5_4d(v, w);
573  } else {
574 #pragma omp barrier
575  for (int ex = 0; ex < Nex; ++ex) {
576  copy(m_w4, 0, w, ex);
577  m_foprw->mult_gm5(m_v4, m_w4);
578  copy(v, ex, m_v4, 0);
579 #pragma omp barrier
580  }
581  }
582 }
583 
584 
585 //====================================================================
586 template<typename AFIELD>
588  const AFIELD& w)
589 {
590  m_foprw->mult_gm5(v, w);
591 }
592 
593 
594 //====================================================================
595 template<typename AFIELD>
597 {
598  assert(w.check_size(m_NinF, m_Nvol2, m_Ns));
599  assert(v.check_size(m_NinF, m_Nvol2, m_Ns));
600 
601 #pragma omp barrier
602 
603  for (int is = 0; is < m_Ns; ++is) {
604  copy(v, m_Ns - 1 - is, w, is);
605  }
606 
607 #pragma omp barrier
608 }
609 
610 
611 //====================================================================
612 template<typename AFIELD>
614 {
615  assert(w.check_size(m_NinF, m_Nvol2, m_Ns));
616  assert(v.check_size(m_NinF, m_Nvol2, m_Ns));
617 
618 #pragma omp barrier
619 
620  for (int is = 0; is < m_Ns; ++is) {
621  copy(m_w4, 0, w, is);
622  mult_gm5_4d(m_v4, m_w4);
623  copy(v, m_Ns - 1 - is, m_v4, 0);
624  }
625 
626 #pragma omp barrier
627 }
628 
629 
630 //====================================================================
631 template<typename AFIELD>
633  const int ieo)
634 { // ieo = 0: even < odd, ieo = 1: odd <- even
635 #pragma omp barrier
636 
637  for (int is = 0; is < m_Ns; ++is) {
638  m_v4.set(0.0);
639  int is_up = (is + 1) % m_Ns;
640  real_t Fup = -0.5;
641  if (is == m_Ns - 1) Fup = m_mq / 2.0;
642  copy(m_y4, 0, w, is_up);
643  mult_gm5_4d(m_t4, m_y4);
644  axpy(m_y4, real_t(-1.0), m_t4);
645  axpy(m_v4, 0, Fup, m_y4, 0); // m_v4 = - P_ w(is+1)
646 
647  int is_dn = (is - 1 + m_Ns) % m_Ns;
648  real_t Fdn = -0.5;
649  if (is == 0) Fdn = m_mq / 2.0;
650  copy(m_y4, 0, w, is_dn);
651  mult_gm5_4d(m_t4, m_y4);
652  axpy(m_y4, real_t(1.0), m_t4);
653  axpy(m_v4, 0, Fdn, m_y4, 0); // m_v4 += - P+ w(is-1)
654 
655  copy(m_w4, 0, w, is);
656 
657  scal(m_w4, m_b[is]);
658  axpy(m_w4, -m_c[is], m_v4);
659 
660  // m_foprw->Meo(m_v4, m_w4, ieo);
661  if (ieo == 0) {
662  m_foprw->mult(m_v4, m_w4, "Deo");
663  } else {
664  m_foprw->mult(m_v4, m_w4, "Doe");
665  }
666 
667  scal(m_v4, real_t(4.0 - m_M0));
668 
669  copy(v, is, m_v4, 0);
670 
671 #pragma omp barrier
672  }
673 }
674 
675 
676 //====================================================================
677 template<typename AFIELD>
679  const int ieo)
680 { // ieo = 0: even < odd, ieo = 1: odd <- even
681 #pragma omp barrier
682 
683  v.set(0.0);
684 
685 #pragma omp barrier
686 
687  for (int is = 0; is < m_Ns; ++is) {
688  copy(m_w4, 0, w, is);
689 
690  // m_foprw->Mdageo(m_v4, m_w4, ieo);
691  mult_gm5_4d(m_v4, m_w4);
692  if (ieo == 0) {
693  m_foprw->mult(m_y4, m_v4, "Deo");
694  } else {
695  m_foprw->mult(m_y4, m_v4, "Doe");
696  }
697  mult_gm5_4d(m_v4, m_y4);
698 
699  scal(m_v4, real_t(4.0 - m_M0));
700  axpy(v, is, m_b[is], m_v4, 0);
701 
702  scal(m_v4, -m_c[is]);
703 
704  int is_up = (is + 1) % m_Ns;
705  real_t Fup = -0.5;
706  if (is_up == 0) Fup = m_mq / 2.0;
707  mult_gm5_4d(m_y4, m_v4);
708  axpy(m_y4, real_t(-1.0), m_v4); // m_y4 = - (1 - gm5) m_v4
709  axpy(v, is_up, -Fup, m_y4, 0);
710 
711  int is_dn = (is - 1 + m_Ns) % m_Ns;
712  real_t Fdn = -0.5;
713  if (is_dn == m_Ns - 1) Fdn = m_mq / 2.0;
714  mult_gm5_4d(m_y4, m_v4);
715  axpy(m_y4, real_t(1.0), m_v4); // m_y4 = (1 + gm5) m_v4
716  axpy(v, is_dn, Fdn, m_y4, 0);
717 
718 #pragma omp barrier
719  }
720 }
721 
722 
723 //====================================================================
724 template<typename AFIELD>
726  const int ieo)
727 { // ieo = 0: even, ieo = 1: odd (but they are identical)
728 #pragma omp barrier
729 
730  for (int is = 0; is < m_Ns; ++is) {
731  m_v4.set(0.0);
732  int is_up = (is + 1) % m_Ns;
733  real_t Fup = -0.5;
734  if (is == m_Ns - 1) Fup = m_mq / 2.0;
735  copy(m_y4, 0, w, is_up);
736  mult_gm5_4d(m_t4, m_y4);
737  axpy(m_y4, real_t(-1.0), m_t4);
738  axpy(m_v4, 0, Fup, m_y4, 0);
739 
740  int is_dn = (is - 1 + m_Ns) % m_Ns;
741  real_t Fdn = -0.5;
742  if (is == 0) Fdn = m_mq / 2.0;
743  copy(m_y4, 0, w, is_dn);
744  mult_gm5_4d(m_t4, m_y4);
745  axpy(m_y4, real_t(1.0), m_t4);
746  axpy(m_v4, 0, Fdn, m_y4, 0);
747 
748  copy(m_w4, 0, w, is);
749  copy(m_t4, m_w4);
750  axpy(m_t4, real_t(1.0), m_v4);
751 
752  scal(m_w4, m_b[is]);
753  axpy(m_w4, -m_c[is], m_v4);
754  axpy(m_t4, real_t(4.0) - m_M0, m_w4);
755 
756  copy(v, is, m_t4, 0);
757 
758 #pragma omp barrier
759  }
760 }
761 
762 
763 //====================================================================
764 template<typename AFIELD>
766 {
767 #pragma omp barrier
768 
769  copy(v, 0, w, 0);
770  copy(m_y4, 0, w, 0);
771  scal(m_y4, m_e[0]);
772 
773 #pragma omp barrier
774 
775  for (int is = 1; is < m_Ns - 1; ++is) {
776  copy(v, is, w, is);
777 
778  copy(m_v4, 0, v, is - 1);
779  mult_gm5_4d(m_w4, m_v4);
780  axpy(m_v4, real_t(1.0), m_w4);
781  scal(m_v4, real_t(0.5) * m_dm[is] / m_dp[is - 1]);
782 
783  axpy(v, is, real_t(1.0), m_v4, 0);
784  copy(m_w4, 0, v, is);
785  axpy(m_y4, m_e[is], m_w4);
786 
787 #pragma omp barrier
788  }
789 
790  int is = m_Ns - 1;
791  copy(v, is, w, is);
792  copy(m_v4, 0, v, is - 1);
793  mult_gm5_4d(m_w4, m_v4);
794  axpy(m_v4, real_t(1.0), m_w4);
795  scal(m_v4, real_t(0.5) * m_dm[is] / m_dp[is - 1]);
796 
797  axpy(v, is, real_t(1.0), m_v4, 0);
798 
799  mult_gm5_4d(m_w4, m_y4);
800  axpy(m_y4, real_t(-1.0), m_w4);
801  scal(m_y4, real_t(-0.5));
802  axpy(v, is, real_t(1.0), m_y4, 0);
803 
804 #pragma omp barrier
805 }
806 
807 
808 //====================================================================
809 template<typename AFIELD>
811 {
812 #pragma omp barrier
813 
814  int is = m_Ns - 1;
815  copy(m_y4, 0, w, is);
816  scal(m_y4, real_t(1.0) / (m_dp[is] + m_g));
817  copy(v, is, m_y4, 0);
818 
819  mult_gm5_4d(m_w4, m_y4);
820  axpy(m_y4, real_t(1.0), m_w4);
821  scal(m_y4, real_t(0.5));
822 
823 #pragma omp barrier
824 
825  for (int is = m_Ns - 2; is >= 0; --is) {
826  copy(m_v4, 0, w, is);
827 
828  copy(m_w4, 0, v, is + 1);
829  mult_gm5_4d(m_t4, m_w4);
830  axpy(m_w4, real_t(-1.0), m_t4);
831 
832  axpy(m_v4, real_t(0.5) * m_dm[is], m_w4);
833 
834  axpy(m_v4, -m_f[is], m_y4);
835 
836  scal(m_v4, real_t(1.0) / m_dp[is]);
837 
838  copy(v, is, m_v4, 0);
839 
840 #pragma omp barrier
841  }
842 }
843 
844 
845 //====================================================================
846 template<typename AFIELD>
848 {
849 #pragma omp barrier
850 
851  copy(m_v4, 0, w, 0);
852  scal(m_v4, real_t(1.0) / m_dp[0]);
853  copy(v, 0, m_v4, 0);
854 
855  copy(m_y4, m_v4);
856  scal(m_y4, m_f[0]);
857 
858 #pragma omp barrier
859 
860  for (int is = 1; is < m_Ns - 1; ++is) {
861  copy(m_t4, 0, w, is);
862 
863  copy(m_v4, 0, v, is - 1);
864  mult_gm5_4d(m_w4, m_v4);
865  axpy(m_v4, real_t(-1.0), m_w4);
866  axpy(m_t4, real_t(0.5) * m_dm[is - 1], m_v4);
867 
868  scal(m_t4, real_t(1.0) / m_dp[is]);
869  copy(v, is, m_t4, 0);
870 
871  axpy(m_y4, m_f[is], m_t4);
872 
873 #pragma omp barrier
874  }
875 
876  int is = m_Ns - 1;
877 
878  copy(m_t4, 0, w, is);
879 
880  copy(m_v4, 0, v, is - 1);
881  mult_gm5_4d(m_w4, m_v4);
882  axpy(m_v4, real_t(-1.0), m_w4);
883  axpy(m_t4, real_t(0.5) * m_dm[is - 1], m_v4);
884 
885  mult_gm5_4d(m_w4, m_y4);
886  axpy(m_y4, real_t(1.0), m_w4);
887  scal(m_y4, real_t(0.5));
888 
889  axpy(m_t4, real_t(-1.0), m_y4);
890 
891  scal(m_t4, real_t(1.0) / (m_dp[is] + m_g));
892  copy(v, is, m_t4, 0);
893 
894 #pragma omp barrier
895 }
896 
897 
898 //====================================================================
899 template<typename AFIELD>
901 {
902 #pragma omp barrier
903 
904  int is = m_Ns - 1;
905  copy(v, is, w, is);
906 
907  copy(m_y4, 0, w, is);
908  mult_gm5_4d(m_t4, m_y4);
909  axpy(m_y4, real_t(-1.0), m_t4);
910  scal(m_y4, real_t(0.5));
911 
912 #pragma omp barrier
913 
914  for (int is = m_Ns - 2; is >= 0; --is) {
915  copy(v, is, w, is);
916 
917  copy(m_v4, 0, v, is + 1);
918  mult_gm5_4d(m_t4, m_v4);
919  axpy(m_v4, real_t(1.0), m_t4);
920  scal(m_v4, real_t(0.5) * m_dm[is + 1] / m_dp[is]);
921 
922  axpy(m_v4, -m_e[is], m_y4);
923 
924  axpy(v, is, real_t(1.0), m_v4, 0);
925 
926 #pragma omp barrier
927  }
928 }
929 
930 
931 //====================================================================
932 template<typename AFIELD>
934 {
935  int Lvol2 = CommonParameters::Lvol() / 2;
936  double vsite = static_cast<double>(Lvol2);
937  double vNs = static_cast<double>(m_Ns);
938 
939  double flop_Wilson = m_foprw->flop_count("Deo");
940  // double flop_Wilson = m_foprw->flop_count("Meo");
941  // double flop_Wilson = m_foprw->flop_count();
942 
943  double axpy1 = static_cast<double>(2 * m_NinF) * vsite;
944  double scal1 = static_cast<double>(1 * m_NinF) * vsite;
945 
946  double flop_Deo = (flop_Wilson + 5.0 * axpy1 + 2.0 * scal1) * vNs;
947 
948  double flop_Dee = vNs * (7.0 * axpy1 + scal1);
949 
950  double flop_LU_inv =
951  2.0 * ((3.0 * axpy1 + scal1) * (vNs - 1.0) + axpy1 + 2.0 * scal1);
952 
953  double flop = 0.0;
954  if ((mode == "Meo") || (mode == "Moe")) {
955  flop = flop_Deo + flop_LU_inv;
956  } else if ((mode == "Dee_inv") || (mode == "Doo_inv")) {
957  flop = flop_LU_inv;
958  } else if ((mode == "Deo") || (mode == "Doe")) {
959  flop = flop_Deo;
960  } else if ((mode == "Dee") || (mode == "Doo")) {
961  flop = flop_Dee;
962  } else if ((mode == "D") || (mode == "Ddag")) {
963  flop = 2.0 * (flop_LU_inv + flop_Deo) + vNs * axpy1;
964  } else if (mode == "DdagD") {
965  flop = 2.0 * (2.0 * (flop_LU_inv + flop_Deo) + vNs * axpy1);
966  } else {
967  vout.crucial(m_vl, "Error at %s: input mode %s is undefined.\n",
968  class_name.c_str(), mode.c_str());
969  exit(EXIT_FAILURE);
970  }
971 
972  return flop;
973 }
974 
975 
976 //============================================================END=====
AFopr_Domainwall_eo::preProp
void preProp(AFIELD &Be, AFIELD &bo, const AFIELD &b)
Definition: afopr_Domainwall_eo-tmpl.h:398
AFopr_Domainwall_eo::Udag_inv
void Udag_inv(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:847
AFopr_Domainwall_eo::init
void init(const Parameters &params)
initial setup.
Definition: afopr_Domainwall_eo-tmpl.h:27
CommonParameters::Lvol
static long_t Lvol()
Definition: commonParameters.h:95
AFopr_Domainwall_eo::flop_count
double flop_count()
this returns the number of floating point number operations.
Definition: afopr_Domainwall_eo.h:173
AFopr_Domainwall_eo::set_parameters
void set_parameters(const Parameters &params)
sets parameters by a Parameter object: to be implemented in a subclass.
Definition: afopr_Domainwall_eo-tmpl.h:101
AFopr_Domainwall_eo::H
void H(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:502
AFopr_Domainwall_eo::D
void D(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:485
AFopr
Definition: afopr.h:48
AFopr_Domainwall_eo::Hdag
void Hdag(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:542
CommonParameters::Ndim
static int Ndim()
Definition: commonParameters.h:117
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
AFopr_Domainwall_eo::D_ee
void D_ee(AFIELD &, const AFIELD &, const int ieo)
Definition: afopr_Domainwall_eo-tmpl.h:725
Parameters::set_double
void set_double(const string &key, const double value)
Definition: parameters.cpp:33
AFopr_Domainwall_eo::mult_R
void mult_R(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:596
Field::nex
int nex() const
Definition: field.h:128
Field::check_size
bool check_size(const int nin, const int nvol, const int nex) const
checking size parameters. [23 May 2016 H.Matsufuru]
Definition: field.h:135
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
aypx
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Definition: field.cpp:509
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
AFopr_Domainwall_eo::Ddag_eo
void Ddag_eo(AFIELD &, const AFIELD &, const int ieo)
Definition: afopr_Domainwall_eo-tmpl.h:678
AFopr_Domainwall_eo::DdagD
void DdagD(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:457
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AFopr_Domainwall_eo::Ddag
void Ddag(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:522
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
AFopr_Domainwall_eo::mult
void mult(AFIELD &v, const AFIELD &w)
multiplies fermion operator to a given field (2nd argument)
Definition: afopr_Domainwall_eo-tmpl.h:324
Bridge::BridgeIO::paranoiac
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:238
AFopr_Domainwall_eo
Domain-wall fermion operator with even-odd site index.
Definition: afopr_Domainwall_eo.h:41
AFopr_Domainwall_eo::mult_gm5R
void mult_gm5R(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:613
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Parameters::fetch_int_vector
int fetch_int_vector(const string &key, vector< int > &value) const
Definition: parameters.cpp:429
AFopr_Domainwall_eo::set_precond_parameters
void set_precond_parameters()
set parameters for preconditioning.
Definition: afopr_Domainwall_eo-tmpl.h:212
AFopr_Domainwall_eo::set_coefficients
void set_coefficients(const std::vector< real_t > b, const std::vector< real_t > c)
set coefficients if they depend in s.
Definition: afopr_Domainwall_eo-tmpl.h:239
threadManager.h
AFopr_Domainwall_eo::set_mode
void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr_Domainwall_eo-tmpl.h:310
AFopr_Domainwall_eo::mult_gm5
void mult_gm5(AFIELD &v, const AFIELD &w)
multiplies gamma_5 matrix.
Definition: afopr_Domainwall_eo-tmpl.h:564
AFopr_Domainwall_eo::Ldag_inv
void Ldag_inv(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:900
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
AFopr_Domainwall_eo::reverse
void reverse(Field &, const AFIELD &)
reverse AField to Field.
Definition: afopr_Domainwall_eo-tmpl.h:287
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
AFopr_Domainwall_eo::L_inv
void L_inv(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:765
scal
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:261
afopr_Domainwall_eo.h
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Parameters::fetch_double
int fetch_double(const string &key, double &value) const
Definition: parameters.cpp:327
commonParameters.h
Parameters::get_string
string get_string(const string &key) const
Definition: parameters.cpp:221
AFopr_Domainwall_eo::set_kernel_parameters
void set_kernel_parameters(const Parameters &params)
set parameters of kernel operaotr.
Definition: afopr_Domainwall_eo-tmpl.h:195
AFopr_Domainwall_eo::D_eo
void D_eo(AFIELD &, const AFIELD &, const int ieo)
Definition: afopr_Domainwall_eo-tmpl.h:632
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
AFopr_Domainwall_eo::U_inv
void U_inv(AFIELD &, const AFIELD &)
Definition: afopr_Domainwall_eo-tmpl.h:810
Field
Container of Field-type object.
Definition: field.h:46
communicator.h
ThreadManager::get_thread_id
static int get_thread_id()
returns thread id.
Definition: threadManager.cpp:253
AFopr_Domainwall_eo::postProp
void postProp(AFIELD &x, const AFIELD &xe, const AFIELD &bo)
Definition: afopr_Domainwall_eo-tmpl.h:423
AFopr_Domainwall_eo::convert
void convert(AFIELD &, const Field &)
convert Field to AField for this class.
Definition: afopr_Domainwall_eo-tmpl.h:264
Parameters::fetch_int
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
AFopr_Domainwall_eo::mult_gm5_4d
void mult_gm5_4d(AFIELD &v, const AFIELD &w)
Definition: afopr_Domainwall_eo-tmpl.h:587
AFopr_Domainwall_eo::tidyup
void tidyup()
final tidyup.
Definition: afopr_Domainwall_eo-tmpl.h:92
AFopr_Domainwall_eo::mult_dag
void mult_dag(AFIELD &v, const AFIELD &w)
hermitian conjugate of mult(Field&, const Field&).
Definition: afopr_Domainwall_eo-tmpl.h:347
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
AFopr_Domainwall_eo::real_t
AFIELD::real_t real_t
Definition: afopr_Domainwall_eo.h:44
Index_eo_Domainwall
Definition: afopr_Domainwall_eo.h:28