22 template<
typename AFIELD>
26 template<
typename AFIELD>
33 vout.
general(m_vl,
"%s: construction\n", class_name.c_str());
44 string vlevel = params.
get_string(
"verbose_level");
50 err += params.
fetch_string(
"kernel_type", m_kernel_type);
52 vout.
crucial(m_vl,
"%s: Error: kernel_type is not specified.\n",
61 vout.
crucial(m_vl,
"Error at %s: domain_wall_height is not specified.\n",
67 double kappa = 1.0 / (8.0 - 2.0 * M0);
68 params_kernel.
set_double(
"hopping_parameter", kappa);
72 m_kernel_created =
true;
74 m_foprw->set_mode(
"D");
78 set_parameters(params);
80 m_w4.reset(m_NinF, m_Nvol, 1);
81 m_v4.reset(m_NinF, m_Nvol, 1);
82 m_t4.reset(m_NinF, m_Nvol, 1);
83 m_y4.reset(m_NinF, m_Nvol, 1);
85 if (needs_convert()) {
86 m_w4lex.reset(m_NinF, m_Nvol, 1);
87 m_v4lex.reset(m_NinF, m_Nvol, 1);
97 template<
typename AFIELD>
105 vout.
general(m_vl,
"%s: construction\n", class_name.c_str());
110 m_NinF = 2 * Nc * Nd;
116 string vlevel = params.
get_string(
"verbose_level");
119 vout.
general(m_vl,
"%s: Initialization start\n", class_name.c_str());
123 m_kernel_type =
"unknown";
124 m_kernel_created =
false;
130 set_parameters(params);
132 m_w4.reset(m_NinF, m_Nvol, 1);
133 m_v4.reset(m_NinF, m_Nvol, 1);
134 m_t4.reset(m_NinF, m_Nvol, 1);
135 m_y4.reset(m_NinF, m_Nvol, 1);
137 if (needs_convert()) {
138 m_w4lex.reset(m_NinF, m_Nvol, 1);
139 m_v4lex.reset(m_NinF, m_Nvol, 1);
149 template<
typename AFIELD>
156 vout.
general(m_vl,
"%s: construction\n", class_name.c_str());
161 m_NinF = 2 * Nc * Nd;
166 vout.
general(m_vl,
"%s: Initialization start\n", class_name.c_str());
170 m_kernel_type =
"unknown";
171 m_kernel_created =
false;
177 m_w4.reset(m_NinF, m_Nvol, 1);
178 m_v4.reset(m_NinF, m_Nvol, 1);
179 m_t4.reset(m_NinF, m_Nvol, 1);
180 m_y4.reset(m_NinF, m_Nvol, 1);
182 if (needs_convert()) {
183 m_w4lex.reset(m_NinF, m_Nvol, 1);
184 m_v4lex.reset(m_NinF, m_Nvol, 1);
194 template<
typename AFIELD>
197 if (m_kernel_created ==
true)
delete m_foprw;
202 template<
typename AFIELD>
217 int err_optional = 0;
218 err_optional += params.
fetch_string(
"gamma_matrix_type", gmset_type);
223 err += params.
fetch_int(
"extent_of_5th_dimension", Ns);
227 vout.
crucial(m_vl,
"Error at %s: input parameter not found.\n",
237 vout.
general(m_vl,
" coefficients b, c are not provided:"
238 " set to Shamir's form.\n");
246 if (
real_t(M0) != m_M0) set_kernel_parameters(params);
251 template<
typename AFIELD>
254 params.
set_string(
"kernel_type", m_kernel_type);
255 params.
set_double(
"quark_mass",
double(m_mq));
256 params.
set_double(
"domain_wall_height",
double(m_M0));
257 params.
set_int(
"extent_of_5th_dimension", m_Ns);
259 params.
set_double(
"coefficient_b",
double(m_b[0]));
260 params.
set_double(
"coefficient_c",
double(m_c[0]));
261 params.
set_string(
"gamma_matrix_type", m_repr);
268 template<
typename AFIELD>
273 const std::vector<int> bc,
284 assert(bc.size() == m_Ndim);
285 if (m_boundary.size() != m_Ndim) m_boundary.resize(m_Ndim);
286 for (
int mu = 0; mu < m_Ndim; ++mu) {
287 m_boundary[mu] = bc[mu];
290 if (m_b.size() != m_Ns) {
294 for (
int is = 0; is < m_Ns; ++is) {
300 vout.
general(m_vl,
"%s: input parameters\n", class_name.c_str());
304 for (
int mu = 0; mu < m_Ndim; ++mu) {
305 vout.
general(m_vl,
" boundary[%d] = %2d\n", mu, m_boundary[mu]);
308 for (
int is = 0; is < m_Ns; ++is) {
309 vout.
general(m_vl,
" b[%2d] = %16.10f c[%2d] = %16.10f\n",
310 is, m_b[is], is, m_c[is]);
313 set_precond_parameters();
316 if (m_w1.nex() != Ns) {
317 m_w1.reset(m_NinF, m_Nvol, m_Ns);
318 m_v1.reset(m_NinF, m_Nvol, m_Ns);
319 m_v2.reset(m_NinF, m_Nvol, m_Ns);
325 template<
typename AFIELD>
330 const std::vector<int> bc,
331 const std::vector<real_t> vec_b,
332 const std::vector<real_t> vec_c)
341 assert(bc.size() == m_Ndim);
342 if (m_boundary.size() != m_Ndim) m_boundary.resize(m_Ndim);
343 for (
int mu = 0; mu < m_Ndim; ++mu) {
344 m_boundary[mu] = bc[mu];
347 if (m_b.size() != m_Ns) {
351 for (
int is = 0; is < m_Ns; ++is) {
352 m_b[is] =
real_t(vec_b[is]);
353 m_c[is] =
real_t(vec_c[is]);
358 vout.
general(m_vl,
"%s: parameters\n", class_name.c_str());
362 for (
int mu = 0; mu < m_Ndim; ++mu) {
363 vout.
general(m_vl,
" boundary[%d] = %2d\n", mu, m_boundary[mu]);
366 for (
int is = 0; is < m_Ns; ++is) {
367 vout.
general(m_vl,
" b[%2d] = %16.10f c[%2d] = %16.10f\n",
368 is, m_b[is], is, m_c[is]);
371 set_precond_parameters();
374 if (m_w1.nex() != Ns) {
375 m_w1.reset(m_NinF, m_Nvol, m_Ns);
376 m_v1.reset(m_NinF, m_Nvol, m_Ns);
377 m_v2.reset(m_NinF, m_Nvol, m_Ns);
384 template<
typename AFIELD>
386 const std::vector<real_t> vec_b,
387 const std::vector<real_t> vec_c)
389 if ((vec_b.size() != m_Ns) || (vec_c.size() != m_Ns)) {
390 vout.
crucial(m_vl,
"%s: size of coefficient vectors incorrect.\n",
394 vout.
general(m_vl,
"%s: coefficient vectors are set:\n",
397 for (
int is = 0; is < m_Ns; ++is) {
398 m_b[is] =
real_t(vec_b[is]);
399 m_c[is] =
real_t(vec_c[is]);
400 vout.
general(m_vl,
"b[%2d] = %16.10f c[%2d] = %16.10f\n",
401 is, m_b[is], is, m_c[is]);
404 set_precond_parameters();
409 template<
typename AFIELD>
418 double kappa = 1.0 / (8.0 - 2.0 * M0);
419 params_kernel.
set_double(
"hopping_parameter", kappa);
421 m_foprw->set_parameters(params_kernel);
426 template<
typename AFIELD>
429 if (m_dp.size() != m_Ns) {
432 m_e.resize(m_Ns - 1);
433 m_f.resize(m_Ns - 1);
436 for (
int is = 0; is < m_Ns; ++is) {
437 m_dp[is] = 1.0 + m_b[is] * (4.0 - m_M0);
438 m_dm[is] = 1.0 - m_c[is] * (4.0 - m_M0);
441 m_e[0] = m_mq * m_dm[m_Ns - 1] / m_dp[0];
442 m_f[0] = m_mq * m_dm[0];
443 for (
int is = 1; is < m_Ns - 1; ++is) {
444 m_e[is] = m_e[is - 1] * m_dm[is - 1] / m_dp[is];
445 m_f[is] = m_f[is - 1] * m_dm[is] / m_dp[is - 1];
448 m_g = m_e[m_Ns - 2] * m_dm[m_Ns - 2];
453 template<
typename AFIELD>
456 if (!needs_convert()) {
457 vout.
crucial(m_vl,
"%s: convert is not necessary.\n",
465 for (
int ex = 0; ex < Nex; ++ex) {
466 copy(m_w4lex, 0, w, ex);
467 m_foprw->convert(m_v4lex, m_w4lex);
468 copy(v, ex, m_v4lex, 0);
476 template<
typename AFIELD>
479 if (!needs_convert()) {
480 vout.
crucial(m_vl,
"%s: convert is not necessary.\n",
488 for (
int ex = 0; ex < Nex; ++ex) {
489 copy(m_v4lex, 0, w, ex);
490 m_foprw->reverse(m_w4lex, m_v4lex);
491 copy(v, ex, m_w4lex, 0);
499 template<
typename AFIELD>
505 if (ith == 0) m_mode = mode;
512 template<
typename AFIELD>
517 }
else if (m_mode ==
"Ddag") {
519 }
else if (m_mode ==
"DdagD") {
521 }
else if (m_mode ==
"DDdag") {
523 }
else if (m_mode ==
"H") {
525 }
else if (m_mode ==
"Hdag") {
527 }
else if (m_mode ==
"D_prec") {
529 }
else if (m_mode ==
"Ddag_prec") {
531 }
else if (m_mode ==
"DdagD_prec") {
533 }
else if (m_mode ==
"Prec") {
536 vout.
crucial(m_vl,
"mode undeifined in %s.\n", class_name.c_str());
543 template<
typename AFIELD>
548 }
else if (m_mode ==
"Ddag") {
550 }
else if (m_mode ==
"DdagD") {
552 }
else if (m_mode ==
"DDdag") {
554 }
else if (m_mode ==
"H") {
556 }
else if (m_mode ==
"Hdag") {
558 }
else if (m_mode ==
"D_prec") {
560 }
else if (m_mode ==
"Ddag_prec") {
562 }
else if (m_mode ==
"DdagD_prec") {
564 }
else if (m_mode ==
"Prec") {
567 vout.
crucial(m_vl,
"mode undeifined in %s.\n", class_name.c_str());
574 template<
typename AFIELD>
581 if (mode ==
"Prec") {
583 }
else if (mode ==
"Precdag") {
585 }
else if (mode ==
"D") {
587 }
else if (mode ==
"Ddag") {
589 }
else if (mode ==
"DdagD") {
591 }
else if (mode ==
"DDdag") {
593 }
else if (mode ==
"D_prec") {
595 }
else if (mode ==
"Ddag_prec") {
597 }
else if (mode ==
"DdagD_prec") {
601 class_name.c_str(), mode.c_str());
608 template<
typename AFIELD>
615 if (mode ==
"Prec") {
617 }
else if (mode ==
"Precdag") {
619 }
else if (mode ==
"D") {
621 }
else if (mode ==
"Ddag") {
623 }
else if (mode ==
"DdagD") {
625 }
else if (mode ==
"DDdag") {
627 }
else if (mode ==
"D_prec") {
629 }
else if (mode ==
"Ddag_prec") {
631 }
else if (mode ==
"DdagD_prec") {
634 std::cout <<
"mode undeifined in AFopr_Domainwall.\n";
641 template<
typename AFIELD>
651 m_foprw->mult_gm5(v, w);
654 for (
int ex = 0; ex < Nex; ++ex) {
655 copy(m_w4, 0, w, ex);
656 m_foprw->mult_gm5(m_v4, m_w4);
657 copy(v, ex, m_v4, 0);
665 template<
typename AFIELD>
674 m_foprw->mult_gm5(m_w4, w);
684 template<
typename AFIELD>
687 m_foprw->mult_gm5(v, w);
692 template<
typename AFIELD>
704 template<
typename AFIELD>
716 template<
typename AFIELD>
728 template<
typename AFIELD>
738 template<
typename AFIELD>
748 template<
typename AFIELD>
757 template<
typename AFIELD>
766 template<
typename AFIELD>
775 template<
typename AFIELD>
784 template<
typename AFIELD>
789 for (
int is = 0; is < m_Ns; ++is) {
790 copy(m_w4, 0, w, is);
791 mult_gm5_4d(m_v4, m_w4);
792 copy(v, m_Ns - 1 - is, m_v4, 0);
800 template<
typename AFIELD>
808 for (
int is = 0; is < m_Ns; ++is) {
809 copy(v, m_Ns - 1 - is, w, is);
817 template<
typename AFIELD>
822 for (
int is = 0; is < m_Ns; ++is) {
824 int is_up = (is + 1) % m_Ns;
826 if (is == m_Ns - 1) Fup = 0.5 * m_mq;
827 copy(m_v4, 0, w, is_up);
828 mult_gm5_4d(m_t4, m_v4);
830 axpy(m_y4, 0, Fup, m_v4, 0);
832 int is_dn = (is - 1 + m_Ns) % m_Ns;
834 if (is == 0) Fdn = 0.5 * m_mq;
835 copy(m_v4, 0, w, is_dn);
836 mult_gm5_4d(m_t4, m_v4);
838 axpy(m_y4, 0, Fdn, m_v4, 0);
840 copy(m_w4, 0, w, is);
842 copy(v, is, m_w4, 0);
846 axpy(m_w4, -m_c[is], m_y4);
848 m_foprw->mult(m_v4, m_w4);
858 template<
typename AFIELD>
866 for (
int is = 0; is < m_Ns; ++is) {
867 copy(m_w4, 0, w, is);
869 m_foprw->mult_dag(m_v4, m_w4);
871 axpy(m_w4, m_b[is] * (
real_t(4.0) - m_M0), m_v4);
874 axpy(m_y4, -m_c[is] * (
real_t(4.0) - m_M0), m_v4);
876 int is_up = (is + 1) % m_Ns;
878 if (is_up == 0) Fup = 0.5 * m_mq;
879 mult_gm5_4d(m_t4, m_y4);
881 axpy(v, is_up, -Fup, m_t4, 0);
883 int is_dn = (is - 1 + m_Ns) % m_Ns;
885 if (is_dn == m_Ns - 1) Fdn = 0.5 * m_mq;
886 mult_gm5_4d(m_t4, m_y4);
888 axpy(v, is_dn, Fdn, m_t4, 0);
896 template<
typename AFIELD>
905 for (
int is = 1; is < m_Ns - 1; ++is) {
908 copy(m_v4, 0, v, is - 1);
909 mult_gm5_4d(m_t4, m_v4);
911 scal(m_v4,
real_t(0.5) * m_dm[is] / m_dp[is - 1]);
914 copy(m_t4, 0, v, is);
915 axpy(m_y4, m_e[is], m_t4);
920 copy(m_v4, 0, v, is - 1);
921 mult_gm5_4d(m_t4, m_v4);
923 scal(m_v4,
real_t(0.5) * m_dm[is] / m_dp[is - 1]);
927 mult_gm5_4d(m_t4, m_y4);
937 template<
typename AFIELD>
945 copy(m_y4, 0, w, is);
947 copy(v, is, m_y4, 0);
949 mult_gm5_4d(m_w4, m_y4);
953 for (
int is = m_Ns - 2; is >= 0; --is) {
954 copy(m_v4, 0, w, is);
956 copy(m_w4, 0, v, is + 1);
957 mult_gm5_4d(m_t4, m_w4);
962 axpy(m_v4, -m_f[is], m_y4);
966 copy(v, is, m_v4, 0);
974 template<
typename AFIELD>
986 for (
int is = 1; is < m_Ns - 1; ++is) {
987 copy(m_t4, 0, w, is);
989 copy(m_v4, 0, v, is - 1);
990 mult_gm5_4d(m_w4, m_v4);
995 copy(v, is, m_t4, 0);
997 axpy(m_y4, m_f[is], m_t4);
1002 copy(m_t4, 0, w, is);
1004 copy(m_v4, 0, v, is - 1);
1005 mult_gm5_4d(m_w4, m_v4);
1007 axpy(m_t4,
real_t(0.5) * m_dm[is - 1], m_v4);
1009 mult_gm5_4d(m_w4, m_y4);
1016 copy(v, is, m_t4, 0);
1023 template<
typename AFIELD>
1032 copy(m_y4, 0, w, is);
1033 mult_gm5_4d(m_w4, m_y4);
1037 for (
int is = m_Ns - 2; is >= 0; --is) {
1040 copy(m_v4, 0, v, is + 1);
1041 mult_gm5_4d(m_w4, m_v4);
1043 scal(m_v4,
real_t(0.5) * m_dm[is + 1] / m_dp[is]);
1045 axpy(m_v4, -m_e[is], m_y4);
1055 template<
typename AFIELD>
1059 double vsite =
static_cast<double>(Lvol);
1060 double vNs =
static_cast<double>(m_Ns);
1063 double flop_Wilson = m_foprw->flop_count();
1065 double axpy1 =
static_cast<double>(2 * m_NinF);
1066 double scal1 =
static_cast<double>(1 * m_NinF);
1068 double flop_DW = vNs * (flop_Wilson + vsite * (6 * axpy1 + 2 * scal1));
1071 double flop_LU_inv = 2.0 * vsite *
1072 ((3.0 * axpy1 + scal1) * (vNs - 1.0) + axpy1 + 2.0 * scal1);
1075 if (mode ==
"Prec") {
1077 }
else if ((mode ==
"D") || (mode ==
"Ddag")) {
1079 }
else if (mode ==
"DdagD") {
1080 flop = 2.0 * flop_DW;
1081 }
else if ((mode ==
"D_prec") || (mode ==
"Ddag_prec")) {
1082 flop = flop_LU_inv + flop_DW;
1083 }
else if (mode ==
"DdagD_prec") {
1084 flop = 2.0 * (flop_LU_inv + flop_DW);
1086 vout.
crucial(m_vl,
"Error at %s: input repr is undefined.\n",
1087 class_name.c_str());