Bridge++  Ver. 1.3.x
contract_4spinor.cpp
Go to the documentation of this file.
1 
14 #include "contract_4spinor.h"
15 
16 #include <cassert>
17 
18 // This implementation only applies to SU(3) group and Nd=4 case.
19 #define NC 3
20 #define NC2 6
21 #define NDF 18
22 #define ND 4
23 #define NCD 12
24 #define NCD2 24
25 #define C1 0
26 #define C2 2
27 #define C3 4
28 
29 //====================================================================
30 void contract_at_t(dcomplex& corr, const GammaMatrix& gm,
31  const Field_F& v1, const Field_F& v2, int time)
32 {
33  int Nvol = v1.nvol();
34  int Nvol_s = Nvol / CommonParameters::Nt();
35 
36  assert(Nvol == v2.nvol());
37  assert(v1.nex() == 1);
38  assert(v2.nex() == 1);
39 
40  const double *w1 = v1.ptr(0);
41  const double *w2 = v2.ptr(0);
42 
43  int id11 = 0;
44  int id12 = NC2;
45  int id13 = 2 * NC2;
46  int id14 = 3 * NC2;
47  int id21 = gm.index(0) * NC2;
48  int id22 = gm.index(1) * NC2;
49  int id23 = gm.index(2) * NC2;
50  int id24 = gm.index(3) * NC2;
51 
52  double cr[ND];
53  double ci[ND];
54  for (int id = 0; id < ND; ++id) {
55  cr[id] = 0.0;
56  ci[id] = 0.0;
57  }
58 
59  for (int ss = 0; ss < Nvol_s; ++ss) {
60  int site = NCD2 * (ss + time * Nvol_s);
61 
62  for (int cc = 0; cc < NC; ++cc) {
63  cr[0] += w1[2 * cc + id21 + site] * w2[2 * cc + id11 + site]
64  + w1[2 * cc + 1 + id21 + site] * w2[2 * cc + 1 + id11 + site];
65  cr[1] += w1[2 * cc + id22 + site] * w2[2 * cc + id12 + site]
66  + w1[2 * cc + 1 + id22 + site] * w2[2 * cc + 1 + id12 + site];
67  cr[2] += w1[2 * cc + id23 + site] * w2[2 * cc + id13 + site]
68  + w1[2 * cc + 1 + id23 + site] * w2[2 * cc + 1 + id13 + site];
69  cr[3] += w1[2 * cc + id24 + site] * w2[2 * cc + id14 + site]
70  + w1[2 * cc + 1 + id24 + site] * w2[2 * cc + 1 + id14 + site];
71 
72  ci[0] += w1[2 * cc + id21 + site] * w2[2 * cc + 1 + id11 + site]
73  - w1[2 * cc + 1 + id21 + site] * w2[2 * cc + id11 + site];
74  ci[1] += w1[2 * cc + id22 + site] * w2[2 * cc + 1 + id12 + site]
75  - w1[2 * cc + 1 + id22 + site] * w2[2 * cc + id12 + site];
76  ci[2] += w1[2 * cc + id23 + site] * w2[2 * cc + 1 + id13 + site]
77  - w1[2 * cc + 1 + id23 + site] * w2[2 * cc + id13 + site];
78  ci[3] += w1[2 * cc + id24 + site] * w2[2 * cc + 1 + id14 + site]
79  - w1[2 * cc + 1 + id24 + site] * w2[2 * cc + id14 + site];
80  }
81  }
82 
83  corr = gm.value(0) * cmplx(cr[0], ci[0])
84  + gm.value(1) * cmplx(cr[1], ci[1])
85  + gm.value(2) * cmplx(cr[2], ci[2])
86  + gm.value(3) * cmplx(cr[3], ci[3]);
87 }
88 
89 
90 //====================================================================
91 void contract_at_t(dcomplex& corr, const GammaMatrix& gm, int d3,
92  const Field_F& v1, const Field_F& v2, const Field_F& v3,
93  int time)
94 {
95  int Nvol = v1.nvol();
96  int Nvol_s = Nvol / CommonParameters::Nt();
97 
98  assert(Nvol == v2.nvol());
99  assert(Nvol == v3.nvol());
100  assert(v1.nex() == 1);
101  assert(v2.nex() == 1);
102  assert(v3.nex() == 1);
103 
104  const double *w1 = v1.ptr(0);
105  const double *w2 = v2.ptr(0);
106  const double *w3 = v3.ptr(0);
107 
108  int s3 = d3 * NC2;
109 
110  int gmd[ND];
111  double cr[ND];
112  double ci[ND];
113 
114  for (int id = 0; id < ND; ++id) {
115  gmd[id] = gm.index(id);
116  cr[id] = 0.0;
117  ci[id] = 0.0;
118  }
119 
120 
121  for (int ss = 0; ss < Nvol_s; ++ss) {
122  int site = NCD2 * (ss + time * Nvol_s);
123 
124  for (int id = 0; id < ND; ++id) {
125  int iw1 = id * NC2 + site;
126  int iw2 = gmd[id] * NC2 + site;
127  int iw3 = s3 + site;
128 
129  cr[id] += (w1[C1 + iw1] * w2[C2 + iw2]
130  - w1[C1 + 1 + iw1] * w2[C2 + 1 + iw2]) * w3[C3 + iw3]
131  - (w1[C1 + iw1] * w2[C2 + 1 + iw2]
132  + w1[C1 + 1 + iw1] * w2[C2 + iw2]) * w3[C3 + 1 + iw3];
133  ci[id] += (w1[C1 + iw1] * w2[C2 + iw2]
134  - w1[C1 + 1 + iw1] * w2[C2 + 1 + iw2]) * w3[C3 + 1 + iw3]
135  + (w1[C1 + iw1] * w2[C2 + 1 + iw2]
136  + w1[C1 + 1 + iw1] * w2[C2 + iw2]) * w3[C3 + iw3];
137 
138  cr[id] += (w1[C2 + iw1] * w2[C3 + iw2]
139  - w1[C2 + 1 + iw1] * w2[C3 + 1 + iw2]) * w3[C1 + iw3]
140  - (w1[C2 + iw1] * w2[C3 + 1 + iw2]
141  + w1[C2 + 1 + iw1] * w2[C3 + iw2]) * w3[C1 + 1 + iw3];
142  ci[id] += (w1[C2 + iw1] * w2[C3 + iw2]
143  - w1[C2 + 1 + iw1] * w2[C3 + 1 + iw2]) * w3[C1 + 1 + iw3]
144  + (w1[C2 + iw1] * w2[C3 + 1 + iw2]
145  + w1[C2 + 1 + iw1] * w2[C3 + iw2]) * w3[C1 + iw3];
146 
147  cr[id] += (w1[C3 + iw1] * w2[C1 + iw2]
148  - w1[C3 + 1 + iw1] * w2[C1 + 1 + iw2]) * w3[C2 + iw3]
149  - (w1[C3 + iw1] * w2[C1 + 1 + iw2]
150  + w1[C3 + 1 + iw1] * w2[C1 + iw2]) * w3[C2 + 1 + iw3];
151  ci[id] += (w1[C3 + iw1] * w2[C1 + iw2]
152  - w1[C3 + 1 + iw1] * w2[C1 + 1 + iw2]) * w3[C2 + 1 + iw3]
153  + (w1[C3 + iw1] * w2[C1 + 1 + iw2]
154  + w1[C3 + 1 + iw1] * w2[C1 + iw2]) * w3[C2 + iw3];
155 
156  cr[id] -= (w1[C3 + iw1] * w2[C2 + iw2]
157  - w1[C3 + 1 + iw1] * w2[C2 + 1 + iw2]) * w3[C1 + iw3]
158  - (w1[C3 + iw1] * w2[C2 + 1 + iw2]
159  + w1[C3 + 1 + iw1] * w2[C2 + iw2]) * w3[C1 + 1 + iw3];
160  ci[id] -= (w1[C3 + iw1] * w2[C2 + iw2]
161  - w1[C3 + 1 + iw1] * w2[C2 + 1 + iw2]) * w3[C1 + 1 + iw3]
162  + (w1[C3 + iw1] * w2[C2 + 1 + iw2]
163  + w1[C3 + 1 + iw1] * w2[C2 + iw2]) * w3[C1 + iw3];
164 
165  cr[id] -= (w1[C2 + iw1] * w2[C1 + iw2]
166  - w1[C2 + 1 + iw1] * w2[C1 + 1 + iw2]) * w3[C3 + iw3]
167  - (w1[C2 + iw1] * w2[C1 + 1 + iw2]
168  + w1[C2 + 1 + iw1] * w2[C1 + iw2]) * w3[C3 + 1 + iw3];
169  ci[id] -= (w1[C2 + iw1] * w2[C1 + iw2]
170  - w1[C2 + 1 + iw1] * w2[C1 + 1 + iw2]) * w3[C3 + 1 + iw3]
171  + (w1[C2 + iw1] * w2[C1 + 1 + iw2]
172  + w1[C2 + 1 + iw1] * w2[C1 + iw2]) * w3[C3 + iw3];
173 
174  cr[id] -= (w1[C1 + iw1] * w2[C3 + iw2]
175  - w1[C1 + 1 + iw1] * w2[C3 + 1 + iw2]) * w3[C2 + iw3]
176  - (w1[C1 + iw1] * w2[C3 + 1 + iw2]
177  + w1[C1 + 1 + iw1] * w2[C3 + iw2]) * w3[C2 + 1 + iw3];
178  ci[id] -= (w1[C1 + iw1] * w2[C3 + iw2]
179  - w1[C1 + 1 + iw1] * w2[C3 + 1 + iw2]) * w3[C2 + 1 + iw3]
180  + (w1[C1 + iw1] * w2[C3 + 1 + iw2]
181  + w1[C1 + 1 + iw1] * w2[C3 + iw2]) * w3[C2 + iw3];
182  }
183  }
184  corr = cmplx(0.0, 0.0);
185  for (int id = 0; id < ND; ++id) {
186  corr += cmplx(cr[id], ci[id]) * gm.value(id);
187  }
188 }
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:133
#define NC
int nvol() const
Definition: field.h:116
#define NCD2
Wilson-type fermion field.
Definition: field_F.h:37
#define NC2
Gamma Matrix class.
Definition: gammaMatrix.h:44
#define C1
int nex() const
Definition: field.h:117
#define C2
void contract_at_t(dcomplex &corr, const GammaMatrix &gm, const Field_F &v1, const Field_F &v2, int time)
contraction for meson at a given time t.
#define ND
#define C3
dcomplex value(int row) const
Definition: gammaMatrix.h:88
int index(int row) const
Definition: gammaMatrix.h:83