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