Bridge++  Ver. 1.2.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fopr_Wilson_eo_impl.cpp
Go to the documentation of this file.
1 
14 #include "fopr_Wilson_eo_impl.h"
15 
16 using std::valarray;
17 
19  = "Fopr_Wilson_eo_impl";
20 
21 //===================================================================
22 namespace {
26  void mult_Field_Gn_eo(Field_F& w, int ex,
27  const Field_G& U, const int ex1,
28  const Field_F& x, const int ex2,
29  const int ieo)
30  {
31  assert(ex < w.nex());
32  assert(ex1 < U.nex());
33  assert(ex2 < x.nex());
34  assert(U.nvol() == w.nvol() * 2);
35  assert(x.nvol() == w.nvol());
36 
37  Vec_SU_N vec(w.nc());
38 
39  for (int site = 0, nvol = w.nvol(); site < nvol; ++site) {
40  for (int s = 0, nd = w.nd(); s < nd; ++s) {
41  vec = U.mat(site + ieo * nvol, ex1) * x.vec(s, site, ex2);
42  w.set_vec(s, site, ex, vec);
43  }
44  }
45  }
46 
47 
48  //====================================================================
52  void mult_Field_Gd_eo(Field_F& w, int ex,
53  const Field_G& U, int ex1,
54  const Field_F& x, int ex2,
55  const int ieo)
56  {
57  assert(ex < w.nex());
58  assert(ex1 < U.nex());
59  assert(ex2 < x.nex());
60  assert(U.nvol() == w.nvol() * 2);
61  assert(x.nvol() == w.nvol());
62 
63  Vec_SU_N vec(w.nc());
64 
65  for (int site = 0, nvol = w.nvol(); site < nvol; ++site) {
66  for (int s = 0, nd = w.nd(); s < nd; ++s) {
67  vec = U.mat_dag(site + ieo * nvol, ex1) * x.vec(s, site, ex2);
68  w.set_vec(s, site, ex, vec);
69  }
70  }
71  }
72 }
73 
74 //====================================================================
76  const double kappa,
77  const std::valarray<int> bc)
78 {
79  //- print input parameters
80  vout.general(m_vl, "Parameters of Fopr_Wilson_eo(impl):\n");
81  vout.general(m_vl, " kappa = %8.4f\n", kappa);
82  for (int mu = 0; mu < m_Ndim; ++mu) {
83  vout.general(m_vl, " boundary[%d] = %2d\n", mu, bc[mu]);
84  }
85 
86  //- range check
87  // NB. kappa = 0 is allowed.
88  assert(bc.size() == m_Ndim);
89 
90  //- store values
91  m_kappa = kappa;
92 
93  // m_boundary.resize(m_Ndim); // already resized in init.
94  for (int mu = 0; mu < m_Ndim; ++mu) {
95  m_boundary[mu] = bc[mu];
96  }
97 }
98 
99 
100 //====================================================================
102 {
103  int Ndim = CommonParameters::Ndim();
104  int Nvol = CommonParameters::Nvol();
105 
106  m_index.convertField(*m_Ueo, *U);
107 }
108 
109 
110 //====================================================================
111 void Fopr_Wilson_eo::Fopr_Wilson_eo_impl::init(const std::string repr)
112 {
113  m_repr = repr;
114 
115  m_boundary.resize(m_Ndim);
116  m_GM.resize(m_Ndim + 1);
117 
118  GammaMatrixSet *gmset = GammaMatrixSet::New(repr);
119 
120  m_GM[0] = gmset->get_GM(gmset->GAMMA1);
121  m_GM[1] = gmset->get_GM(gmset->GAMMA2);
122  m_GM[2] = gmset->get_GM(gmset->GAMMA3);
123  m_GM[3] = gmset->get_GM(gmset->GAMMA4);
124  m_GM[4] = gmset->get_GM(gmset->GAMMA5);
125 
126  m_Ueo = new Field_G(m_Nvol, m_Ndim);
127 
128  delete gmset;
129 }
130 
131 
132 //====================================================================
134 {
135 #pragma omp master
136  {
137  int Nin = b.nin();
138  int Nex = b.nex();
139 
140  Field be(Nin, m_Nvol2, Nex);
141 
142  m_index.convertField(be, b, 0);
143  m_index.convertField(bo, b, 1);
144 
145  Be.reset(Nin, m_Nvol2, Nex);
146 
147  // Be = be - (Field)Meo(bo, 0);
148  Field_F v1(m_Nvol2, Nex);
149  copy(Be, be);
150  Meo(v1, bo, 0);
151  axpy(Be, -1.0, v1);
152  }
153 #pragma omp barrier
154 }
155 
156 
157 //====================================================================
159 {
160 #pragma omp master
161  {
162  int Nin = xe.nin();
163  int Nex = xe.nex();
164 
165  Field xo(Nin, m_Nvol2, Nex);
166 
167  // xo = bo - (Field)Meo(xe, 1);
168  Field_F v1(m_Nvol2, Nex);
169  copy(xo, bo);
170  Meo(v1, xe, 1);
171  axpy(xo, -1.0, v1);
172 
173  x.reset(Nin, m_Nvol2 * 2, Nex);
174  m_index.reverseField(x, xe, 0);
175  m_index.reverseField(x, xo, 1);
176  }
177 #pragma omp barrier
178 }
179 
180 
181 //====================================================================
183 {
184 #pragma omp master
185  {
186  int Nin = b.nin();
187  int Nex = b.nex();
188 
189  Field be(Nin, m_Nvol2, Nex);
190 
191  m_index.convertField(be, b, 0);
192  m_index.convertField(bo, b, 1);
193 
194  Be.reset(Nin, m_Nvol2, Nex);
195 
196  // Be = be - (Field)Mdageo(bo, 0);
197  Field_F v1(m_Nvol2, Nex);
198  copy(Be, be);
199  Mdageo(v1, bo, 0);
200  axpy(Be, -1.0, v1);
201  }
202 #pragma omp barrier
203 }
204 
205 
206 //====================================================================
208 {
209 #pragma omp master
210  {
211  //Field bo();
212  //index.convertField(bo, b, 1);
213  int Nin = xe.nin();
214  int Nex = xe.nex();
215 
216  Field xo(Nin, m_Nvol2, Nex);
217 
218  // xo = bo - (Field)Mdageo(xe, 1);
219  Field_F v1(m_Nvol2, Nex);
220  copy(xo, bo);
221  Mdageo(v1, xe, 1);
222  axpy(xo, -1.0, v1);
223 
224  x.reset(Nin, m_Nvol2 * 2, Nex);
225  m_index.reverseField(x, xe, 0);
226  m_index.reverseField(x, xo, 1);
227  }
228 #pragma omp barrier
229 }
230 
231 
232 //====================================================================
234 {
235 #pragma omp master
236  {
237  assert(f.nex() == 1);
238  Field_F v1(m_Nvol2, 1), v2(m_Nvol2, 1);
239 
240  copy(v, f); // v = f;
241 
242  // v -= (Field)Meo(Meo(f, 1), 0);
243  Meo(v1, f, 1);
244  Meo(v2, v1, 0);
245  axpy(v, -1.0, v2);
246  }
247 #pragma omp barrier
248 }
249 
250 
251 //====================================================================
253 {
254 #pragma omp master
255  {
256  Field_F v1(m_Nvol2, 1), v2(m_Nvol2, 1);
257 
258  copy(v, f); // v = f;
259 
260  // v -= (Field)Mdageo(Mdageo(f, 1), 0);
261  Mdageo(v1, f, 1);
262  Mdageo(v2, v1, 0);
263  axpy(v, -1.0, v2);
264  }
265 #pragma omp barrier
266 }
267 
268 
269 //====================================================================
271 {
272 #pragma omp master
273  {
274  Field w(v);
275  D(w, f);
276  Ddag(v, w);
277  }
278 #pragma omp barrier
279 }
280 
281 
282 //====================================================================
284 {
285 #pragma omp master
286  {
287  Field w(v);
288  Ddag(w, f);
289  D(v, w);
290  }
291 #pragma omp barrier
292 }
293 
294 
295 //====================================================================
297 {
298 #pragma omp master
299  {
300  Field w(v);
301  D(w, f);
302  mult_gm5(v, w);
303  }
304 #pragma omp barrier
305 }
306 
307 
308 //====================================================================
310 {
311 #pragma omp master
312  {
313  Field_F v1(m_Nvol2, 1), v2(m_Nvol2, 1);
314 
315  // v -= (Field)Meo(Meo(f, 1), 0);
316  Meo(v1, f, 1);
317  Meo(v2, v1, 0);
318  axpy(v, -1.0, v2);
319  }
320 #pragma omp barrier
321 }
322 
323 
324 //====================================================================
326  const Field& f, const int ieo)
327 {
328 #pragma omp master
329  {
330  Field_F w2(m_Nvol2, 1), f2(m_Nvol2, 1);
331  copy(f2, f);
332  w2.set(0.0); // w2 = 0.0
333 
334  for (int mu = 0; mu < m_Ndim; ++mu) {
335  mult_p(mu, w2, f2, ieo);
336  mult_m(mu, w2, f2, ieo);
337  }
338 
339  scal(w2, -m_kappa); // w *= -m_kappa;
340 
341  copy(w, w2);
342  }
343 }
344 
345 
346 //====================================================================
348  const Field& f, const int ieo)
349 {
350 #pragma omp master
351  {
352  Field_F v(m_Nvol2, f.nex());
353 
354  mult_gm5(v, f);
355  Meo_gm5(w, v, ieo);
356  }
357 }
358 
359 
360 //====================================================================
362  const Field& f, const int ieo)
363 {
364  Field_F w(m_Nvol2, f.nex());
365 
366  Meo(w, f, ieo);
367  mult_gm5(v, w);
368 }
369 
370 
371 //====================================================================
373 {
374 #pragma omp master
375  {
376  Field_F w2 = (Field_F)f;
377  mult_GM(w2, m_GM[4], (Field_F)f);
378  w = w2;
379  }
380 #pragma omp barrier
381 }
382 
383 
384 //====================================================================
386  const Field& f)
387 {
388  Field_F vt1(f.nvol(), 1);
389  Field_F vt2(f.nvol(), 1);
390 
391  for (int ex = 0; ex < f.nex(); ++ex) {
392  vt1.setpart_ex(0, f, ex);
393  shift.backward(vt2, vt1, m_boundary[mu], mu); // vt2 = vt1(x+mu)
394  mult_GMproj2(vt1, -1, m_GM[mu], vt2); // vt1 = (1 - gamma_mu) vt2
395  mult_GM(vt2, m_GM[4], vt1); // vt2 = gamma_5 vt1
396  w.addpart_ex(ex, vt2, 0);
397  }
398 }
399 
400 
401 //====================================================================
403  Field_F& w, const Field_F& f,
404  const int ieo)
405 {
406  Field_F vt(f.nvol(), 1);
407 
408  for (int ex = 0; ex < f.nex(); ++ex) {
409  vt.setpart_ex(0, f, ex);
410  shift.backward_h(trf, vt, m_boundary[mu], mu, ieo);
411  mult_Field_Gn_eo(trf2, 0, *m_Ueo, mu, trf, 0, ieo);
412  mult_GMproj2(vt, -1, m_GM[mu], trf2);
413  w.addpart_ex(ex, vt, 0);
414  }
415 }
416 
417 
418 //=====================================================================
420  Field_F& w, const Field_F& f,
421  const int ieo)
422 {
423  Field_F vt(f.nvol(), 1);
424 
425  for (int ex = 0; ex < f.nex(); ++ex) {
426  mult_Field_Gd_eo(trf, 0, *m_Ueo, mu, f, ex, 1 - ieo);
427  shift.forward_h(trf2, trf, m_boundary[mu], mu, ieo);
428  mult_GMproj2(vt, 1, m_GM[mu], trf2);
429  w.addpart_ex(ex, vt, 0);
430  }
431 }
432 
433 
434 //====================================================================
436 {
437  // this counting is based on the Org-implementation of ver.1.2.0.
438  // Flop count of mult_GMproj2 is different for upward and downward
439  // directions due to the implemetation in Field_F.cpp.
440  // Present counting is based on rev.1130. [10 Sep 2014 H.Matsufuru]
441 
442  int Nc = m_Nc;
443  int Nd = m_Nd;
444  int Lvol = CommonParameters::Lvol();
445 
446  int flop_Meo = Nc * Nd * 2 * 8 * (4 * Nc - 1); // #(mult_Field_Gn/d)
447 
448  flop_Meo += Nc * Nd * 2 * (4 * 3 + 4 * 2); // #(mult_GMproj2)
449  flop_Meo += Nc * Nd * 2 * 8; // #(addpart_ex)
450  flop_Meo += Nc * Nd * 2; // #(scal(kappa))
451 
452  int flop_per_site = 2 * flop_Meo + Nc * Nd * 2 * 2; // #(2*Meo + axpy)
453 
454  double flop = static_cast<double>(flop_per_site) *
455  static_cast<double>(Lvol / 2);
456 
457  if ((m_mode == "DdagD") || (m_mode == "DDdag")) {
458  flop *= 2.0;
459  }
460 
461  return flop;
462 }
463 
464 
465 //====================================================================
466 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:310
const Field_F Meo(const Field_F &, const int ieo)
void prePropD(Field &, Field &, const Field &)
void backward(Field &, const Field &, const int mu)
BridgeIO vout
Definition: bridgeIO.cpp:207
void prePropDag(Field &, Field &, const Field &)
void MeoMoe(Field &, const Field &)
Index_eo m_index
void set_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:134
void mult_gm5(Field &v, const Field &f)
const Field_F Mdageo(const Field_F &, const int ieo)
void D(Field &v, const Field &f)
void general(const char *format,...)
Definition: bridgeIO.cpp:38
GammaMatrix get_GM(GMspecies spec)
Field_G * m_Ueo
void Meo_gm5(Field &, const Field &, const int ieo)
void set_parameters(const double kappa, const std::valarray< int > bc)
Container of Field-type object.
Definition: field.h:37
void DdagD(Field &v, const Field &f)
int nvol() const
Definition: field.h:101
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:409
static int Lvol()
void convertField(Field &eo, const Field &lex)
Definition: index_eo.cpp:20
void addpart_ex(int ex, const Field &w, int exw)
Definition: field.h:162
std::string m_mode
void mult_gm5(Field &, const Field &)
void postPropDag(Field &, const Field &, const Field &)
Wilson-type fermion field.
Definition: field_F.h:37
void mult_GMproj2(Field_F &y, const int pm, const GammaMatrix &gm, const Field_F &x)
projection with gamma matrix: (1 gamma)
void mult_m(int mu, Field_F &, const Field_F &, const int ieo)
void mult_p(int mu, Field_F &, const Field_F &, const int ieo)
int nin() const
Definition: field.h:100
void Meo(Field &, const Field &, const int ieo)
void postPropD(Field &, const Field &, const Field &)
SU(N) gauge field.
Definition: field_G.h:36
std::string m_repr
void DDdag(Field &v, const Field &f)
void Ddag(Field &v, const Field &f)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
Definition: field.h:82
void Mdageo(Field &, const Field &, const int ieo)
Set of Gamma Matrices: basis class.
int nex() const
Definition: field.h:102
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:193
void mult_GM(Field_F &y, const GammaMatrix &gm, const Field_F &x)
gamma matrix multiplication
Definition: field_F_imp.cpp:39
void H(Field &v, const Field &f)
void D(Field &v, const Field &f)
int nc() const
Definition: field_F.h:89
void reverseField(Field &lex, const Field &eo)
Definition: index_eo.cpp:110
std::valarray< int > m_boundary
boundary condition.
Vec_SU_N vec(const int s, const int site, const int e=0) const
Definition: field_F.h:122
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:123
void Ddag(Field &v, const Field &f)
void backward_h(Field &, const Field &, const int mu, const int ieo)
void mult_m(int mu, Field_F &, const Field_F &, const int ieo)
double flop_count()
this returns the number of floating point operations of Meo.
void mult_p(int mu, Field_F &, const Field_F &, const int ieo)
int nd() const
Definition: field_F.h:91
void setpart_ex(int ex, const Field &w, int exw)
Definition: field.h:150
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:110
std::valarray< GammaMatrix > m_GM
void forward_h(Field &, const Field &, const int mu, const int ieo)
void gm5p(const int mu, Field &, const Field &v)
gamma_5 (1 - gamma_mu) v(x + mu) used in force calculation.
const Field_F Meo_gm5(const Field_F &, const int ieo)
std::valarray< int > m_boundary
ShiftField_eo shift