Bridge++  Version 1.6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
field.cpp
Go to the documentation of this file.
1 
14 #include "field.h"
15 
16 #include <cstring>
18 
19 #include "IO/bridgeIO.h"
20 using Bridge::vout;
21 
22 using std::string;
23 
24 //====================================================================
25 namespace {
26  inline
27  void set_threadtask(int& i_thread, int& Nthread, int& is, int& ns,
28  const int size)
29  {
32 
33  is = static_cast<long_t>(size) * i_thread / Nthread;
34  ns = static_cast<long_t>(size) * (i_thread + 1) / Nthread;
35  }
36 }
37 
38 //====================================================================
40 {
41  // vout.general("Field was constructed.\n");
42 }
43 
44 
45 //====================================================================
46 double dot(const Field& y, const Field& x)
47 {
48  const double *yp = y.ptr(0);
49  const double *xp = x.ptr(0);
50 
51  // int size = x.ntot();
52  int i_thread, Nthread, is, ns;
53 
54  set_threadtask(i_thread, Nthread, is, ns, x.ntot());
55 
56  double a = 0.0;
57 
58  for (int k = is; k < ns; ++k) {
59  a += yp[k] * xp[k];
60  }
61  ThreadManager_OpenMP::reduce_sum_global(a, i_thread, Nthread);
62 
63  return a;
64 }
65 
66 
67 //====================================================================
68 double dot(const Field& y, const int exy, const Field& x, const int exx)
69 {
70  assert(x.nin() == y.nin());
71  assert(x.nvol() == y.nvol());
72 
73  const double *yp = y.ptr(0, 0, exy);
74  const double *xp = x.ptr(0, 0, exx);
75 
76  // int size = x.nin() * x.nvol();
77  int i_thread, Nthread, is, ns;
78  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol());
79 
80  double a = 0.0;
81 
82  for (int k = is; k < ns; ++k) {
83  a += yp[k] * xp[k];
84  }
85  ThreadManager_OpenMP::reduce_sum_global(a, i_thread, Nthread);
86 
87  return a;
88 }
89 
90 
91 //====================================================================
92 void dot_and_norm2(double& yx, double& y2, double& x2, const Field& y, const int exy, const Field& x, const int exx)
93 {
94  assert(x.nin() == y.nin());
95  assert(x.nvol() == y.nvol());
96 
97  const double *yp = y.ptr(0, 0, exy);
98  const double *xp = x.ptr(0, 0, exx);
99 
100  // long_t size = x.nin() * x.nvol();
101  int i_thread, Nthread;
102  int is, ns;
103  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol());
104 
105  double sum_yx = 0.0;
106  double sum_x2 = 0.0;
107  double sum_y2 = 0.0;
108 
109  for (int k = is; k < ns; ++k) {
110  sum_yx += yp[k] * xp[k];
111  sum_x2 += xp[k] * xp[k];
112  sum_y2 += yp[k] * yp[k];
113  }
114 
115  double prd[3] = { sum_yx, sum_x2, sum_y2 };
116  ThreadManager_OpenMP::reduce_sum_global(prd, 3, i_thread, Nthread);
117  yx = prd[0];
118  y2 = prd[1];
119  x2 = prd[2];
120 }
121 
122 
123 //====================================================================
124 void dot_and_norm2(double& yx, double& y2, double& x2, const Field& y, const Field& x)
125 {
126  assert(x.nin() == y.nin());
127  assert(x.nex() == y.nex());
128  assert(x.nvol() == y.nvol());
129 
130  const double *yp = y.ptr(0);
131  const double *xp = x.ptr(0);
132 
133  int i_thread, Nthread;
134  int is, ns;
135  set_threadtask(i_thread, Nthread, is, ns, x.ntot());
136 
137  double sum_yx = 0.0;
138  double sum_x2 = 0.0;
139  double sum_y2 = 0.0;
140 
141  for (int k = is; k < ns; ++k) {
142  sum_yx += yp[k] * xp[k];
143  sum_x2 += xp[k] * xp[k];
144  sum_y2 += yp[k] * yp[k];
145  }
146 
147  double prd[3] = { sum_yx, sum_x2, sum_y2 };
148  ThreadManager_OpenMP::reduce_sum_global(prd, 3, i_thread, Nthread);
149  yx = prd[0];
150  y2 = prd[1];
151  x2 = prd[2];
152 }
153 
154 
155 //====================================================================
156 dcomplex dotc(const Field& y, const Field& x)
157 {
158  const double *yp = y.ptr(0);
159  const double *xp = x.ptr(0);
160 
161  assert(x.ntot() == y.ntot());
162 
163  int i_thread, Nthread;
164  int is, ns;
165  set_threadtask(i_thread, Nthread, is, ns, x.ntot() / 2);
166 
169  double prd_r = 0.0;
170  double prd_i = 0.0;
171 
172  for (int k = is * 2; k < ns * 2; k += 2) {
173  prd_r += yp[k] * xp[k] + yp[k + 1] * xp[k + 1];
174  prd_i += yp[k] * xp[k + 1] - yp[k + 1] * xp[k];
175  }
176  double prd[2] = { prd_r, prd_i };
177  ThreadManager_OpenMP::reduce_sum_global(prd, 2, i_thread, Nthread);
178  return cmplx(prd[0], prd[1]);
179  } else if ((y.field_element_type() == Element_type::REAL) &&
181  return cmplx(dot(y, x), 0.0);
182  } else {
183  vout.crucial("Error at %s: unsupported arg types.\n", __func__);
184  exit(EXIT_FAILURE);
185 
186  return cmplx(0.0, 0.0); // never reached.
187  }
188 }
189 
190 
191 //====================================================================
192 dcomplex dotc(const Field& y, const int exy, const Field& x, const int exx)
193 {
194  const double *yp = y.ptr(0, 0, exy);
195  const double *xp = x.ptr(0, 0, exx);
196 
197  assert(x.nin() == y.nin());
198  assert(x.nvol() == y.nvol());
199 
200  // int size = x.nin() * x.nvol();
201  int i_thread, Nthread;
202  int is, ns;
203  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol() / 2);
204 
207  double prd_r = 0.0;
208  double prd_i = 0.0;
209 
210  for (int k = 2 * is; k < 2 * ns; k += 2) {
211  prd_r += yp[k] * xp[k] + yp[k + 1] * xp[k + 1];
212  prd_i += yp[k] * xp[k + 1] - yp[k + 1] * xp[k];
213  }
214  double prd[2] = { prd_r, prd_i };
215  ThreadManager_OpenMP::reduce_sum_global(prd, 2, i_thread, Nthread);
216  return cmplx(prd[0], prd[1]);
217  } else if ((y.field_element_type() == Element_type::REAL) &&
219  return cmplx(dot(y, exy, x, exx), 0.0);
220  } else {
221  vout.crucial("Error at %s: unsupported arg types.\n", __func__);
222  exit(EXIT_FAILURE);
223 
224  return cmplx(0.0, 0.0); // never reached.
225  }
226 }
227 
228 
229 //====================================================================
230 void dotc_and_norm2(dcomplex& yx, double& y2, double& x2,
231  const Field& y, const int exy, const Field& x, const int exx)
232 {
233  const double *yp = y.ptr(0, 0, exy);
234  const double *xp = x.ptr(0, 0, exx);
235 
236  assert(x.nin() == y.nin());
237  assert(x.nvol() == y.nvol());
238 
239  int i_thread, Nthread;
240  int is, ns;
241  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol() / 2);
242 
245  double prd_r = 0.0;
246  double prd_i = 0.0;
247  double prd_x2 = 0.0;
248  double prd_y2 = 0.0;
249 
250  for (int k = 2 * is; k < 2 * ns; k += 2) {
251  prd_r += yp[k] * xp[k] + yp[k + 1] * xp[k + 1];
252  prd_i += yp[k] * xp[k + 1] - yp[k + 1] * xp[k];
253  prd_x2 += xp[k] * xp[k] + xp[k + 1] * xp[k + 1];
254  prd_y2 += yp[k] * yp[k] + yp[k + 1] * yp[k + 1];
255  }
256  double prd[4] = { prd_r, prd_i, prd_x2, prd_y2 };
257  ThreadManager_OpenMP::reduce_sum_global(prd, 4, i_thread, Nthread);
258  yx = cmplx(prd[0], prd[1]);
259  y2 = prd[2];
260  x2 = prd[3];
261  } else if ((y.field_element_type() == Element_type::REAL) &&
263  double yx_re = 0.0;
264  dot_and_norm2(yx_re, y2, x2, y, exy, x, exx);
265  yx = cmplx(yx_re, 0.0);
266  } else {
267  vout.crucial("Error at %s: unsupported arg types.\n", __func__);
268  exit(EXIT_FAILURE);
269  // never reached.
270  }
271 }
272 
273 
274 //====================================================================
275 void dotc_and_norm2(dcomplex& yx, double& y2, double& x2,
276  const Field& y, const Field& x)
277 {
278  const double *yp = y.ptr(0);
279  const double *xp = x.ptr(0);
280 
281  assert(x.nin() == y.nin());
282  assert(x.nvol() == y.nvol());
283 
284  int i_thread, Nthread;
285  int is, ns;
286  set_threadtask(i_thread, Nthread, is, ns, x.ntot() / 2);
287 
290  double prd_r = 0.0;
291  double prd_i = 0.0;
292  double prd_x2 = 0.0;
293  double prd_y2 = 0.0;
294 
295  for (int k = 2 * is; k < 2 * ns; k += 2) {
296  prd_r += yp[k] * xp[k] + yp[k + 1] * xp[k + 1];
297  prd_i += yp[k] * xp[k + 1] - yp[k + 1] * xp[k];
298  prd_x2 += xp[k] * xp[k] + xp[k + 1] * xp[k + 1];
299  prd_y2 += yp[k] * yp[k] + yp[k + 1] * yp[k + 1];
300  }
301  double prd[4] = { prd_r, prd_i, prd_x2, prd_y2 };
302  ThreadManager_OpenMP::reduce_sum_global(prd, 4, i_thread, Nthread);
303  yx = cmplx(prd[0], prd[1]);
304  y2 = prd[2];
305  x2 = prd[3];
306  } else if ((y.field_element_type() == Element_type::REAL) &&
308  double yx_re = 0.0;
309  dot_and_norm2(yx_re, y2, x2, y, x);
310  yx = cmplx(yx_re, 0.0);
311  } else {
312  vout.crucial("Error at %s: unsupported arg types.\n", __func__);
313  exit(EXIT_FAILURE);
314  // never reached.
315  }
316 }
317 
318 
319 //====================================================================
320 void axpy(Field& y, const double a, const Field& x)
321 {
322  double *yp = y.ptr(0);
323  const double *xp = x.ptr(0);
324 
325  // int size = x.ntot();
326  int i_thread, Nthread, is, ns;
327 
328  set_threadtask(i_thread, Nthread, is, ns, x.ntot());
329 
330  for (int k = is; k < ns; ++k) {
331  yp[k] += a * xp[k];
332  }
333 }
334 
335 
336 //====================================================================
337 void axpy(Field& y, const int exy, const double a, const Field& x, const int exx)
338 {
339  assert(x.nin() == y.nin());
340  assert(x.nvol() == y.nvol());
341 
342  double *yp = y.ptr(0, 0, exy);
343  const double *xp = x.ptr(0, 0, exx);
344 
345  // int size = x.nin() * x.nvol();
346  int i_thread, Nthread, is, ns;
347  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol());
348 
349  for (int k = is; k < ns; ++k) {
350  yp[k] += a * xp[k];
351  }
352 }
353 
354 
355 //====================================================================
356 void axpy(Field& y, const dcomplex a, const Field& x)
357 {
358  if (imag(a) == 0.0) {
359  return axpy(y, real(a), x);
360  } else if ((y.field_element_type() == Element_type::REAL) &&
362  vout.crucial("Error at %s: real vector and complex parameter.\n", __func__);
363  exit(EXIT_FAILURE);
364 
365  return axpy(y, real(a), x); // ignore imaginary part of a
366  } else if ((y.field_element_type() == Element_type::COMPLEX) &&
368  double *yp = y.ptr(0);
369  const double *xp = x.ptr(0);
370 
371  assert(x.ntot() == y.ntot());
372 
373  // int ntot = x.ntot();
374  int i_thread, Nthread, is, ns;
375  set_threadtask(i_thread, Nthread, is, ns, x.ntot() / 2);
376 
377  double ar = real(a);
378  double ai = imag(a);
379 
380  for (int k = 2 * is; k < 2 * ns; k += 2) {
381  yp[k] += ar * xp[k] - ai * xp[k + 1];
382  yp[k + 1] += ar * xp[k + 1] + ai * xp[k];
383  }
384 
385  return;
386  } else {
387  vout.crucial("Error at %s: unsupported types.\n", __func__);
388  exit(EXIT_FAILURE);
389  }
390 }
391 
392 
393 //====================================================================
394 void axpy(Field& y, const int exy, const dcomplex a, const Field& x, const int exx)
395 {
396  if (imag(a) == 0.0) {
397  return axpy(y, exy, real(a), x, exx);
398  } else if ((y.field_element_type() == Element_type::REAL) &&
400  vout.crucial("Error at %s: real vector and complex parameter.\n", __func__);
401  exit(EXIT_FAILURE);
402 
403  return axpy(y, real(a), x); // ignore imaginary part of a
404  } else if ((y.field_element_type() == Element_type::COMPLEX) &&
406  double *yp = y.ptr(0, 0, exy);
407  const double *xp = x.ptr(0, 0, exx);
408 
409  assert(x.nin() == y.nin());
410  assert(x.nvol() == y.nvol());
411 
412  // int size = x.nin() * x.nvol();
413  int i_thread, Nthread, is, ns;
414  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol() / 2);
415 
416  double ar = real(a);
417  double ai = imag(a);
418 
419  for (int k = 2 * is; k < 2 * ns; k += 2) {
420  yp[k] += ar * xp[k] - ai * xp[k + 1];
421  yp[k + 1] += ar * xp[k + 1] + ai * xp[k];
422  }
423 
424  return;
425  } else {
426  vout.crucial("Error at %s: unsupported types.\n", __func__);
427  exit(EXIT_FAILURE);
428  }
429 }
430 
431 
432 //====================================================================
433 void scal(Field& x, const double a)
434 {
435  // x.field *= a;
436 
437  double *xp = x.ptr(0, 0, 0);
438  int i_thread, Nthread, is, ns;
439 
440  set_threadtask(i_thread, Nthread, is, ns, x.ntot());
441 
442  for (int k = is; k < ns; ++k) {
443  xp[k] *= a;
444  }
445 }
446 
447 
448 //====================================================================
449 void scal(Field& x, const int exx, const double a)
450 {
451  double *xp = x.ptr(0, 0, exx);
452  // int size = x.nin() * x.nvol();
453  int i_thread, Nthread, is, ns;
454 
455  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol());
456 
457  // for (int k = 0; k < size; ++k) {
458  for (int k = is; k < ns; ++k) {
459  // x.field[k] *= a;
460  xp[k] *= a;
461  }
462 }
463 
464 
465 //====================================================================
466 void scal(Field& x, const dcomplex a)
467 {
469  vout.crucial("Error at %s: real vector and complex parameter.\n", __func__);
470  exit(EXIT_FAILURE);
471 
472  // x.field *= real(a); // ignore imaginary part of a
473  scal(x, a);
474  } else if (x.field_element_type() == Element_type::COMPLEX) {
475  double *xp = x.ptr(0);
476  //int ntot = x.ntot();
477  int i_thread, Nthread, is, ns;
478  set_threadtask(i_thread, Nthread, is, ns, x.ntot() / 2);
479 
480  double ar = real(a);
481  double ai = imag(a);
482 
483  // for (int k = 0; k < ntot; k += 2) {
484  for (int k = 2 * is; k < 2 * ns; k += 2) {
485  double xr = xp[k];
486  double xi = xp[k + 1];
487 
488  xp[k] = ar * xr - ai * xi;
489  xp[k + 1] = ar * xi + ai * xr;
490  }
491  } else {
492  vout.crucial("Error at %s: unsupported field type.\n", __func__);
493  exit(EXIT_FAILURE);
494  }
495 }
496 
497 
498 //====================================================================
499 void scal(Field& x, const int exx, const dcomplex a)
500 {
502  vout.crucial("Error at %s: real vector and complex parameter.\n", __func__);
503  exit(EXIT_FAILURE);
504 
505  // x.field *= real(a); // ignore imaginary part of a
506  scal(x, exx, a);
507  } else if (x.field_element_type() == Element_type::COMPLEX) {
508  double *xp = x.ptr(0, 0, exx);
509  // int size = x.nin() * x.nvol();
510  int i_thread, Nthread, is, ns;
511  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol() / 2);
512 
513  double ar = real(a);
514  double ai = imag(a);
515 
516  // for (int k = 0; k < size; k += 2) {
517  for (int k = 2 * is; k < 2 * ns; k += 2) {
518  double xr = xp[k];
519  double xi = xp[k + 1];
520 
521  xp[k] = ar * xr - ai * xi;
522  xp[k + 1] = ar * xi + ai * xr;
523  }
524  } else {
525  vout.crucial("Error ar %s: unsupported field type.\n", __func__);
526  exit(EXIT_FAILURE);
527  }
528 }
529 
530 
531 //====================================================================
532 void copy(Field& y, const Field& x)
533 {
534  // y.field = x.field;
535 
536  assert(x.nin() == y.nin());
537  assert(x.nvol() == y.nvol());
538  assert(x.nex() == y.nex());
539 
540  double *yp = y.ptr(0, 0, 0);
541  const double *xp = x.ptr(0, 0, 0);
542 
543  int i_thread, Nthread, is, ns;
544  set_threadtask(i_thread, Nthread, is, ns, x.ntot());
545 
546  for (int k = is; k < ns; ++k) {
547  yp[k] = xp[k];
548  }
549 }
550 
551 
552 //====================================================================
553 void copy(Field& y, const int exy, const Field& x, const int exx)
554 {
555  assert(x.nin() == y.nin());
556  assert(x.nvol() == y.nvol());
557 
558  double *yp = y.ptr(0, 0, exy);
559  const double *xp = x.ptr(0, 0, exx);
560 
561  // int size = x.nin() * x.nvol();
562  int i_thread, Nthread, is, ns;
563  set_threadtask(i_thread, Nthread, is, ns, x.nin() * x.nvol());
564 
565  for (int k = is; k < ns; ++k) {
566  yp[k] = xp[k];
567  }
568 
572  // memcpy(yp, xp, sizeof(double) * size);
573 }
574 
575 
576 //====================================================================
577 void Field::set(double a)
578 {
579  int i_thread, Nthread, is, ns;
580 
581  set_threadtask(i_thread, Nthread, is, ns, ntot());
582 
583  double *yp = this->ptr(0);
584 
585  for (int k = is; k < ns; ++k) {
586  yp[k] = a;
587  }
588 }
589 
590 
591 //====================================================================
592 void Field::setc(const double a)
593 {
595  set(a);
596  } else if (m_element_type == Element_type::COMPLEX) {
597  dcomplex c = cmplx(a, 0.0);
598  setc(c);
599  } else {
600  vout.crucial("Error at %s: unsupported arg types.\n", __func__);
601  exit(EXIT_FAILURE);
602  }
603 }
604 
605 
606 //====================================================================
607 void Field::setc(const dcomplex a)
608 {
609  int i_thread, Nthread, is, ns;
610  double ar = real(a);
611  double ai = imag(a);
612 
614  if (fabs(ai) < fabs(ar) * CommonParameters::epsilon_criterion()) {
615  // if the argument is "real", treat it as a real number
616  set(ar);
617  } else {
618  vout.crucial("Error at %s: real vector and complex parameter.\n", __func__);
619  exit(EXIT_FAILURE);
620  }
621  } else if (m_element_type == Element_type::COMPLEX) {
622  set_threadtask(i_thread, Nthread, is, ns, ntot() / 2);
623  double *yp = this->ptr(0);
624 
625  for (int k = 2 * is; k < 2 * ns; k += 2) {
626  yp[k] = ar;
627  yp[k + 1] = ai;
628  }
629  } else {
630  vout.crucial("Error at %s: unsupported arg types.\n", __func__);
631  exit(EXIT_FAILURE);
632  }
633 }
634 
635 
636 //====================================================================
637 double Field::norm2() const
638 {
639  int i_thread, Nthread, is, ns;
640 
641  set_threadtask(i_thread, Nthread, is, ns, ntot());
642 
643  const double *yp = this->ptr(0);
644 
645  double a = 0.0;
646 
647  for (int k = is; k < ns; ++k) {
648  a += yp[k] * yp[k];
649  }
650  ThreadManager_OpenMP::reduce_sum_global(a, i_thread, Nthread);
651 
652  return a;
653 }
654 
655 
656 //====================================================================
657 void aypx(const double a, Field& y, const Field& x)
658 {
659  int i_thread, Nthread, is, ns;
660 
661  set_threadtask(i_thread, Nthread, is, ns, x.ntot());
662 
663  double *yp = y.ptr(0);
664  const double *xp = x.ptr(0);
665 
666  for (int k = is; k < ns; ++k) {
667  yp[k] = a * yp[k] + xp[k];
668  }
669 }
670 
671 
672 //====================================================================
673 void aypx(const dcomplex a, Field& y, const Field& x)
674 {
675  if (imag(a) == 0.0) {
676  return aypx(real(a), y, x);
677  } else if ((y.field_element_type() == Element_type::REAL) &&
679  vout.crucial("Error at %s: real vector and complex parameter.\n", __func__);
680  exit(EXIT_FAILURE);
681 
682  return aypx(real(a), y, x); // ignore imaginary part of a
683  } else if ((y.field_element_type() == Element_type::COMPLEX) &&
685  double *yp = y.ptr(0);
686  const double *xp = x.ptr(0);
687 
688  assert(x.ntot() == y.ntot());
689 
690  int i_thread, Nthread, is, ns;
691  set_threadtask(i_thread, Nthread, is, ns, x.ntot() / 2);
692 
693  double ar = real(a);
694  double ai = imag(a);
695 
696  for (int k = 2 * is; k < 2 * ns; k += 2) {
697  double ypr = yp[k];
698  double ypi = yp[k + 1];
699  yp[k] = ar * ypr - ai * ypi + xp[k];
700  yp[k + 1] = ar * ypi + ai * ypr + xp[k + 1];
701  }
702 
703  return;
704  } else {
705  vout.crucial("Error at %s: unsupported types.\n", __func__);
706  exit(EXIT_FAILURE);
707  }
708 }
709 
710 
711 //====================================================================
712 void Field::stat(double& Fave, double& Fmax, double& Fdev) const
713 {
715 
716  double sum = 0.0;
717  double sum2 = 0.0;
718 
719  Fmax = 0.0;
720  for (int ex = 0, nnex = nex(); ex < nnex; ++ex) {
721  for (int site = 0, nnvol = nvol(); site < nnvol; ++site) {
722  double fst = 0.0;
723  for (int in = 0, nnin = nin(); in < nnin; ++in) {
724  double fv = field[myindex(in, site, ex)];
725  fst += fv * fv;
726  }
727  sum2 += fst;
728  fst = sqrt(fst);
729  sum += fst;
730  if (fst > Fmax) Fmax = fst;
731  }
732  }
733 
734  sum = Communicator::reduce_sum(sum);
735  sum2 = Communicator::reduce_sum(sum2);
736  Fmax = Communicator::reduce_max(Fmax);
737 
738  double perdeg = 1.0 / ((double)CommonParameters::Lvol() * nex());
739  Fave = sum * perdeg;
740 
741  double fval = sum2 * perdeg;
742  fval -= Fave * Fave;
743  Fdev = sqrt(fval);
744 }
745 
746 
747 //====================================================================
749  const std::string& msg, const Field& f)
750 {
752 
753  double favg, fmax, fdev;
754  f.stat(favg, fmax, fdev);
755 
756  vout.general(vl,
757  " %s: avg = %12.6f max = %12.6f dev = %12.6f\n",
758  msg.c_str(),
759  favg, fmax, fdev);
760 }
761 
762 
763 //====================================================================
764 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:433
void report_field_stat(const Bridge::VerboseLevel vl, const std::string &msg, const Field &f)
Definition: field.cpp:748
BridgeIO vout
Definition: bridgeIO.cpp:503
static int get_num_threads()
returns available number of threads.
static int reduce_max(int count, double *recv_buf, double *send_buf, int pattern=0)
find a global maximum of an array of double over the communicator. pattern specifies the dimensions t...
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:154
static double epsilon_criterion()
double norm2() const
Definition: field.cpp:637
size_t myindex(const int jin, const int site, const int jex) const
Definition: field.h:65
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:176
double dot(const Field &y, const Field &x)
Definition: field.cpp:46
void dotc_and_norm2(dcomplex &yx, double &y2, double &x2, const Field &y, const int exy, const Field &x, const int exx)
Definition: field.cpp:230
void general(const char *format,...)
Definition: bridgeIO.cpp:197
Container of Field-type object.
Definition: field.h:46
int nvol() const
Definition: field.h:128
static int reduce_sum(int count, dcomplex *recv_buf, dcomplex *send_buf, int pattern=0)
make a global sum of an array of dcomplex over the communicator. pattern specifies the dimensions to ...
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:532
static int get_thread_id()
returns thread id.
element_type m_element_type
Definition: field.h:58
int nin() const
Definition: field.h:127
dcomplex dotc(const Field &y, const Field &x)
Definition: field.cpp:156
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
Definition: field.cpp:657
void check()
Definition: field.cpp:39
int nex() const
Definition: field.h:129
std::valarray< double > field
Definition: field.h:61
long long_t
definition of long for Bridge++
Definition: bridge_long.h:46
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:320
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
static void reduce_sum_global(dcomplex &value, const int i_thread, const int Nthread)
global reduction with summation: dcomplex values are assumed thread local.
Bridge::VerboseLevel vl
int ntot() const
Definition: field.h:132
VerboseLevel
Definition: bridgeIO.h:42
element_type field_element_type() const
Definition: field.h:130
void setc(double a)
Definition: field.cpp:592
void stat(double &Fave, double &Fmax, double &Fdev) const
determines the statistics of the field. average, maximum value, and deviation is determined over glob...
Definition: field.cpp:712
void dot_and_norm2(double &yx, double &y2, double &x2, const Field &y, const int exy, const Field &x, const int exx)
Definition: field.cpp:92
static long_t Lvol()