19 #if defined USE_GROUP_SU3
29 #elif defined USE_GROUP_SU2
50 assert(Nvol == v1.
nvol());
51 assert(Nvol == v2.
nvol());
55 std::vector<int> gm_index(Nd);
56 std::vector<double> corr_r(Nd), corr_i(Nd);
58 for (
int i = 0; i < Nd; ++i) {
59 gm_index[i] = gm_sink.
index(i);
64 for (
int z = 0; z < Nz; ++z) {
65 for (
int y = 0; y < Ny; ++y) {
66 for (
int x = 0; x < Nx; ++x) {
67 int site = index.
site(x, y, z, time);
69 for (
int s0 = 0; s0 < Nd; ++s0) {
70 int s1 = gm_index[s0];
72 for (
int c1 = 0; c1 < Nc; ++c1) {
73 corr_r[s0] += v1.
cmp_r(c1, s1, site) * v2.
cmp_r(c1, s0, site)
74 + v1.
cmp_i(c1, s1, site) * v2.
cmp_i(c1, s0, site);
76 corr_i[s0] += -v1.
cmp_r(c1, s1, site) * v2.
cmp_i(c1, s0, site)
77 + v1.
cmp_i(c1, s1, site) * v2.
cmp_r(c1, s0, site);
84 corr = cmplx(0.0, 0.0);
85 for (
int s0 = 0; s0 < Nd; ++s0) {
86 corr += gm_sink.
value(s0) * cmplx(corr_r[s0], corr_i[s0]);
99 assert(corr_global.size() == Lt);
101 std::vector<dcomplex> corr_local(Nt, 0.0);
102 for (
int t = 0; t < Nt; ++t) {
105 corr_local[t] += corr_t;
113 const std::vector<int>& momentum_sink,
115 const std::vector<int>& source_position,
131 assert(Nvol == v1.
nvol());
132 assert(Nvol == v2.
nvol());
134 assert(momentum_sink.size() == Ndim - 1);
137 std::vector<int> gm_index(Nd);
138 std::vector<double> corr_r(Nd), corr_i(Nd);
140 for (
int i = 0; i < Nd; ++i) {
141 gm_index[i] = gm_sink.
index(i);
146 static const double PI = 4.0 * atan(1.0);
147 std::vector<double> p_unit(Ndim - 1);
148 p_unit[0] = (2.0 * PI / Lx) * momentum_sink[0];
149 p_unit[1] = (2.0 * PI / Ly) * momentum_sink[1];
150 p_unit[2] = (2.0 * PI / Lz) * momentum_sink[2];
152 std::vector<int> ipe(Ndim - 1);
157 for (
int z = 0; z < Nz; ++z) {
158 for (
int y = 0; y < Ny; ++y) {
159 for (
int x = 0; x < Nx; ++x) {
160 int site = index.
site(x, y, z, time);
162 int x_global = x + ipe[0] * Nx;
163 int y_global = y + ipe[1] * Ny;
164 int z_global = z + ipe[2] * Nz;
166 double p_x = p_unit[0] * (x_global - source_position[0]);
167 double p_y = p_unit[1] * (y_global - source_position[1]);
168 double p_z = p_unit[2] * (z_global - source_position[2]);
170 double cos_p_xyz = cos(p_x + p_y + p_z);
171 double sin_p_xyz = sin(p_x + p_y + p_z);
173 for (
int s0 = 0; s0 < Nd; ++s0) {
174 int s1 = gm_index[s0];
176 double v1_v2_r = 0.0;
177 double v1_v2_i = 0.0;
179 for (
int c1 = 0; c1 < Nc; ++c1) {
180 v1_v2_r += v1.
cmp_r(c1, s1, site) * v2.
cmp_r(c1, s0, site)
181 + v1.
cmp_i(c1, s1, site) * v2.
cmp_i(c1, s0, site);
183 v1_v2_i += -v1.
cmp_r(c1, s1, site) * v2.
cmp_i(c1, s0, site)
184 + v1.
cmp_i(c1, s1, site) * v2.
cmp_r(c1, s0, site);
188 corr_r[s0] += v1_v2_r * cos_p_xyz - v1_v2_i * sin_p_xyz;
189 corr_i[s0] += v1_v2_r * sin_p_xyz + v1_v2_i * cos_p_xyz;
195 corr = cmplx(0.0, 0.0);
196 for (
int s0 = 0; s0 < Nd; ++s0) {
197 corr += gm_sink.
value(s0) * cmplx(corr_r[s0], corr_i[s0]);
204 const std::vector<int>& momentum_sink,
206 const std::vector<int>& source_position,
212 assert(corr_global.size() == Lt);
214 std::vector<dcomplex> corr_local(Nt, 0.0);
215 for (
int t = 0; t < Nt; ++t) {
217 contract_at_t(corr_t, momentum_sink, gm_sink, source_position, v1, v2, t);
218 corr_local[t] += corr_t;
226 const std::vector<int>& momentum_sink,
228 const std::vector<int>& source_position,
232 #if defined USE_GROUP_SU_N
235 const int NC2 = 2 *
NC;
239 const int Nvol = v1.
nvol();
249 assert(Nvol == v2.
nvol());
250 assert(v1.
nex() == 1);
251 assert(v2.
nex() == 1);
252 assert(momentum_sink.size() == Ndim - 1);
254 const double *w1 = v1.
ptr(0);
255 const double *w2 = v2.
ptr(0);
259 for (
int id = 0;
id <
ND; ++id) {
266 for (
int id = 0;
id <
ND; ++id) {
271 static const double PI = 4.0 * atan(1.0);
272 std::vector<double> p_unit(
ND - 1);
273 p_unit[0] = (2.0 * PI / Lx) * momentum_sink[0];
274 p_unit[1] = (2.0 * PI / Ly) * momentum_sink[1];
275 p_unit[2] = (2.0 * PI / Lz) * momentum_sink[2];
277 std::vector<int> ipe(
ND - 1);
283 for (
int ss = 0; ss < Nvol_s; ++ss) {
284 int site =
NCD2 * (ss + time * Nvol_s);
287 int y = ss % (Nx * Ny) / Nx;
288 int z = ss % (Nx * Ny * Nz) / (Nx * Ny);
290 int x_global = x + ipe[0] * Nx;
291 int y_global = y + ipe[1] * Ny;
292 int z_global = z + ipe[2] * Nz;
294 double p_x = p_unit[0] * (x_global - source_position[0]);
295 double p_y = p_unit[1] * (y_global - source_position[1]);
296 double p_z = p_unit[2] * (z_global - source_position[2]);
298 double cos_p_xyz = cos(p_x + p_y + p_z);
300 double sin_p_xyz = 0;
302 for (
int cc = 0; cc <
NC; ++cc) {
303 for (
int id = 0;
id <
ND; ++id) {
304 int ic1_r = 2 * cc + id1[id] + site;
305 int ic2_r = 2 * cc + id2[id] + site;
307 int ic1_i = 2 * cc + 1 + id1[id] + site;
308 int ic2_i = 2 * cc + 1 + id2[id] + site;
310 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
311 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
315 c_r[id] += w1_w2_r * cos_p_xyz - w1_w2_i * sin_p_xyz;
316 c_i[id] += w1_w2_r * sin_p_xyz + w1_w2_i * cos_p_xyz;
321 corr = cmplx(0.0, 0.0);
322 for (
int id = 0;
id <
ND; ++id) {
323 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
330 const std::vector<int>& momentum_sink,
332 const std::vector<int>& source_position,
338 assert(corr_global.size() == Lt);
340 std::vector<dcomplex> corr_local(Nt, 0.0);
341 for (
int t = 0; t < Nt; ++t) {
344 corr_local[t] += corr_t;
357 #if defined USE_GROUP_SU3
367 assert(Nvol == v1.
nvol());
368 assert(Nvol == v2.
nvol());
369 assert(Nvol == v3.
nvol());
373 std::vector<int> gm_index(Nd);
374 std::vector<double> c_r(Nd), c_i(Nd);
376 for (
int i = 0; i < Nd; ++i) {
377 gm_index[i] = gm_sink.
index(i);
382 for (
int z = 0; z < Nz; ++z) {
383 for (
int y = 0; y < Ny; ++y) {
384 for (
int x = 0; x < Nx; ++x) {
385 int site = index.
site(x, y, z, time);
387 for (
int d1 = 0; d1 < Nd; ++d1) {
388 int d2 = gm_index[d1];
391 c_r[d1] += (v1.
cmp_r(C1, d1, site) * v2.
cmp_r(C2, d2, site)
392 - v1.
cmp_i(C1, d1, site) * v2.
cmp_i(C2, d2, site)) * v3.
cmp_r(C3, d3, site)
393 - (v1.
cmp_r(C1, d1, site) * v2.
cmp_i(C2, d2, site)
394 + v1.
cmp_i(C1, d1, site) * v2.
cmp_r(C2, d2, site)) * v3.
cmp_i(C3, d3, site);
395 c_i[d1] += (v1.
cmp_r(C1, d1, site) * v2.
cmp_r(C2, d2, site)
396 - v1.
cmp_i(C1, d1, site) * v2.
cmp_i(C2, d2, site)) * v3.
cmp_i(C3, d3, site)
397 + (v1.
cmp_r(C1, d1, site) * v2.
cmp_i(C2, d2, site)
398 + v1.
cmp_i(C1, d1, site) * v2.
cmp_r(C2, d2, site)) * v3.
cmp_r(C3, d3, site);
400 c_r[d1] += (v1.
cmp_r(C2, d1, site) * v2.
cmp_r(C3, d2, site)
401 - v1.
cmp_i(C2, d1, site) * v2.
cmp_i(C3, d2, site)) * v3.
cmp_r(C1, d3, site)
402 - (v1.
cmp_r(C2, d1, site) * v2.
cmp_i(C3, d2, site)
403 + v1.
cmp_i(C2, d1, site) * v2.
cmp_r(C3, d2, site)) * v3.
cmp_i(C1, d3, site);
404 c_i[d1] += (v1.
cmp_r(C2, d1, site) * v2.
cmp_r(C3, d2, site)
405 - v1.
cmp_i(C2, d1, site) * v2.
cmp_i(C3, d2, site)) * v3.
cmp_i(C1, d3, site)
406 + (v1.
cmp_r(C2, d1, site) * v2.
cmp_i(C3, d2, site)
407 + v1.
cmp_i(C2, d1, site) * v2.
cmp_r(C3, d2, site)) * v3.
cmp_r(C1, d3, site);
409 c_r[d1] += (v1.
cmp_r(C3, d1, site) * v2.
cmp_r(C1, d2, site)
410 - v1.
cmp_i(C3, d1, site) * v2.
cmp_i(C1, d2, site)) * v3.
cmp_r(C2, d3, site)
411 - (v1.
cmp_r(C3, d1, site) * v2.
cmp_i(C1, d2, site)
412 + v1.
cmp_i(C3, d1, site) * v2.
cmp_r(C1, d2, site)) * v3.
cmp_i(C2, d3, site);
413 c_i[d1] += (v1.
cmp_r(C3, d1, site) * v2.
cmp_r(C1, d2, site)
414 - v1.
cmp_i(C3, d1, site) * v2.
cmp_i(C1, d2, site)) * v3.
cmp_i(C2, d3, site)
415 + (v1.
cmp_r(C3, d1, site) * v2.
cmp_i(C1, d2, site)
416 + v1.
cmp_i(C3, d1, site) * v2.
cmp_r(C1, d2, site)) * v3.
cmp_r(C2, d3, site);
418 c_r[d1] -= (v1.
cmp_r(C3, d1, site) * v2.
cmp_r(C2, d2, site)
419 - v1.
cmp_i(C3, d1, site) * v2.
cmp_i(C2, d2, site)) * v3.
cmp_r(C1, d3, site)
420 - (v1.
cmp_r(C3, d1, site) * v2.
cmp_i(C2, d2, site)
421 + v1.
cmp_i(C3, d1, site) * v2.
cmp_r(C2, d2, site)) * v3.
cmp_i(C1, d3, site);
422 c_i[d1] -= (v1.
cmp_r(C3, d1, site) * v2.
cmp_r(C2, d2, site)
423 - v1.
cmp_i(C3, d1, site) * v2.
cmp_i(C2, d2, site)) * v3.
cmp_i(C1, d3, site)
424 + (v1.
cmp_r(C3, d1, site) * v2.
cmp_i(C2, d2, site)
425 + v1.
cmp_i(C3, d1, site) * v2.
cmp_r(C2, d2, site)) * v3.
cmp_r(C1, d3, site);
427 c_r[d1] -= (v1.
cmp_r(C2, d1, site) * v2.
cmp_r(C1, d2, site)
428 - v1.
cmp_i(C2, d1, site) * v2.
cmp_i(C1, d2, site)) * v3.
cmp_r(C3, d3, site)
429 - (v1.
cmp_r(C2, d1, site) * v2.
cmp_i(C1, d2, site)
430 + v1.
cmp_i(C2, d1, site) * v2.
cmp_r(C1, d2, site)) * v3.
cmp_i(C3, d3, site);
431 c_i[d1] -= (v1.
cmp_r(C2, d1, site) * v2.
cmp_r(C1, d2, site)
432 - v1.
cmp_i(C2, d1, site) * v2.
cmp_i(C1, d2, site)) * v3.
cmp_i(C3, d3, site)
433 + (v1.
cmp_r(C2, d1, site) * v2.
cmp_i(C1, d2, site)
434 + v1.
cmp_i(C2, d1, site) * v2.
cmp_r(C1, d2, site)) * v3.
cmp_r(C3, d3, site);
436 c_r[d1] -= (v1.
cmp_r(C1, d1, site) * v2.
cmp_r(C3, d2, site)
437 - v1.
cmp_i(C1, d1, site) * v2.
cmp_i(C3, d2, site)) * v3.
cmp_r(C2, d3, site)
438 - (v1.
cmp_r(C1, d1, site) * v2.
cmp_i(C3, d2, site)
439 + v1.
cmp_i(C1, d1, site) * v2.
cmp_r(C3, d2, site)) * v3.
cmp_i(C2, d3, site);
440 c_i[d1] -= (v1.
cmp_r(C1, d1, site) * v2.
cmp_r(C3, d2, site)
441 - v1.
cmp_i(C1, d1, site) * v2.
cmp_i(C3, d2, site)) * v3.
cmp_i(C2, d3, site)
442 + (v1.
cmp_r(C1, d1, site) * v2.
cmp_i(C3, d2, site)
443 + v1.
cmp_i(C1, d1, site) * v2.
cmp_r(C3, d2, site)) * v3.
cmp_r(C2, d3, site);
449 corr = cmplx(0.0, 0.0);
450 for (
int s0 = 0; s0 < Nd; ++s0) {
451 corr += gm_sink.
value(s0) * cmplx(c_r[s0], c_i[s0]);
453 #endif // (USE_GROUP_SU3)
463 #if defined USE_GROUP_SU_N
466 const int NC2 = 2 *
NC;
470 const int Nvol = v1.
nvol();
477 assert(Nvol == v2.
nvol());
478 assert(v1.
nex() == 1);
479 assert(v2.
nex() == 1);
481 const double *w1 = v1.
ptr(0);
482 const double *w2 = v2.
ptr(0);
486 for (
int id = 0;
id <
ND; ++id) {
493 for (
int id = 0;
id <
ND; ++id) {
498 for (
int t = 0; t < Nt; ++t) {
499 for (
int z = 0; z < Nz; ++z) {
500 for (
int y = 0; y < Ny; ++y) {
501 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
503 for (
int cc = 0; cc <
NC; ++cc) {
504 for (
int id = 0;
id <
ND; ++id) {
505 int ic1_r = 2 * cc + id1[id] + site;
506 int ic2_r = 2 * cc + id2[id] + site;
508 int ic1_i = 2 * cc + 1 + id1[id] + site;
509 int ic2_i = 2 * cc + 1 + id2[id] + site;
511 c_r[id] += w1[ic2_r] * w2[ic1_r]
512 + w1[ic2_i] * w2[ic1_i];
514 c_i[id] += -w1[ic2_r] * w2[ic1_i]
515 + w1[ic2_i] * w2[ic1_r];
522 corr = cmplx(0.0, 0.0);
523 for (
int id = 0;
id <
ND; ++id) {
524 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
537 assert(corr_global.size() == Lx);
539 std::vector<dcomplex> corr_local(Nx, 0.0);
540 for (
int x = 0; x < Nx; ++x) {
543 corr_local[x] += corr_x;
551 const std::vector<int>& momentum_sink,
553 const std::vector<int>& source_position,
557 #if defined USE_GROUP_SU_N
564 const int Nvol = v1.
nvol();
576 assert(Nvol == v2.
nvol());
577 assert(v1.
nex() == 1);
578 assert(v2.
nex() == 1);
579 assert(momentum_sink.size() == Ndim - 1);
580 assert(source_position.size() == Ndim);
582 const double *w1 = v1.
ptr(0);
583 const double *w2 = v2.
ptr(0);
587 for (
int id = 0;
id <
ND; ++id) {
594 for (
int id = 0;
id <
ND; ++id) {
599 static const double PI = 4.0 * atan(1.0);
600 std::vector<double> p_unit(
ND - 1);
601 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
602 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
603 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
605 std::vector<int> ipe(
ND);
611 for (
int t = 0; t < Nt; ++t) {
612 for (
int z = 0; z < Nz; ++z) {
613 for (
int y = 0; y < Ny; ++y) {
614 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
616 int y_global = y + ipe[1] * Ny;
617 int z_global = z + ipe[2] * Nz;
618 int t_global = t + ipe[3] * Nt;
620 double p_y = p_unit[0] * (y_global - source_position[1]);
621 double p_z = p_unit[1] * (z_global - source_position[2]);
622 double p_t = p_unit[2] * (t_global - source_position[3]);
624 double cos_p_yzt = cos(p_t + p_y + p_z);
625 double sin_p_yzt = sin(p_t + p_y + p_z);
627 for (
int cc = 0; cc <
NC; ++cc) {
628 for (
int id = 0;
id <
ND; ++id) {
629 int ic1_r = 2 * cc + id1[id] + site;
630 int ic2_r = 2 * cc + id2[id] + site;
632 int ic1_i = 2 * cc + 1 + id1[id] + site;
633 int ic2_i = 2 * cc + 1 + id2[id] + site;
635 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
636 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
639 c_r[id] += w1_w2_r * cos_p_yzt - w1_w2_i * sin_p_yzt;
640 c_i[id] += w1_w2_r * sin_p_yzt + w1_w2_i * cos_p_yzt;
647 corr = cmplx(0.0, 0.0);
648 for (
int id = 0;
id <
ND; ++id) {
649 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
656 const std::vector<int>& momentum_sink,
658 const std::vector<int>& source_position,
664 assert(corr_global.size() == Lx);
666 std::vector<dcomplex> corr_local(Nx, 0.0);
667 for (
int x = 0; x < Nx; ++x) {
669 contract_at_x(corr_x, momentum_sink, gm_sink, source_position, v1, v2, x);
670 corr_local[x] += corr_x;
678 const std::vector<int>& momentum_sink,
680 const std::vector<int>& source_position,
684 #if defined USE_GROUP_SU_N
691 const int Nvol = v1.
nvol();
703 assert(Nvol == v2.
nvol());
704 assert(v1.
nex() == 1);
705 assert(v2.
nex() == 1);
706 assert(momentum_sink.size() == Ndim - 1);
707 assert(source_position.size() == Ndim);
709 const double *w1 = v1.
ptr(0);
710 const double *w2 = v2.
ptr(0);
714 for (
int id = 0;
id <
ND; ++id) {
721 for (
int id = 0;
id <
ND; ++id) {
726 static const double PI = 4.0 * atan(1.0);
727 std::vector<double> p_unit(
ND - 1);
728 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
729 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
730 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
732 std::vector<int> ipe(
ND);
739 for (
int t = 0; t < Nt; ++t) {
740 for (
int z = 0; z < Nz; ++z) {
741 for (
int y = 0; y < Ny; ++y) {
742 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
744 int y_global = y + ipe[1] * Ny;
745 int z_global = z + ipe[2] * Nz;
746 int t_global = t + ipe[3] * Nt;
748 double p_y = p_unit[0] * (y_global - source_position[1]);
749 double p_z = p_unit[1] * (z_global - source_position[2]);
750 double p_t = p_unit[2] * (t_global - source_position[3]);
752 double cos_p_yzt = cos(p_t + p_y + p_z);
754 double sin_p_yzt = 0;
756 for (
int cc = 0; cc <
NC; ++cc) {
757 for (
int id = 0;
id <
ND; ++id) {
758 int ic1_r = 2 * cc + id1[id] + site;
759 int ic2_r = 2 * cc + id2[id] + site;
761 int ic1_i = 2 * cc + 1 + id1[id] + site;
762 int ic2_i = 2 * cc + 1 + id2[id] + site;
764 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
765 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
769 c_r[id] += w1_w2_r * cos_p_yzt - w1_w2_i * sin_p_yzt;
770 c_i[id] += w1_w2_r * sin_p_yzt + w1_w2_i * cos_p_yzt;
777 corr = cmplx(0.0, 0.0);
778 for (
int id = 0;
id <
ND; ++id) {
779 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
786 const std::vector<int>& momentum_sink,
788 const std::vector<int>& source_position,
794 assert(corr_global.size() == Lx);
796 std::vector<dcomplex> corr_local(Nx, 0.0);
797 for (
int x = 0; x < Nx; ++x) {
800 corr_local[x] += corr_x;
813 #if defined USE_GROUP_SU3
814 const int Nvol = v1.
nvol();
821 assert(Nvol == v2.
nvol());
822 assert(Nvol == v3.
nvol());
823 assert(v1.
nex() == 1);
824 assert(v2.
nex() == 1);
825 assert(v3.
nex() == 1);
827 const double *w1 = v1.
ptr(0);
828 const double *w2 = v2.
ptr(0);
829 const double *w3 = v3.
ptr(0);
833 for (
int id = 0;
id <
ND; ++id) {
837 int id3 = i_alpha *
NC2;
841 for (
int id = 0;
id <
ND; ++id) {
847 for (
int t = 0; t < Nt; ++t) {
848 for (
int z = 0; z < Nz; ++z) {
849 for (
int y = 0; y < Ny; ++y) {
850 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
852 for (
int id = 0;
id <
ND; ++id) {
853 int ic11_r = C1 + id1[id] + site;
854 int ic22_r = C2 + id2[id] + site;
855 int ic33_r = C3 + id3 + site;
857 int ic11_i = C1 + 1 + id1[id] + site;
858 int ic22_i = C2 + 1 + id2[id] + site;
859 int ic33_i = C3 + 1 + id3 + site;
861 int ic21_r = C2 + id1[id] + site;
862 int ic32_r = C3 + id2[id] + site;
863 int ic13_r = C1 + id3 + site;
865 int ic21_i = C2 + 1 + id1[id] + site;
866 int ic32_i = C3 + 1 + id2[id] + site;
867 int ic13_i = C1 + 1 + id3 + site;
869 int ic31_r = C3 + id1[id] + site;
870 int ic12_r = C1 + id2[id] + site;
871 int ic23_r = C2 + id3 + site;
873 int ic31_i = C3 + 1 + id1[id] + site;
874 int ic12_i = C1 + 1 + id2[id] + site;
875 int ic23_i = C2 + 1 + id3 + site;
877 c_r[id] += (w1[ic11_r] * w2[ic22_r] - w1[ic11_i] * w2[ic22_i]) * w3[ic33_r]
878 - (w1[ic11_r] * w2[ic22_i] + w1[ic11_i] * w2[ic22_r]) * w3[ic33_i];
879 c_i[id] += (w1[ic11_r] * w2[ic22_r] - w1[ic11_i] * w2[ic22_i]) * w3[ic33_i]
880 + (w1[ic11_r] * w2[ic22_i] + w1[ic11_i] * w2[ic22_r]) * w3[ic33_r];
882 c_r[id] += (w1[ic21_r] * w2[ic32_r] - w1[ic21_i] * w2[ic32_i]) * w3[ic13_r]
883 - (w1[ic21_r] * w2[ic32_i] + w1[ic21_i] * w2[ic32_r]) * w3[ic13_i];
884 c_i[id] += (w1[ic21_r] * w2[ic32_r] - w1[ic21_i] * w2[ic32_i]) * w3[ic13_i]
885 + (w1[ic21_r] * w2[ic32_i] + w1[ic21_i] * w2[ic32_r]) * w3[ic13_r];
887 c_r[id] += (w1[ic31_r] * w2[ic12_r] - w1[ic31_i] * w2[ic12_i]) * w3[ic23_r]
888 - (w1[ic31_r] * w2[ic12_i] + w1[ic31_i] * w2[ic12_r]) * w3[ic23_i];
889 c_i[id] += (w1[ic31_r] * w2[ic12_r] - w1[ic31_i] * w2[ic12_i]) * w3[ic23_i]
890 + (w1[ic31_r] * w2[ic12_i] + w1[ic31_i] * w2[ic12_r]) * w3[ic23_r];
892 c_r[id] -= (w1[ic31_r] * w2[ic22_r] - w1[ic31_i] * w2[ic22_i]) * w3[ic13_r]
893 - (w1[ic31_r] * w2[ic22_i] + w1[ic31_i] * w2[ic22_r]) * w3[ic13_i];
894 c_i[id] -= (w1[ic31_r] * w2[ic22_r] - w1[ic31_i] * w2[ic22_i]) * w3[ic13_i]
895 + (w1[ic31_r] * w2[ic22_i] + w1[ic31_i] * w2[ic22_r]) * w3[ic13_r];
897 c_r[id] -= (w1[ic21_r] * w2[ic12_r] - w1[ic21_i] * w2[ic12_i]) * w3[ic33_r]
898 - (w1[ic21_r] * w2[ic12_i] + w1[ic21_i] * w2[ic12_r]) * w3[ic33_i];
899 c_i[id] -= (w1[ic21_r] * w2[ic12_r] - w1[ic21_i] * w2[ic12_i]) * w3[ic33_i]
900 + (w1[ic21_r] * w2[ic12_i] + w1[ic21_i] * w2[ic12_r]) * w3[ic33_r];
902 c_r[id] -= (w1[ic11_r] * w2[ic32_r] - w1[ic11_i] * w2[ic32_i]) * w3[ic23_r]
903 - (w1[ic11_r] * w2[ic32_i] + w1[ic11_i] * w2[ic32_r]) * w3[ic23_i];
904 c_i[id] -= (w1[ic11_r] * w2[ic32_r] - w1[ic11_i] * w2[ic32_i]) * w3[ic23_i]
905 + (w1[ic11_r] * w2[ic32_i] + w1[ic11_i] * w2[ic32_r]) * w3[ic23_r];
911 corr = cmplx(0.0, 0.0);
912 for (
int id = 0;
id <
ND; ++id) {
913 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
915 #endif // (USE_GROUP_SU3)
926 #if defined USE_GROUP_SU_N
929 const int NC2 = 2 *
NC;
933 const int Nvol = v1.
nvol();
939 assert(Nvol == v1.
nvol());
940 assert(Nvol == v2.
nvol());
941 assert(v1.
nex() == 1);
942 assert(v2.
nex() == 1);
945 const double *w1 = v1.
ptr(0);
946 const double *w2 = v2.
ptr(0);
950 for (
int id = 0;
id <
ND; ++id) {
957 for (
int id = 0;
id <
ND; ++id) {
962 for (
int t = 0; t < Nt; ++t) {
963 for (
int z = 0; z < Nz; ++z) {
964 for (
int x = 0; x < Nx; ++x) {
965 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
966 for (
int cc = 0; cc <
NC; ++cc) {
967 for (
int id = 0;
id <
ND; ++id) {
968 int ic1_r = 2 * cc + id1[id] + site;
969 int ic2_r = 2 * cc + id2[id] + site;
971 int ic1_i = 2 * cc + 1 + id1[id] + site;
972 int ic2_i = 2 * cc + 1 + id2[id] + site;
974 c_r[id] += w1[ic2_r] * w2[ic1_r]
975 + w1[ic2_i] * w2[ic1_i];
977 c_i[id] += -w1[ic2_r] * w2[ic1_i]
978 + w1[ic2_i] * w2[ic1_r];
985 corr = cmplx(0.0, 0.0);
986 for (
int id = 0;
id <
ND; ++id) {
987 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1000 assert(corr_global.size() == Ly);
1002 std::vector<dcomplex> corr_local(Ny, 0.0);
1003 for (
int y = 0; y < Ny; ++y) {
1006 corr_local[y] += corr_y;
1014 const std::vector<int>& momentum_sink,
1016 const std::vector<int>& source_position,
1020 #if defined USE_GROUP_SU_N
1027 const int Nvol = v1.
nvol();
1039 assert(Nvol == v2.
nvol());
1040 assert(v1.
nex() == 1);
1041 assert(v2.
nex() == 1);
1042 assert(momentum_sink.size() == Ndim - 1);
1043 assert(source_position.size() == Ndim);
1045 const double *w1 = v1.
ptr(0);
1046 const double *w2 = v2.
ptr(0);
1050 for (
int id = 0;
id <
ND; ++id) {
1057 for (
int id = 0;
id <
ND; ++id) {
1062 static const double PI = 4.0 * atan(1.0);
1063 std::vector<double> p_unit(
ND - 1);
1064 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1065 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1066 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1068 std::vector<int> ipe(
ND);
1074 for (
int t = 0; t < Nt; ++t) {
1075 for (
int z = 0; z < Nz; ++z) {
1076 for (
int x = 0; x < Nx; ++x) {
1077 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1079 int x_global = x + ipe[0] * Nx;
1080 int z_global = z + ipe[2] * Nz;
1081 int t_global = t + ipe[3] * Nt;
1083 double p_x = p_unit[0] * (x_global - source_position[0]);
1084 double p_z = p_unit[1] * (z_global - source_position[2]);
1085 double p_t = p_unit[2] * (t_global - source_position[3]);
1087 double cos_p_xzt = cos(p_t + p_x + p_z);
1088 double sin_p_xzt = sin(p_t + p_x + p_z);
1090 for (
int cc = 0; cc <
NC; ++cc) {
1091 for (
int id = 0;
id <
ND; ++id) {
1092 int ic1_r = 2 * cc + id1[id] + site;
1093 int ic2_r = 2 * cc + id2[id] + site;
1095 int ic1_i = 2 * cc + 1 + id1[id] + site;
1096 int ic2_i = 2 * cc + 1 + id2[id] + site;
1098 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1099 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1102 c_r[id] += w1_w2_r * cos_p_xzt - w1_w2_i * sin_p_xzt;
1103 c_i[id] += w1_w2_r * sin_p_xzt + w1_w2_i * cos_p_xzt;
1110 corr = cmplx(0.0, 0.0);
1111 for (
int id = 0;
id <
ND; ++id) {
1112 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1119 const std::vector<int>& momentum_sink,
1121 const std::vector<int>& source_position,
1127 assert(corr_global.size() == Ly);
1129 std::vector<dcomplex> corr_local(Ny, 0.0);
1130 for (
int y = 0; y < Ny; ++y) {
1132 contract_at_y(corr_y, momentum_sink, gm_sink, source_position, v1, v2, y);
1133 corr_local[y] += corr_y;
1141 const std::vector<int>& momentum_sink,
1143 const std::vector<int>& source_position,
1147 #if defined USE_GROUP_SU_N
1154 const int Nvol = v1.
nvol();
1166 assert(Nvol == v2.
nvol());
1167 assert(v1.
nex() == 1);
1168 assert(v2.
nex() == 1);
1169 assert(momentum_sink.size() == Ndim - 1);
1170 assert(source_position.size() == Ndim);
1172 const double *w1 = v1.
ptr(0);
1173 const double *w2 = v2.
ptr(0);
1177 for (
int id = 0;
id <
ND; ++id) {
1184 for (
int id = 0;
id <
ND; ++id) {
1189 static const double PI = 4.0 * atan(1.0);
1190 std::vector<double> p_unit(
ND - 1);
1191 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1192 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1193 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1195 std::vector<int> ipe(
ND);
1202 for (
int t = 0; t < Nt; ++t) {
1203 for (
int z = 0; z < Nz; ++z) {
1204 for (
int x = 0; x < Nx; ++x) {
1205 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1207 int x_global = x + ipe[0] * Nx;
1208 int z_global = z + ipe[2] * Nz;
1209 int t_global = t + ipe[3] * Nt;
1211 double p_x = p_unit[0] * (x_global - source_position[0]);
1212 double p_z = p_unit[1] * (z_global - source_position[2]);
1213 double p_t = p_unit[2] * (t_global - source_position[3]);
1215 double cos_p_xzt = cos(p_t + p_x + p_z);
1217 double sin_p_xzt = 0;
1219 for (
int cc = 0; cc <
NC; ++cc) {
1220 for (
int id = 0;
id <
ND; ++id) {
1221 int ic1_r = 2 * cc + id1[id] + site;
1222 int ic2_r = 2 * cc + id2[id] + site;
1224 int ic1_i = 2 * cc + 1 + id1[id] + site;
1225 int ic2_i = 2 * cc + 1 + id2[id] + site;
1227 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1228 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1232 c_r[id] += w1_w2_r * cos_p_xzt - w1_w2_i * sin_p_xzt;
1233 c_i[id] += w1_w2_r * sin_p_xzt + w1_w2_i * cos_p_xzt;
1240 corr = cmplx(0.0, 0.0);
1241 for (
int id = 0;
id <
ND; ++id) {
1242 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1249 const std::vector<int>& momentum_sink,
1251 const std::vector<int>& source_position,
1257 assert(corr_global.size() == Ly);
1259 std::vector<dcomplex> corr_local(Ny, 0.0);
1260 for (
int y = 0; y < Ny; ++y) {
1263 corr_local[y] += corr_y;
1276 #if defined USE_GROUP_SU_N
1279 const int NC2 = 2 *
NC;
1287 const int Nvol = v1.
nvol();
1289 assert(Nvol == v1.
nvol());
1290 assert(Nvol == v2.
nvol());
1291 assert(v1.
nex() == 1);
1292 assert(v2.
nex() == 1);
1295 const double *w1 = v1.
ptr(0);
1296 const double *w2 = v2.
ptr(0);
1300 for (
int id = 0;
id <
ND; ++id) {
1307 for (
int id = 0;
id <
ND; ++id) {
1312 for (
int t = 0; t < Nt; ++t) {
1313 for (
int y = 0; y < Ny; ++y) {
1314 for (
int x = 0; x < Nx; ++x) {
1315 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1316 for (
int cc = 0; cc <
NC; ++cc) {
1317 for (
int id = 0;
id <
ND; ++id) {
1318 int ic1_r = 2 * cc + id1[id] + site;
1319 int ic2_r = 2 * cc + id2[id] + site;
1321 int ic1_i = 2 * cc + 1 + id1[id] + site;
1322 int ic2_i = 2 * cc + 1 + id2[id] + site;
1324 c_r[id] += w1[ic2_r] * w2[ic1_r]
1325 + w1[ic2_i] * w2[ic1_i];
1327 c_i[id] += -w1[ic2_r] * w2[ic1_i]
1328 + w1[ic2_i] * w2[ic1_r];
1335 corr = cmplx(0.0, 0.0);
1336 for (
int id = 0;
id <
ND; ++id) {
1337 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1350 assert(corr_global.size() == Lz);
1352 std::vector<dcomplex> corr_local(Nz, 0.0);
1353 for (
int z = 0; z < Nz; ++z) {
1356 corr_local[z] += corr_z;
1364 const std::vector<int>& momentum_sink,
1366 const std::vector<int>& source_position,
1370 #if defined USE_GROUP_SU_N
1377 const int Nvol = v1.
nvol();
1389 assert(Nvol == v2.
nvol());
1390 assert(v1.
nex() == 1);
1391 assert(v2.
nex() == 1);
1392 assert(momentum_sink.size() == Ndim - 1);
1393 assert(source_position.size() == Ndim);
1395 const double *w1 = v1.
ptr(0);
1396 const double *w2 = v2.
ptr(0);
1400 for (
int id = 0;
id <
ND; ++id) {
1407 for (
int id = 0;
id <
ND; ++id) {
1412 static const double PI = 4.0 * atan(1.0);
1413 std::vector<double> p_unit(
ND - 1);
1414 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1415 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1416 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1418 std::vector<int> ipe(
ND);
1424 for (
int t = 0; t < Nt; ++t) {
1425 for (
int y = 0; y < Ny; ++y) {
1426 for (
int x = 0; x < Nx; ++x) {
1427 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1429 int x_global = x + ipe[0] * Nx;
1430 int y_global = y + ipe[1] * Ny;
1431 int t_global = t + ipe[3] * Nt;
1433 double p_x = p_unit[0] * (x_global - source_position[0]);
1434 double p_y = p_unit[1] * (y_global - source_position[1]);
1435 double p_t = p_unit[2] * (t_global - source_position[3]);
1437 double cos_p_xyt = cos(p_t + p_x + p_y);
1438 double sin_p_xyt = sin(p_t + p_x + p_y);
1440 for (
int cc = 0; cc <
NC; ++cc) {
1441 for (
int id = 0;
id <
ND; ++id) {
1442 int ic1_r = 2 * cc + id1[id] + site;
1443 int ic2_r = 2 * cc + id2[id] + site;
1445 int ic1_i = 2 * cc + 1 + id1[id] + site;
1446 int ic2_i = 2 * cc + 1 + id2[id] + site;
1448 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1449 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1452 c_r[id] += w1_w2_r * cos_p_xyt - w1_w2_i * sin_p_xyt;
1453 c_i[id] += w1_w2_r * sin_p_xyt + w1_w2_i * cos_p_xyt;
1460 corr = cmplx(0.0, 0.0);
1461 for (
int id = 0;
id <
ND; ++id) {
1462 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1469 const std::vector<int>& momentum_sink,
1471 const std::vector<int>& source_position,
1477 assert(corr_global.size() == Lz);
1479 std::vector<dcomplex> corr_local(Nz, 0.0);
1480 for (
int z = 0; z < Nz; ++z) {
1482 contract_at_z(corr_z, momentum_sink, gm_sink, source_position, v1, v2, z);
1483 corr_local[z] += corr_z;
1491 const std::vector<int>& momentum_sink,
1493 const std::vector<int>& source_position,
1497 #if defined USE_GROUP_SU_N
1504 const int Nvol = v1.
nvol();
1516 assert(Nvol == v2.
nvol());
1517 assert(v1.
nex() == 1);
1518 assert(v2.
nex() == 1);
1519 assert(momentum_sink.size() == Ndim - 1);
1520 assert(source_position.size() == Ndim);
1522 const double *w1 = v1.
ptr(0);
1523 const double *w2 = v2.
ptr(0);
1527 for (
int id = 0;
id <
ND; ++id) {
1534 for (
int id = 0;
id <
ND; ++id) {
1539 static const double PI = 4.0 * atan(1.0);
1540 std::vector<double> p_unit(
ND - 1);
1541 p_unit[0] = (2.0 * PI / Ly) * momentum_sink[0];
1542 p_unit[1] = (2.0 * PI / Lz) * momentum_sink[1];
1543 p_unit[2] = (2.0 * PI / Lt) * momentum_sink[2];
1545 std::vector<int> ipe(
ND);
1552 for (
int t = 0; t < Nt; ++t) {
1553 for (
int y = 0; y < Ny; ++y) {
1554 for (
int x = 0; x < Nx; ++x) {
1555 int site =
NCD2 * (x + Nx * (y + Ny * (z + Nz * t)));
1557 int x_global = x + ipe[0] * Nx;
1558 int y_global = y + ipe[1] * Ny;
1559 int t_global = t + ipe[3] * Nt;
1561 double p_x = p_unit[0] * (x_global - source_position[0]);
1562 double p_y = p_unit[1] * (y_global - source_position[1]);
1563 double p_t = p_unit[2] * (t_global - source_position[2]);
1565 double cos_p_xyt = cos(p_t + p_x + p_y);
1567 double sin_p_xyt = 0;
1569 for (
int cc = 0; cc <
NC; ++cc) {
1570 for (
int id = 0;
id <
ND; ++id) {
1571 int ic1_r = 2 * cc + id1[id] + site;
1572 int ic2_r = 2 * cc + id2[id] + site;
1574 int ic1_i = 2 * cc + 1 + id1[id] + site;
1575 int ic2_i = 2 * cc + 1 + id2[id] + site;
1577 double w1_w2_r = w1[ic2_r] * w2[ic1_r] + w1[ic2_i] * w2[ic1_i];
1578 double w1_w2_i = -w1[ic2_r] * w2[ic1_i] + w1[ic2_i] * w2[ic1_r];
1582 c_r[id] += w1_w2_r * cos_p_xyt - w1_w2_i * sin_p_xyt;
1583 c_i[id] += w1_w2_r * sin_p_xyt + w1_w2_i * cos_p_xyt;
1590 corr = cmplx(0.0, 0.0);
1591 for (
int id = 0;
id <
ND; ++id) {
1592 corr += gm_sink.
value(
id) * cmplx(c_r[
id], c_i[
id]);
1599 const std::vector<int>& momentum_sink,
1601 const std::vector<int>& source_position,
1607 assert(corr_global.size() == Lz);
1609 std::vector<dcomplex> corr_local(Nz, 0.0);
1610 for (
int z = 0; z < Nz; ++z) {
1613 corr_local[z] += corr_z;
1621 std::vector<dcomplex>& corr_local)
1626 assert(corr_global.size() == Lx);
1627 assert(corr_local.size() == Nx);
1629 std::vector<dcomplex> corr_tmp(Lx, 0);
1633 for (
int x = 0; x < Nx; ++x) {
1634 int x2 = x + ipex * Nx;
1635 corr_tmp[x2] = corr_local[x];
1638 for (
int x = 0; x < Lx; ++x) {
1641 corr_global[x] = cmplx(crr, cri);
1648 std::vector<dcomplex>& corr_local)
1653 assert(corr_global.size() == Ly);
1654 assert(corr_local.size() == Ny);
1656 std::vector<dcomplex> corr_tmp(Ly, 0);
1660 for (
int y = 0; y < Ny; ++y) {
1661 int y2 = y + ipey * Ny;
1662 corr_tmp[y2] = corr_local[y];
1665 for (
int y = 0; y < Ly; ++y) {
1668 corr_global[y] = cmplx(crr, cri);
1675 std::vector<dcomplex>& corr_local)
1680 assert(corr_global.size() == Lz);
1681 assert(corr_local.size() == Nz);
1683 std::vector<dcomplex> corr_tmp(Lz);
1687 for (
int z = 0; z < Nz; ++z) {
1688 int z2 = z + ipez * Nz;
1689 corr_tmp[z2] = corr_local[z];
1692 for (
int z = 0; z < Lz; ++z) {
1695 corr_global[z] = cmplx(crr, cri);
1702 std::vector<dcomplex>& corr_local)
1707 assert(corr_global.size() == Lt);
1708 assert(corr_local.size() == Nt);
1710 std::vector<dcomplex> corr_tmp(Lt, 0);
1714 for (
int t = 0; t < Nt; ++t) {
1715 int t_global = t + ipe_t * Nt;
1716 corr_tmp[t_global] = corr_local[t];
1719 for (
int t_global = 0; t_global < Lt; ++t_global) {
1722 corr_global[t_global] = cmplx(cr_r, cr_i);