Bridge++  Ver. 2.0.2
field_F.cpp
Go to the documentation of this file.
1 
14 #include "Field/field_F.h"
15 #include "Field/index_lex.h"
16 #include "Field/field_thread-inc.h"
17 
18 using std::valarray;
19 
20 //====================================================================
21 void Field_F::check()
22 {
23  // do nothing.
24 }
25 
26 
27 //====================================================================
28 void mult_Field_Gn(Field_F& y, const int ex,
29  const Field_G& U, int ex1,
30  const Field_F& x, int ex2)
31 {
32  assert(ex < y.nex());
33  assert(ex1 < U.nex());
34  assert(ex2 < x.nex());
35  assert(U.nvol() == y.nvol());
36  assert(x.nvol() == y.nvol());
37 
38  const int Nvol = x.nvol();
39  const int Nd = x.nd();
40  const int Nc = x.nc();
41 
42  int ith, nth, is, ns;
43  set_threadtask(ith, nth, is, ns, Nvol);
44 
45  for (int site = is; site < ns; ++site) {
46  for (int s = 0; s < Nd; ++s) {
47  y.set_vec(s, site, ex, U.mat(site, ex1) * x.vec(s, site, ex2));
48  }
49  }
50 }
51 
52 
53 //====================================================================
54 void mult_Field_Gd(Field_F& y, const int ex,
55  const Field_G& U, int ex1,
56  const Field_F& x, int ex2)
57 {
58  assert(ex < y.nex());
59  assert(ex1 < U.nex());
60  assert(ex2 < x.nex());
61  assert(U.nvol() == y.nvol());
62  assert(x.nvol() == y.nvol());
63 
64  const int Nvol = y.nvol();
65  const int Nd = y.nd();
66  const int Nc = y.nc();
67 
68  int ith, nth, is, ns;
69  set_threadtask(ith, nth, is, ns, Nvol);
70 
71  for (int site = is; site < ns; ++site) {
72  for (int s = 0; s < Nd; ++s) {
73  y.set_vec(s, site, ex, U.mat_dag(site, ex1) * x.vec(s, site, ex2));
74  }
75  }
76 }
77 
78 
79 //====================================================================
80 void multadd_Field_Gn(Field_F& y, const int ex,
81  const Field_G& U, int ex1,
82  const Field_F& x, int ex2,
83  const double a)
84 {
85  assert(ex < y.nex());
86  assert(ex1 < U.nex());
87  assert(ex2 < x.nex());
88  assert(U.nvol() == y.nvol());
89  assert(x.nvol() == y.nvol());
90 
91  const int Nvol = y.nvol();
92  const int Nd = y.nd();
93  const int Nc = y.nc();
94 
95  Vec_SU_N vec(Nc);
96 
97  int ith, nth, is, ns;
98  set_threadtask(ith, nth, is, ns, Nvol);
99 
100  for (int site = is; site < ns; ++site) {
101  for (int s = 0; s < Nd; ++s) {
102  y.add_vec(s, site, ex, U.mat(site, ex1) * x.vec(s, site, ex2) * a);
103  }
104  }
105 }
106 
107 
108 //====================================================================
109 void multadd_Field_Gd(Field_F& y, const int ex,
110  const Field_G& U, int ex1,
111  const Field_F& x, int ex2,
112  const double a)
113 {
114  assert(ex < y.nex());
115  assert(ex1 < U.nex());
116  assert(ex2 < x.nex());
117  assert(U.nvol() == y.nvol());
118  assert(x.nvol() == y.nvol());
119 
120  const int Nvol = y.nvol();
121  const int Nd = y.nd();
122  const int Nc = y.nc();
123 
124  int ith, nth, is, ns;
125  set_threadtask(ith, nth, is, ns, Nvol);
126 
127  for (int site = is; site < ns; ++site) {
128  for (int s = 0; s < Nd; ++s) {
129  y.add_vec(s, site, ex, U.mat_dag(site, ex1) * x.vec(s, site, ex2) * a);
130  }
131  }
132 }
133 
134 
135 //====================================================================
136 void mult_GM(Field_F& v, const GammaMatrix& gm, const Field_F& w)
137 {
138  assert(w.nex() == v.nex());
139  assert(w.nvol() == v.nvol());
140 
141  const int Nvol = v.nvol();
142  const int Nex = v.nex();
143  const int Nd = v.nd();
144  const int Nc = v.nc();
145 
146  valarray<int> id(Nd);
147  valarray<int> idc_r(Nd);
148  valarray<int> idc_i(Nd);
149  valarray<double> gv_r(Nd);
150  valarray<double> gv_i(Nd);
151 
152  for (int s = 0; s < Nd; ++s) {
153  id[s] = gm.index(s);
154  gv_r[s] = gm.value_r(s);
155  gv_i[s] = gm.value_i(s);
156  idc_r[s] = gm.index_c(s);
157  idc_i[s] = 1 - idc_r[s];
158  }
159 
160  int ith, nth, is, ns;
161  set_threadtask(ith, nth, is, ns, Nvol);
162 
163  for (int ex = 0; ex < Nex; ++ex) {
164  for (int site = is; site < ns; ++site) {
165  for (int s = 0; s < Nd; ++s) {
166  for (int c = 0; c < Nc; ++c) {
167  double ww[2];
168  ww[0] = w.cmp_r(c, id[s], site, ex);
169  ww[1] = w.cmp_i(c, id[s], site, ex);
170 
171  v.set_ri(c, s, site, ex,
172  gv_r[s] * ww[idc_r[s]],
173  gv_i[s] * ww[idc_i[s]]);
174  }
175  }
176  }
177  }
178 }
179 
180 
181 //====================================================================
182 void mult_iGM(Field_F& v, const GammaMatrix& gm, const Field_F& w)
183 {
184  assert(w.nex() == v.nex());
185  assert(w.nvol() == v.nvol());
186 
187  const int Nvol = v.nvol();
188  const int Nex = v.nex();
189  const int Nd = v.nd();
190  const int Nc = v.nc();
191 
192  valarray<int> id(Nd);
193  valarray<int> idc_r(Nd);
194  valarray<int> idc_i(Nd);
195  valarray<double> gv_r(Nd);
196  valarray<double> gv_i(Nd);
197 
198  for (int s = 0; s < Nd; ++s) {
199  id[s] = gm.index(s);
200  gv_r[s] = -gm.value_i(s);
201  gv_i[s] = gm.value_r(s);
202  idc_r[s] = 1 - gm.index_c(s);
203  idc_i[s] = 1 - idc_r[s];
204  }
205 
206  int ith, nth, is, ns;
207  set_threadtask(ith, nth, is, ns, Nvol);
208 
209  for (int ex = 0; ex < Nex; ++ex) {
210  for (int site = is; site < ns; ++site) {
211  for (int s = 0; s < Nd; ++s) {
212  for (int c = 0; c < Nc; ++c) {
213  double ww[2];
214  ww[0] = w.cmp_r(c, id[s], site, ex);
215  ww[1] = w.cmp_i(c, id[s], site, ex);
216 
217  v.set_ri(c, s, site, ex,
218  gv_r[s] * ww[idc_r[s]],
219  gv_i[s] * ww[idc_i[s]]);
220  }
221  }
222  }
223  }
224 }
225 
226 
227 //====================================================================
229  const int pm, const GammaMatrix& gm,
230  const Field_F& w)
231 {
232  assert(w.nvol() == v.nvol());
233  assert(w.nex() == v.nex());
234  assert(pm == 1 || pm == -1);
235 
236  mult_GM(v, gm, w);
237 
238  if (pm == 1) {
239  axpy(v, 1.0, w); // v += w;
240  scal(v, 0.5); // v *= 0.5;
241  } else if (pm == -1) {
242  axpy(v, -1.0, w); // v -= w i.e. v = (gamma - 1) * w
243  scal(v, -0.5); // v *= -0.5 i.e. v = (1 - gamma)/2 * w
244  } else {
245  vout.crucial("Error at %s: wrong pm = %d\n", __func__, pm);
246  exit(EXIT_FAILURE);
247  }
248 }
249 
250 
251 //====================================================================
253  const int pm, const GammaMatrix& gm,
254  const Field_F& w)
255 {
256  assert(w.nvol() == v.nvol());
257  assert(w.nex() == v.nex());
258  assert(pm == 1 || pm == -1);
259 
260  mult_GM(v, gm, w);
261 
262  if (pm == 1) {
263  axpy(v, 1.0, w); // v += w;
264  } else if (pm == -1) {
265  axpy(v, -1.0, w); // v -= w;
266  scal(v, -1.0); // v *= -1.0;
267  } else {
268  vout.crucial("Error at %s: wrong pm = %d\n", __func__, pm);
269  exit(EXIT_FAILURE);
270  }
271 }
272 
273 
274 //====================================================================
276  const double nu_s,
277  const int pm,
278  const double r_s,
279  const GammaMatrix& gm,
280  const Field_F& w)
281 {
282  assert(w.nvol() == v.nvol());
283  assert(w.nex() == v.nex());
284  assert(pm == 1 || pm == -1);
285 
286  mult_GM(v, gm, w);
287  scal(v, nu_s); // v *= nu_s;
288 
289  if (pm == 1) {
290  axpy(v, r_s, w); // v += r_s * w;
291  } else if (pm == -1) {
292  axpy(v, -r_s, w); // v -= r_s * w i.e. v = (nu_s * gamma - r_s) * w
293  scal(v, -1.0); // v *= -1.0 i.e. v = (r_s - nu_s * gamma) * w
294  } else {
295  vout.crucial("Error at %s: wrong pm = %d\n", __func__, pm);
296  exit(EXIT_FAILURE);
297  }
298 }
299 
300 
301 //====================================================================
302 //============================================================END=====
mult_GM
void mult_GM(Field_F &v, const GammaMatrix &gm, const Field_F &w)
gamma matrix multiplication
Definition: field_F.cpp:136
field_F.h
Field_F::set_vec
void set_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:134
GammaMatrix::index_c
int index_c(int row) const
Definition: gammaMatrix.h:93
GammaMatrix::index
int index(int row) const
Definition: gammaMatrix.h:83
Field_F::cmp_i
double cmp_i(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:100
Field_F::vec
Vec_SU_N vec(const int s, const int site, const int e=0) const
Definition: field_F.h:122
GammaMatrix
Gamma Matrix class.
Definition: gammaMatrix.h:44
Field_G::mat_dag
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
mult_Field_Gn
void mult_Field_Gn(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2)
Definition: field_F.cpp:28
GammaMatrix::value_i
double value_i(int row) const
Definition: gammaMatrix.h:103
multadd_Field_Gd
void multadd_Field_Gd(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2, const double a)
Definition: field_F.cpp:109
Field::nex
int nex() const
Definition: field.h:128
GammaMatrix::value_r
double value_r(int row) const
Definition: gammaMatrix.h:98
Field_F::nc
int nc() const
Definition: field_F.h:89
Field_F::set_ri
void set_ri(const int cc, const int s, const int site, const int e, const double re, const double im)
Definition: field_F.h:116
Field_F::add_vec
void add_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:142
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
Field_F::check
void check()
check several assumptions for performance implementation.
Definition: field_F_imp.cpp:26
mult_Field_Gd
void mult_Field_Gd(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2)
Definition: field_F.cpp:54
mult_GMproj2
void mult_GMproj2(Field_F &v, const int pm, const GammaMatrix &gm, const Field_F &w)
projection with gamma matrix: (1 \pm gamma)
Definition: field_F.cpp:252
multadd_Field_Gn
void multadd_Field_Gn(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2, const double a)
Definition: field_F.cpp:80
Field_F::cmp_r
double cmp_r(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:94
mult_iGM
void mult_iGM(Field_F &v, const GammaMatrix &gm, const Field_F &w)
gamma matrix multiplication (i is multiplied)
Definition: field_F.cpp:182
Field::nvol
int nvol() const
Definition: field.h:127
index_lex.h
SU_N::Vec_SU_N
Definition: vec_SU_N.h:24
scal
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:261
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
field_thread-inc.h
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
mult_GMproj
void mult_GMproj(Field_F &v, const int pm, const GammaMatrix &gm, const Field_F &w)
projection with gamma matrix: (1 \pm gamma)/2
Definition: field_F.cpp:228
Field_G::mat
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Field_F::nd
int nd() const
Definition: field_F.h:91
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512