20 #if defined USE_GROUP_SU3
28 #elif defined USE_GROUP_SU2
42 #if defined USE_GROUP_SU_N
45 const int NC2 = 2 *
NC;
49 const int Nvol = v1.
nvol();
52 assert(Nvol == v2.
nvol());
53 assert(v1.
nex() == 1);
54 assert(v2.
nex() == 1);
56 const double *w1 = v1.
ptr(0);
57 const double *w2 = v2.
ptr(0);
61 for (
int id = 0;
id <
ND; ++id) {
68 for (
int id = 0;
id <
ND; ++id) {
74 for (
int ss = 0; ss < Nvol_s; ++ss) {
75 int site = NCD2 * (ss + time * Nvol_s);
77 for (
int cc = 0; cc <
NC; ++cc) {
78 for (
int id = 0;
id <
ND; ++id) {
79 int ic1_r = 2 * cc + id1[id] + site;
80 int ic2_r = 2 * cc + id2[id] + site;
82 int ic1_i = 2 * cc + 1 + id1[id] + site;
83 int ic2_i = 2 * cc + 1 + id2[id] + site;
85 c_r[id] += w1[ic2_r] * w2[ic1_r]
86 + w1[ic2_i] * w2[ic1_i];
88 c_i[id] += -w1[ic2_r] * w2[ic1_i]
89 + w1[ic2_i] * w2[ic1_r];
94 corr = cmplx(0.0, 0.0);
95 for (
int id = 0;
id <
ND; ++id) {
96 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
109 assert(corr_global.size() == Lt);
111 std::vector<dcomplex> corr_local(Nt, 0.0);
112 for (
int t = 0; t < Nt; ++t) {
115 corr_local[t] += corr_t;
123 const std::vector<int>& momentum_sink,
125 const std::vector<int>& source_position,
129 #if defined USE_GROUP_SU_N
132 const int NC2 = 2 *
NC;
133 const int NCD2 = NC2 *
ND;
136 const int Nvol = v1.
nvol();
145 assert(Nvol == v2.
nvol());
146 assert(v1.
nex() == 1);
147 assert(v2.
nex() == 1);
148 assert(momentum_sink.size() ==
NDIM - 1);
150 const double *w1 = v1.
ptr(0);
151 const double *w2 = v2.
ptr(0);
155 for (
int id = 0;
id <
ND; ++id) {
162 for (
int id = 0;
id <
ND; ++id) {
167 static const double PI = 4.0 * atan(1.0);
168 std::vector<double> p_unit(ND - 1);
169 p_unit[0] = (2.0 * PI / Lx) * momentum_sink[0];
170 p_unit[1] = (2.0 * PI / Ly) * momentum_sink[1];
171 p_unit[2] = (2.0 * PI / Lz) * momentum_sink[2];
173 std::vector<int> ipe(ND - 1);
179 for (
int ss = 0; ss < Nvol_s; ++ss) {
180 int site = NCD2 * (ss + time * Nvol_s);
183 int y = ss % (Nx * Ny) / Nx;
184 int z = ss % (Nx * Ny * Nz) / (Nx * Ny);
186 int x_global = x + ipe[0] * Nx;
187 int y_global = y + ipe[1] * Ny;
188 int z_global = z + ipe[2] * Nz;
190 double p_x = p_unit[0] * (x_global - source_position[0]);
191 double p_y = p_unit[1] * (y_global - source_position[1]);
192 double p_z = p_unit[2] * (z_global - source_position[2]);
194 double cos_p_xyz = cos(p_x + p_y + p_z);
195 double sin_p_xyz = sin(p_x + p_y + p_z);
197 for (
int cc = 0; cc <
NC; ++cc) {
198 for (
int id = 0;
id <
ND; ++id) {
199 int ic1_r = 2 * cc + id1[id] + site;
200 int ic2_r = 2 * cc + id2[id] + site;
202 int ic1_i = 2 * cc + 1 + id1[id] + site;
203 int ic2_i = 2 * cc + 1 + id2[id] + site;
205 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
206 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
209 c_r[id] += w1_w2_r * cos_p_xyz - w1_w2_i * sin_p_xyz;
210 c_i[id] += w1_w2_r * sin_p_xyz + w1_w2_i * cos_p_xyz;
215 corr = cmplx(0.0, 0.0);
216 for (
int id = 0;
id <
ND; ++id) {
217 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
224 const std::vector<int>& momentum_sink,
226 const std::vector<int>& source_position,
232 assert(corr_global.size() == Lt);
234 std::vector<dcomplex> corr_local(Nt, 0.0);
235 for (
int t = 0; t < Nt; ++t) {
237 contract_at_t(corr_t, momentum_sink, gm_sink, source_position, v1, v2, t);
238 corr_local[t] += corr_t;
246 const std::vector<int>& momentum_sink,
248 const std::vector<int>& source_position,
252 #if defined USE_GROUP_SU_N
255 const int NC2 = 2 *
NC;
256 const int NCD2 = NC2 *
ND;
259 const int Nvol = v1.
nvol();
268 assert(Nvol == v2.
nvol());
269 assert(v1.
nex() == 1);
270 assert(v2.
nex() == 1);
271 assert(momentum_sink.size() ==
NDIM - 1);
273 const double *w1 = v1.
ptr(0);
274 const double *w2 = v2.
ptr(0);
278 for (
int id = 0;
id <
ND; ++id) {
285 for (
int id = 0;
id <
ND; ++id) {
290 static const double PI = 4.0 * atan(1.0);
291 std::vector<double> p_unit(ND - 1);
292 p_unit[0] = (2.0 * PI / Lx) * momentum_sink[0];
293 p_unit[1] = (2.0 * PI / Ly) * momentum_sink[1];
294 p_unit[2] = (2.0 * PI / Lz) * momentum_sink[2];
296 std::vector<int> ipe(ND - 1);
302 for (
int ss = 0; ss < Nvol_s; ++ss) {
303 int site = NCD2 * (ss + time * Nvol_s);
306 int y = ss % (Nx * Ny) / Nx;
307 int z = ss % (Nx * Ny * Nz) / (Nx * Ny);
309 int x_global = x + ipe[0] * Nx;
310 int y_global = y + ipe[1] * Ny;
311 int z_global = z + ipe[2] * Nz;
313 double p_x = p_unit[0] * (x_global - source_position[0]);
314 double p_y = p_unit[1] * (y_global - source_position[1]);
315 double p_z = p_unit[2] * (z_global - source_position[2]);
317 double cos_p_xyz = cos(p_x + p_y + p_z);
319 double sin_p_xyz = 0;
321 for (
int cc = 0; cc <
NC; ++cc) {
322 for (
int id = 0;
id <
ND; ++id) {
323 int ic1_r = 2 * cc + id1[id] + site;
324 int ic2_r = 2 * cc + id2[id] + site;
326 int ic1_i = 2 * cc + 1 + id1[id] + site;
327 int ic2_i = 2 * cc + 1 + id2[id] + site;
329 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
330 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
334 c_r[id] += w1_w2_r * cos_p_xyz - w1_w2_i * sin_p_xyz;
335 c_i[id] += w1_w2_r * sin_p_xyz + w1_w2_i * cos_p_xyz;
340 corr = cmplx(0.0, 0.0);
341 for (
int id = 0;
id <
ND; ++id) {
342 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
349 const std::vector<int>& momentum_sink,
351 const std::vector<int>& source_position,
357 assert(corr_global.size() == Lt);
359 std::vector<dcomplex> corr_local(Nt, 0.0);
360 for (
int t = 0; t < Nt; ++t) {
363 corr_local[t] += corr_t;
376 #if defined USE_GROUP_SU3
377 const int Nvol = v1.
nvol();
380 assert(Nvol == v2.
nvol());
381 assert(Nvol == v3.
nvol());
382 assert(v1.
nex() == 1);
383 assert(v2.
nex() == 1);
384 assert(v3.
nex() == 1);
386 const double *w1 = v1.
ptr(0);
387 const double *w2 = v2.
ptr(0);
388 const double *w3 = v3.
ptr(0);
392 for (
int id = 0;
id <
ND; ++id) {
396 int id3 = i_alpha *
NC2;
400 for (
int id = 0;
id <
ND; ++id) {
406 for (
int ss = 0; ss < Nvol_s; ++ss) {
407 int site =
NCD2 * (ss + time * Nvol_s);
409 for (
int id = 0;
id <
ND; ++id) {
410 int ic11_r = C1 + id1[id] + site;
411 int ic22_r = C2 + id2[id] + site;
412 int ic33_r = C3 + id3 + site;
414 int ic11_i = C1 + 1 + id1[id] + site;
415 int ic22_i = C2 + 1 + id2[id] + site;
416 int ic33_i = C3 + 1 + id3 + site;
418 int ic21_r = C2 + id1[id] + site;
419 int ic32_r = C3 + id2[id] + site;
420 int ic13_r = C1 + id3 + site;
422 int ic21_i = C2 + 1 + id1[id] + site;
423 int ic32_i = C3 + 1 + id2[id] + site;
424 int ic13_i = C1 + 1 + id3 + site;
426 int ic31_r = C3 + id1[id] + site;
427 int ic12_r = C1 + id2[id] + site;
428 int ic23_r = C2 + id3 + site;
430 int ic31_i = C3 + 1 + id1[id] + site;
431 int ic12_i = C1 + 1 + id2[id] + site;
432 int ic23_i = C2 + 1 + id3 + site;
435 c_r[id] += (w1[ic11_r] * w2[ic22_r] - w1[ic11_i] * w2[ic22_i]) * w3[ic33_r]
436 - (w1[ic11_r] * w2[ic22_i] + w1[ic11_i] * w2[ic22_r]) * w3[ic33_i];
437 c_i[id] += (w1[ic11_r] * w2[ic22_r] - w1[ic11_i] * w2[ic22_i]) * w3[ic33_i]
438 + (w1[ic11_r] * w2[ic22_i] + w1[ic11_i] * w2[ic22_r]) * w3[ic33_r];
440 c_r[id] += (w1[ic21_r] * w2[ic32_r] - w1[ic21_i] * w2[ic32_i]) * w3[ic13_r]
441 - (w1[ic21_r] * w2[ic32_i] + w1[ic21_i] * w2[ic32_r]) * w3[ic13_i];
442 c_i[id] += (w1[ic21_r] * w2[ic32_r] - w1[ic21_i] * w2[ic32_i]) * w3[ic13_i]
443 + (w1[ic21_r] * w2[ic32_i] + w1[ic21_i] * w2[ic32_r]) * w3[ic13_r];
445 c_r[id] += (w1[ic31_r] * w2[ic12_r] - w1[ic31_i] * w2[ic12_i]) * w3[ic23_r]
446 - (w1[ic31_r] * w2[ic12_i] + w1[ic31_i] * w2[ic12_r]) * w3[ic23_i];
447 c_i[id] += (w1[ic31_r] * w2[ic12_r] - w1[ic31_i] * w2[ic12_i]) * w3[ic23_i]
448 + (w1[ic31_r] * w2[ic12_i] + w1[ic31_i] * w2[ic12_r]) * w3[ic23_r];
450 c_r[id] -= (w1[ic31_r] * w2[ic22_r] - w1[ic31_i] * w2[ic22_i]) * w3[ic13_r]
451 - (w1[ic31_r] * w2[ic22_i] + w1[ic31_i] * w2[ic22_r]) * w3[ic13_i];
452 c_i[id] -= (w1[ic31_r] * w2[ic22_r] - w1[ic31_i] * w2[ic22_i]) * w3[ic13_i]
453 + (w1[ic31_r] * w2[ic22_i] + w1[ic31_i] * w2[ic22_r]) * w3[ic13_r];
455 c_r[id] -= (w1[ic21_r] * w2[ic12_r] - w1[ic21_i] * w2[ic12_i]) * w3[ic33_r]
456 - (w1[ic21_r] * w2[ic12_i] + w1[ic21_i] * w2[ic12_r]) * w3[ic33_i];
457 c_i[id] -= (w1[ic21_r] * w2[ic12_r] - w1[ic21_i] * w2[ic12_i]) * w3[ic33_i]
458 + (w1[ic21_r] * w2[ic12_i] + w1[ic21_i] * w2[ic12_r]) * w3[ic33_r];
460 c_r[id] -= (w1[ic11_r] * w2[ic32_r] - w1[ic11_i] * w2[ic32_i]) * w3[ic23_r]
461 - (w1[ic11_r] * w2[ic32_i] + w1[ic11_i] * w2[ic32_r]) * w3[ic23_i];
462 c_i[id] -= (w1[ic11_r] * w2[ic32_r] - w1[ic11_i] * w2[ic32_i]) * w3[ic23_i]
463 + (w1[ic11_r] * w2[ic32_i] + w1[ic11_i] * w2[ic32_r]) * w3[ic23_r];
467 corr = cmplx(0.0, 0.0);
468 for (
int id = 0;
id <
ND; ++id) {
469 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
471 #endif // (USE_GROUP_SU3)
481 #if defined USE_GROUP_SU_N
484 const int NC2 = 2 *
NC;
485 const int NCD2 = NC2 *
ND;
488 const int Nvol = v1.
nvol();
495 assert(Nvol == v2.
nvol());
496 assert(v1.
nex() == 1);
497 assert(v2.
nex() == 1);
499 const double *w1 = v1.
ptr(0);
500 const double *w2 = v2.
ptr(0);
504 for (
int id = 0;
id <
ND; ++id) {
511 for (
int id = 0;
id <
ND; ++id) {
516 for (
int t = 0; t < Nt; ++t) {
517 for (
int z = 0; z < Nz; ++z) {
518 for (
int y = 0; y < Ny; ++y) {
519 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
521 for (
int cc = 0; cc <
NC; ++cc) {
522 for (
int id = 0;
id <
ND; ++id) {
523 int ic1_r = 2 * cc + id1[id] + site;
524 int ic2_r = 2 * cc + id2[id] + site;
526 int ic1_i = 2 * cc + 1 + id1[id] + site;
527 int ic2_i = 2 * cc + 1 + id2[id] + site;
529 c_r[id] += w1[ic2_r] * w2[ic1_r]
530 + w1[ic2_i] * w2[ic1_i];
532 c_i[id] += -w1[ic2_r] * w2[ic1_i]
533 + w1[ic2_i] * w2[ic1_r];
540 corr = cmplx(0.0, 0.0);
541 for (
int id = 0;
id <
ND; ++id) {
542 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
555 assert(corr_global.size() == Lx);
557 std::vector<dcomplex> corr_local(Nx, 0.0);
558 for (
int x = 0; x < Nx; ++x) {
561 corr_local[x] += corr_x;
569 const std::vector<int>& momentum_sink,
571 const std::vector<int>& source_position,
575 #if defined USE_GROUP_SU_N
582 const int Nvol = v1.
nvol();
593 assert(Nvol == v2.
nvol());
594 assert(v1.
nex() == 1);
595 assert(v2.
nex() == 1);
596 assert(momentum_sink.size() ==
NDIM - 1);
597 assert(source_position.size() ==
NDIM);
599 const double *w1 = v1.
ptr(0);
600 const double *w2 = v2.
ptr(0);
604 for (
int id = 0;
id <
ND; ++id) {
611 for (
int id = 0;
id <
ND; ++id) {
616 static const double PI = 4.0 * atan(1.0);
617 std::vector<double> p_unit(ND - 1);
618 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
619 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
620 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
622 std::vector<int> ipe(ND);
628 for (
int t = 0; t < Nt; ++t) {
629 for (
int z = 0; z < Nz; ++z) {
630 for (
int y = 0; y < Ny; ++y) {
631 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
633 int y_global = y + ipe[1] * Ny;
634 int z_global = z + ipe[2] * Nz;
635 int t_global = t + ipe[3] * Nt;
637 double p_y = p_unit[0] * (y_global - source_position[1]);
638 double p_z = p_unit[1] * (z_global - source_position[2]);
639 double p_t = p_unit[2] * (t_global - source_position[3]);
641 double cos_p_yzt = cos(p_t + p_y + p_z);
642 double sin_p_yzt = sin(p_t + p_y + p_z);
644 for (
int cc = 0; cc <
NC; ++cc) {
645 for (
int id = 0;
id <
ND; ++id) {
646 int ic1_r = 2 * cc + id1[id] + site;
647 int ic2_r = 2 * cc + id2[id] + site;
649 int ic1_i = 2 * cc + 1 + id1[id] + site;
650 int ic2_i = 2 * cc + 1 + id2[id] + site;
652 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
653 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
656 c_r[id] += w1_w2_r * cos_p_yzt - w1_w2_i * sin_p_yzt;
657 c_i[id] += w1_w2_r * sin_p_yzt + w1_w2_i * cos_p_yzt;
664 corr = cmplx(0.0, 0.0);
665 for (
int id = 0;
id <
ND; ++id) {
666 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
673 const std::vector<int>& momentum_sink,
675 const std::vector<int>& source_position,
681 assert(corr_global.size() == Lx);
683 std::vector<dcomplex> corr_local(Nx, 0.0);
684 for (
int x = 0; x < Nx; ++x) {
686 contract_at_x(corr_x, momentum_sink, gm_sink, source_position, v1, v2, x);
687 corr_local[x] += corr_x;
695 const std::vector<int>& momentum_sink,
697 const std::vector<int>& source_position,
701 #if defined USE_GROUP_SU_N
708 const int Nvol = v1.
nvol();
719 assert(Nvol == v2.
nvol());
720 assert(v1.
nex() == 1);
721 assert(v2.
nex() == 1);
722 assert(momentum_sink.size() ==
NDIM - 1);
723 assert(source_position.size() ==
NDIM);
725 const double *w1 = v1.
ptr(0);
726 const double *w2 = v2.
ptr(0);
730 for (
int id = 0;
id <
ND; ++id) {
737 for (
int id = 0;
id <
ND; ++id) {
742 static const double PI = 4.0 * atan(1.0);
743 std::vector<double> p_unit(ND - 1);
744 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
745 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
746 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
748 std::vector<int> ipe(ND);
755 for (
int t = 0; t < Nt; ++t) {
756 for (
int z = 0; z < Nz; ++z) {
757 for (
int y = 0; y < Ny; ++y) {
758 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
760 int y_global = y + ipe[1] * Ny;
761 int z_global = z + ipe[2] * Nz;
762 int t_global = t + ipe[3] * Nt;
764 double p_y = p_unit[0] * (y_global - source_position[1]);
765 double p_z = p_unit[1] * (z_global - source_position[2]);
766 double p_t = p_unit[2] * (t_global - source_position[3]);
768 double cos_p_yzt = cos(p_t + p_y + p_z);
770 double sin_p_yzt = 0;
772 for (
int cc = 0; cc <
NC; ++cc) {
773 for (
int id = 0;
id <
ND; ++id) {
774 int ic1_r = 2 * cc + id1[id] + site;
775 int ic2_r = 2 * cc + id2[id] + site;
777 int ic1_i = 2 * cc + 1 + id1[id] + site;
778 int ic2_i = 2 * cc + 1 + id2[id] + site;
780 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
781 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
785 c_r[id] += w1_w2_r * cos_p_yzt - w1_w2_i * sin_p_yzt;
786 c_i[id] += w1_w2_r * sin_p_yzt + w1_w2_i * cos_p_yzt;
793 corr = cmplx(0.0, 0.0);
794 for (
int id = 0;
id <
ND; ++id) {
795 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
802 const std::vector<int>& momentum_sink,
804 const std::vector<int>& source_position,
810 assert(corr_global.size() == Lx);
812 std::vector<dcomplex> corr_local(Nx, 0.0);
813 for (
int x = 0; x < Nx; ++x) {
816 corr_local[x] += corr_x;
829 #if defined USE_GROUP_SU3
830 const int Nvol = v1.
nvol();
837 assert(Nvol == v2.
nvol());
838 assert(Nvol == v3.
nvol());
839 assert(v1.
nex() == 1);
840 assert(v2.
nex() == 1);
841 assert(v3.
nex() == 1);
843 const double *w1 = v1.
ptr(0);
844 const double *w2 = v2.
ptr(0);
845 const double *w3 = v3.
ptr(0);
849 for (
int id = 0;
id <
ND; ++id) {
853 int id3 = i_alpha *
NC2;
857 for (
int id = 0;
id <
ND; ++id) {
863 for (
int t = 0; t < Nt; ++t) {
864 for (
int z = 0; z < Nz; ++z) {
865 for (
int y = 0; y < Ny; ++y) {
866 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
868 for (
int id = 0;
id <
ND; ++id) {
869 int ic11_r = C1 + id1[id] + site;
870 int ic22_r = C2 + id2[id] + site;
871 int ic33_r = C3 + id3 + site;
873 int ic11_i = C1 + 1 + id1[id] + site;
874 int ic22_i = C2 + 1 + id2[id] + site;
875 int ic33_i = C3 + 1 + id3 + site;
877 int ic21_r = C2 + id1[id] + site;
878 int ic32_r = C3 + id2[id] + site;
879 int ic13_r = C1 + id3 + site;
881 int ic21_i = C2 + 1 + id1[id] + site;
882 int ic32_i = C3 + 1 + id2[id] + site;
883 int ic13_i = C1 + 1 + id3 + site;
885 int ic31_r = C3 + id1[id] + site;
886 int ic12_r = C1 + id2[id] + site;
887 int ic23_r = C2 + id3 + site;
889 int ic31_i = C3 + 1 + id1[id] + site;
890 int ic12_i = C1 + 1 + id2[id] + site;
891 int ic23_i = C2 + 1 + id3 + site;
893 c_r[id] += (w1[ic11_r] * w2[ic22_r] - w1[ic11_i] * w2[ic22_i]) * w3[ic33_r]
894 - (w1[ic11_r] * w2[ic22_i] + w1[ic11_i] * w2[ic22_r]) * w3[ic33_i];
895 c_i[id] += (w1[ic11_r] * w2[ic22_r] - w1[ic11_i] * w2[ic22_i]) * w3[ic33_i]
896 + (w1[ic11_r] * w2[ic22_i] + w1[ic11_i] * w2[ic22_r]) * w3[ic33_r];
898 c_r[id] += (w1[ic21_r] * w2[ic32_r] - w1[ic21_i] * w2[ic32_i]) * w3[ic13_r]
899 - (w1[ic21_r] * w2[ic32_i] + w1[ic21_i] * w2[ic32_r]) * w3[ic13_i];
900 c_i[id] += (w1[ic21_r] * w2[ic32_r] - w1[ic21_i] * w2[ic32_i]) * w3[ic13_i]
901 + (w1[ic21_r] * w2[ic32_i] + w1[ic21_i] * w2[ic32_r]) * w3[ic13_r];
903 c_r[id] += (w1[ic31_r] * w2[ic12_r] - w1[ic31_i] * w2[ic12_i]) * w3[ic23_r]
904 - (w1[ic31_r] * w2[ic12_i] + w1[ic31_i] * w2[ic12_r]) * w3[ic23_i];
905 c_i[id] += (w1[ic31_r] * w2[ic12_r] - w1[ic31_i] * w2[ic12_i]) * w3[ic23_i]
906 + (w1[ic31_r] * w2[ic12_i] + w1[ic31_i] * w2[ic12_r]) * w3[ic23_r];
908 c_r[id] -= (w1[ic31_r] * w2[ic22_r] - w1[ic31_i] * w2[ic22_i]) * w3[ic13_r]
909 - (w1[ic31_r] * w2[ic22_i] + w1[ic31_i] * w2[ic22_r]) * w3[ic13_i];
910 c_i[id] -= (w1[ic31_r] * w2[ic22_r] - w1[ic31_i] * w2[ic22_i]) * w3[ic13_i]
911 + (w1[ic31_r] * w2[ic22_i] + w1[ic31_i] * w2[ic22_r]) * w3[ic13_r];
913 c_r[id] -= (w1[ic21_r] * w2[ic12_r] - w1[ic21_i] * w2[ic12_i]) * w3[ic33_r]
914 - (w1[ic21_r] * w2[ic12_i] + w1[ic21_i] * w2[ic12_r]) * w3[ic33_i];
915 c_i[id] -= (w1[ic21_r] * w2[ic12_r] - w1[ic21_i] * w2[ic12_i]) * w3[ic33_i]
916 + (w1[ic21_r] * w2[ic12_i] + w1[ic21_i] * w2[ic12_r]) * w3[ic33_r];
918 c_r[id] -= (w1[ic11_r] * w2[ic32_r] - w1[ic11_i] * w2[ic32_i]) * w3[ic23_r]
919 - (w1[ic11_r] * w2[ic32_i] + w1[ic11_i] * w2[ic32_r]) * w3[ic23_i];
920 c_i[id] -= (w1[ic11_r] * w2[ic32_r] - w1[ic11_i] * w2[ic32_i]) * w3[ic23_i]
921 + (w1[ic11_r] * w2[ic32_i] + w1[ic11_i] * w2[ic32_r]) * w3[ic23_r];
927 corr = cmplx(0.0, 0.0);
928 for (
int id = 0;
id <
ND; ++id) {
929 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
931 #endif // (USE_GROUP_SU3)
942 #if defined USE_GROUP_SU_N
945 const int NC2 = 2 *
NC;
946 const int NCD2 = NC2 *
ND;
949 const int Nvol = v1.
nvol();
955 assert(Nvol == v1.
nvol());
956 assert(Nvol == v2.
nvol());
957 assert(v1.
nex() == 1);
958 assert(v2.
nex() == 1);
961 const double *w1 = v1.
ptr(0);
962 const double *w2 = v2.
ptr(0);
966 for (
int id = 0;
id <
ND; ++id) {
973 for (
int id = 0;
id <
ND; ++id) {
978 for (
int t = 0; t < Nt; ++t) {
979 for (
int z = 0; z < Nz; ++z) {
980 for (
int x = 0; x < Nx; ++x) {
981 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
982 for (
int cc = 0; cc <
NC; ++cc) {
983 for (
int id = 0;
id <
ND; ++id) {
984 int ic1_r = 2 * cc + id1[id] + site;
985 int ic2_r = 2 * cc + id2[id] + site;
987 int ic1_i = 2 * cc + 1 + id1[id] + site;
988 int ic2_i = 2 * cc + 1 + id2[id] + site;
990 c_r[id] += w1[ic2_r] * w2[ic1_r]
991 + w1[ic2_i] * w2[ic1_i];
993 c_i[id] += -w1[ic2_r] * w2[ic1_i]
994 + w1[ic2_i] * w2[ic1_r];
1001 corr = cmplx(0.0, 0.0);
1002 for (
int id = 0;
id <
ND; ++id) {
1003 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1016 assert(corr_global.size() == Ly);
1018 std::vector<dcomplex> corr_local(Ny, 0.0);
1019 for (
int y = 0; y < Ny; ++y) {
1022 corr_local[y] += corr_y;
1030 const std::vector<int>& momentum_sink,
1032 const std::vector<int>& source_position,
1036 #if defined USE_GROUP_SU_N
1043 const int Nvol = v1.
nvol();
1054 assert(Nvol == v2.
nvol());
1055 assert(v1.
nex() == 1);
1056 assert(v2.
nex() == 1);
1057 assert(momentum_sink.size() ==
NDIM - 1);
1058 assert(source_position.size() ==
NDIM);
1060 const double *w1 = v1.
ptr(0);
1061 const double *w2 = v2.
ptr(0);
1065 for (
int id = 0;
id <
ND; ++id) {
1072 for (
int id = 0;
id <
ND; ++id) {
1077 static const double PI = 4.0 * atan(1.0);
1078 std::vector<double> p_unit(ND - 1);
1079 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1080 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1081 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1083 std::vector<int> ipe(ND);
1089 for (
int t = 0; t < Nt; ++t) {
1090 for (
int z = 0; z < Nz; ++z) {
1091 for (
int x = 0; x < Nx; ++x) {
1092 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1094 int x_global = x + ipe[0] * Nx;
1095 int z_global = z + ipe[2] * Nz;
1096 int t_global = t + ipe[3] * Nt;
1098 double p_x = p_unit[0] * (x_global - source_position[0]);
1099 double p_z = p_unit[1] * (z_global - source_position[2]);
1100 double p_t = p_unit[2] * (t_global - source_position[3]);
1102 double cos_p_xzt = cos(p_t + p_x + p_z);
1103 double sin_p_xzt = sin(p_t + p_x + p_z);
1105 for (
int cc = 0; cc <
NC; ++cc) {
1106 for (
int id = 0;
id <
ND; ++id) {
1107 int ic1_r = 2 * cc + id1[id] + site;
1108 int ic2_r = 2 * cc + id2[id] + site;
1110 int ic1_i = 2 * cc + 1 + id1[id] + site;
1111 int ic2_i = 2 * cc + 1 + id2[id] + site;
1113 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1114 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1117 c_r[id] += w1_w2_r * cos_p_xzt - w1_w2_i * sin_p_xzt;
1118 c_i[id] += w1_w2_r * sin_p_xzt + w1_w2_i * cos_p_xzt;
1125 corr = cmplx(0.0, 0.0);
1126 for (
int id = 0;
id <
ND; ++id) {
1127 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1134 const std::vector<int>& momentum_sink,
1136 const std::vector<int>& source_position,
1142 assert(corr_global.size() == Ly);
1144 std::vector<dcomplex> corr_local(Ny, 0.0);
1145 for (
int y = 0; y < Ny; ++y) {
1147 contract_at_y(corr_y, momentum_sink, gm_sink, source_position, v1, v2, y);
1148 corr_local[y] += corr_y;
1156 const std::vector<int>& momentum_sink,
1158 const std::vector<int>& source_position,
1162 #if defined USE_GROUP_SU_N
1169 const int Nvol = v1.
nvol();
1180 assert(Nvol == v2.
nvol());
1181 assert(v1.
nex() == 1);
1182 assert(v2.
nex() == 1);
1183 assert(momentum_sink.size() ==
NDIM - 1);
1184 assert(source_position.size() ==
NDIM);
1186 const double *w1 = v1.
ptr(0);
1187 const double *w2 = v2.
ptr(0);
1191 for (
int id = 0;
id <
ND; ++id) {
1198 for (
int id = 0;
id <
ND; ++id) {
1203 static const double PI = 4.0 * atan(1.0);
1204 std::vector<double> p_unit(ND - 1);
1205 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1206 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1207 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1209 std::vector<int> ipe(ND);
1216 for (
int t = 0; t < Nt; ++t) {
1217 for (
int z = 0; z < Nz; ++z) {
1218 for (
int x = 0; x < Nx; ++x) {
1219 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1221 int x_global = x + ipe[0] * Nx;
1222 int z_global = z + ipe[2] * Nz;
1223 int t_global = t + ipe[3] * Nt;
1225 double p_x = p_unit[0] * (x_global - source_position[0]);
1226 double p_z = p_unit[1] * (z_global - source_position[2]);
1227 double p_t = p_unit[2] * (t_global - source_position[3]);
1229 double cos_p_xzt = cos(p_t + p_x + p_z);
1231 double sin_p_xzt = 0;
1233 for (
int cc = 0; cc <
NC; ++cc) {
1234 for (
int id = 0;
id <
ND; ++id) {
1235 int ic1_r = 2 * cc + id1[id] + site;
1236 int ic2_r = 2 * cc + id2[id] + site;
1238 int ic1_i = 2 * cc + 1 + id1[id] + site;
1239 int ic2_i = 2 * cc + 1 + id2[id] + site;
1241 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1242 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1246 c_r[id] += w1_w2_r * cos_p_xzt - w1_w2_i * sin_p_xzt;
1247 c_i[id] += w1_w2_r * sin_p_xzt + w1_w2_i * cos_p_xzt;
1254 corr = cmplx(0.0, 0.0);
1255 for (
int id = 0;
id <
ND; ++id) {
1256 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1263 const std::vector<int>& momentum_sink,
1265 const std::vector<int>& source_position,
1271 assert(corr_global.size() == Ly);
1273 std::vector<dcomplex> corr_local(Ny, 0.0);
1274 for (
int y = 0; y < Ny; ++y) {
1277 corr_local[y] += corr_y;
1290 #if defined USE_GROUP_SU_N
1293 const int NC2 = 2 *
NC;
1294 const int NCD2 = NC2 *
ND;
1301 const int Nvol = v1.
nvol();
1303 assert(Nvol == v1.
nvol());
1304 assert(Nvol == v2.
nvol());
1305 assert(v1.
nex() == 1);
1306 assert(v2.
nex() == 1);
1309 const double *w1 = v1.
ptr(0);
1310 const double *w2 = v2.
ptr(0);
1314 for (
int id = 0;
id <
ND; ++id) {
1321 for (
int id = 0;
id <
ND; ++id) {
1326 for (
int t = 0; t < Nt; ++t) {
1327 for (
int y = 0; y < Ny; ++y) {
1328 for (
int x = 0; x < Nx; ++x) {
1329 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1330 for (
int cc = 0; cc <
NC; ++cc) {
1331 for (
int id = 0;
id <
ND; ++id) {
1332 int ic1_r = 2 * cc + id1[id] + site;
1333 int ic2_r = 2 * cc + id2[id] + site;
1335 int ic1_i = 2 * cc + 1 + id1[id] + site;
1336 int ic2_i = 2 * cc + 1 + id2[id] + site;
1338 c_r[id] += w1[ic2_r] * w2[ic1_r]
1339 + w1[ic2_i] * w2[ic1_i];
1341 c_i[id] += -w1[ic2_r] * w2[ic1_i]
1342 + w1[ic2_i] * w2[ic1_r];
1349 corr = cmplx(0.0, 0.0);
1350 for (
int id = 0;
id <
ND; ++id) {
1351 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1364 assert(corr_global.size() == Lz);
1366 std::vector<dcomplex> corr_local(Nz, 0.0);
1367 for (
int z = 0; z < Nz; ++z) {
1370 corr_local[z] += corr_z;
1378 const std::vector<int>& momentum_sink,
1380 const std::vector<int>& source_position,
1384 #if defined USE_GROUP_SU_N
1391 const int Nvol = v1.
nvol();
1402 assert(Nvol == v2.
nvol());
1403 assert(v1.
nex() == 1);
1404 assert(v2.
nex() == 1);
1405 assert(momentum_sink.size() ==
NDIM - 1);
1406 assert(source_position.size() ==
NDIM);
1408 const double *w1 = v1.
ptr(0);
1409 const double *w2 = v2.
ptr(0);
1413 for (
int id = 0;
id <
ND; ++id) {
1420 for (
int id = 0;
id <
ND; ++id) {
1425 static const double PI = 4.0 * atan(1.0);
1426 std::vector<double> p_unit(ND - 1);
1427 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1428 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1429 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1431 std::vector<int> ipe(ND);
1437 for (
int t = 0; t < Nt; ++t) {
1438 for (
int y = 0; y < Ny; ++y) {
1439 for (
int x = 0; x < Nx; ++x) {
1440 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1442 int x_global = x + ipe[0] * Nx;
1443 int y_global = y + ipe[1] * Ny;
1444 int t_global = t + ipe[3] * Nt;
1446 double p_x = p_unit[0] * (x_global - source_position[0]);
1447 double p_y = p_unit[1] * (y_global - source_position[1]);
1448 double p_t = p_unit[2] * (t_global - source_position[3]);
1450 double cos_p_xyt = cos(p_t + p_x + p_y);
1451 double sin_p_xyt = sin(p_t + p_x + p_y);
1453 for (
int cc = 0; cc <
NC; ++cc) {
1454 for (
int id = 0;
id <
ND; ++id) {
1455 int ic1_r = 2 * cc + id1[id] + site;
1456 int ic2_r = 2 * cc + id2[id] + site;
1458 int ic1_i = 2 * cc + 1 + id1[id] + site;
1459 int ic2_i = 2 * cc + 1 + id2[id] + site;
1461 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1462 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1465 c_r[id] += w1_w2_r * cos_p_xyt - w1_w2_i * sin_p_xyt;
1466 c_i[id] += w1_w2_r * sin_p_xyt + w1_w2_i * cos_p_xyt;
1473 corr = cmplx(0.0, 0.0);
1474 for (
int id = 0;
id <
ND; ++id) {
1475 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1482 const std::vector<int>& momentum_sink,
1484 const std::vector<int>& source_position,
1490 assert(corr_global.size() == Lz);
1492 std::vector<dcomplex> corr_local(Nz, 0.0);
1493 for (
int z = 0; z < Nz; ++z) {
1495 contract_at_z(corr_z, momentum_sink, gm_sink, source_position, v1, v2, z);
1496 corr_local[z] += corr_z;
1504 const std::vector<int>& momentum_sink,
1506 const std::vector<int>& source_position,
1510 #if defined USE_GROUP_SU_N
1517 const int Nvol = v1.
nvol();
1528 assert(Nvol == v2.
nvol());
1529 assert(v1.
nex() == 1);
1530 assert(v2.
nex() == 1);
1531 assert(momentum_sink.size() ==
NDIM - 1);
1532 assert(source_position.size() ==
NDIM);
1534 const double *w1 = v1.
ptr(0);
1535 const double *w2 = v2.
ptr(0);
1539 for (
int id = 0;
id <
ND; ++id) {
1546 for (
int id = 0;
id <
ND; ++id) {
1551 static const double PI = 4.0 * atan(1.0);
1552 std::vector<double> p_unit(ND - 1);
1553 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1554 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1555 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1557 std::vector<int> ipe(ND);
1564 for (
int t = 0; t < Nt; ++t) {
1565 for (
int y = 0; y < Ny; ++y) {
1566 for (
int x = 0; x < Nx; ++x) {
1567 int site = NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1569 int x_global = x + ipe[0] * Nx;
1570 int y_global = y + ipe[1] * Ny;
1571 int t_global = t + ipe[3] * Nt;
1573 double p_x = p_unit[0] * (x_global - source_position[0]);
1574 double p_y = p_unit[1] * (y_global - source_position[1]);
1575 double p_t = p_unit[2] * (t_global - source_position[2]);
1577 double cos_p_xyt = cos(p_t + p_x + p_y);
1579 double sin_p_xyt = 0;
1581 for (
int cc = 0; cc <
NC; ++cc) {
1582 for (
int id = 0;
id <
ND; ++id) {
1583 int ic1_r = 2 * cc + id1[id] + site;
1584 int ic2_r = 2 * cc + id2[id] + site;
1586 int ic1_i = 2 * cc + 1 + id1[id] + site;
1587 int ic2_i = 2 * cc + 1 + id2[id] + site;
1589 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1590 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1594 c_r[id] += w1_w2_r * cos_p_xyt - w1_w2_i * sin_p_xyt;
1595 c_i[id] += w1_w2_r * sin_p_xyt + w1_w2_i * cos_p_xyt;
1602 corr = cmplx(0.0, 0.0);
1603 for (
int id = 0;
id <
ND; ++id) {
1604 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1611 const std::vector<int>& momentum_sink,
1613 const std::vector<int>& source_position,
1619 assert(corr_global.size() == Lz);
1621 std::vector<dcomplex> corr_local(Nz, 0.0);
1622 for (
int z = 0; z < Nz; ++z) {
1625 corr_local[z] += corr_z;
1633 std::vector<dcomplex>& corr_local)
1638 assert(corr_global.size() == Lx);
1639 assert(corr_local.size() == Nx);
1641 std::vector<dcomplex> corr_tmp(Lx, 0);
1645 for (
int x = 0; x < Nx; ++x) {
1646 int x2 = x + ipex * Nx;
1647 corr_tmp[x2] = corr_local[x];
1650 for (
int x = 0; x < Lx; ++x) {
1653 corr_global[x] = cmplx(crr, cri);
1660 std::vector<dcomplex>& corr_local)
1665 assert(corr_global.size() == Ly);
1666 assert(corr_local.size() == Ny);
1668 std::vector<dcomplex> corr_tmp(Ly, 0);
1672 for (
int y = 0; y < Ny; ++y) {
1673 int y2 = y + ipey * Ny;
1674 corr_tmp[y2] = corr_local[y];
1677 for (
int y = 0; y < Ly; ++y) {
1680 corr_global[y] = cmplx(crr, cri);
1687 std::vector<dcomplex>& corr_local)
1692 assert(corr_global.size() == Lz);
1693 assert(corr_local.size() == Nz);
1695 std::vector<dcomplex> corr_tmp(Lz);
1699 for (
int z = 0; z < Nz; ++z) {
1700 int z2 = z + ipez * Nz;
1701 corr_tmp[z2] = corr_local[z];
1704 for (
int z = 0; z < Lz; ++z) {
1707 corr_global[z] = cmplx(crr, cri);
1714 std::vector<dcomplex>& corr_local)
1719 assert(corr_global.size() == Lt);
1720 assert(corr_local.size() == Nt);
1722 std::vector<dcomplex> corr_tmp(Lt, 0);
1726 for (
int t = 0; t < Nt; ++t) {
1727 int t_global = t + ipe_t * Nt;
1728 corr_tmp[t_global] = corr_local[t];
1731 for (
int t_global = 0; t_global < Lt; ++t_global) {
1734 corr_global[t_global] = cmplx(cr_r, cr_i);
const double * ptr(const int jin, const int site, const int jex) const
void global_corr_z(std::vector< dcomplex > &corr_global, std::vector< dcomplex > &corr_local)
transform node-local correlator in z to global.
void global_corr_x(std::vector< dcomplex > &corr_global, std::vector< dcomplex > &corr_local)
transform node-local correlator in x to global.
void contract_at_t(dcomplex &corr, const GammaMatrix &gm_sink, const Field_F &v1, const Field_F &v2, const int time)
Contraction of hadron for 4-spinor fermion.
void contract_at_x_cos(dcomplex &corr, const std::vector< int > &momentum_sink, const GammaMatrix &gm_sink, const std::vector< int > &source_position, const Field_F &v1, const Field_F &v2, const int x)
contraction for meson at a given x with Fourier transformation, where (p_y,p_z,p_t) is given by momen...
static int ipe(const int dir)
logical coordinate of current proc.
void contract_at_y_cos(dcomplex &corr, const std::vector< int > &momentum_sink, const GammaMatrix &gm_sink, const std::vector< int > &source_position, const Field_F &v1, const Field_F &v2, const int y)
contraction for meson at a given y with Fourier transformation, where (p_x,p_z,p_t) is given by momen...
void contract_at_z_cos(dcomplex &corr, const std::vector< int > &momentum_sink, const GammaMatrix &gm_sink, const std::vector< int > &source_position, const Field_F &v1, const Field_F &v2, const int z)
contraction for meson at a given z with Fourier transformation, where (p_x,p_y,p_t) is given by momen...
Wilson-type fermion field.
void contract_at_z(dcomplex &corr, const GammaMatrix &gm_sink, const Field_F &v1, const Field_F &v2, const int z)
contraction for meson at a given z.
void contract_at_x(dcomplex &corr, const GammaMatrix &gm_sink, const Field_F &v1, const Field_F &v2, int x)
void global_corr_t(std::vector< dcomplex > &corr_global, std::vector< dcomplex > &corr_local)
transform node-local correlator in t to global.
void global_corr_y(std::vector< dcomplex > &corr_global, std::vector< dcomplex > &corr_local)
transform node-local correlator in y to global.
void contract_at_t_cos(dcomplex &corr, const std::vector< int > &momentum_sink, const GammaMatrix &gm_sink, const std::vector< int > &source_position, const Field_F &v1, const Field_F &v2, const int time)
static int reduce_sum(int count, double *recv_buf, double *send_buf, int pattern=0)
make a global sum of an array of double over the communicator. pattern specifies the dimensions to be...
dcomplex value(int row) const
void contract_at_y(dcomplex &corr, const GammaMatrix &gm_sink, const Field_F &v1, const Field_F &v2, const int y)
contraction for meson at a given y.