Bridge++  Ver.2.1.3
tensorProd.cpp
Go to the documentation of this file.
1 
10 #include <cassert>
11 
13 
15 
16 // This implementation only applies to SU(3) group and Nd=4 case.
17 #if defined USE_GROUP_SU3
18 #define NC 3
19 #define NC2 6
20 #define NDF 18
21 #define ND 4
22 #define NCD2 24
23 #define C1 0
24 #define C2 2
25 #define C3 4
26 #elif defined USE_GROUP_SU2
27 #define NC 2
28 #define NC2 4
29 #define NDF 8
30 #define ND 4
31 #define NCD2 16
32 #endif
33 
34 //====================================================================
35 void tensorProd_Field_F(Field_G& u, const Field_F& v1, const Field_F& v2)
36 {
37  return tensorProd_Field_F(u, 0, v1, v2);
38 }
39 
40 
41 //====================================================================
42 void tensorProd_Field_F(Field_G& u, const int ex, const Field_F& v1, const Field_F& v2)
43 {
44 #pragma omp barrier
45 
46  const int Nvol = u.nvol();
47 
48  assert(Nvol == v1.nvol());
49  assert(Nvol == v2.nvol());
50  assert(ex < u.nex());
51  assert(v1.nex() == 1);
52  assert(v2.nex() == 1);
53 
54 #if defined USE_GROUP_SU_N
55  const int NC = CommonParameters::Nc();
56  const int ND = CommonParameters::Nd();
57  const int NC2 = 2 * NC;
58  const int NDF = 2 * NC * NC;
59  const int NCD2 = NC2 * ND;
60 #endif
61 
62  const double *w1 = v1.ptr(0);
63  const double *w2 = v2.ptr(0);
64  double *g = u.ptr(0, 0, ex);
65 
66  int ith, nth, is, ns;
67  set_threadtask(ith, nth, is, ns, Nvol);
68 
69  for (int site = is; site < ns; ++site) {
70  int iw = NCD2 * site;
71  int ig = NDF * site;
72 
73  for (int c1 = 0; c1 < NC; ++c1) {
74  for (int c2 = 0; c2 < NC; ++c2) {
75  int c1_r = 2 * c1;
76  int c1_i = 2 * c1 + 1;
77 
78  int c2_r = 2 * c2;
79  int c2_i = 2 * c2 + 1;
80 
81  int ig_r = c2 * 2 + c1 * NC2 + ig;
82  int ig_i = c2 * 2 + c1 * NC2 + ig + 1;
83 
84  g[ig_r] = 0.0;
85  g[ig_i] = 0.0;
86 
87  for (int s = 0; s < ND; ++s) {
88  g[ig_r] += w1[c2_r + s * NC2 + iw] * w2[c1_r + s * NC2 + iw]
89  + w1[c2_i + s * NC2 + iw] * w2[c1_i + s * NC2 + iw];
90  g[ig_i] += w1[c2_r + s * NC2 + iw] * w2[c1_i + s * NC2 + iw]
91  - w1[c2_i + s * NC2 + iw] * w2[c1_r + s * NC2 + iw];
92  }
93  }
94  }
95  }
96 
97 #pragma omp barrier
98 }
99 
100 
101 //================================================================
NC2
#define NC2
Definition: field_F_imp_SU2-inc.h:16
Field::nex
int nex() const
Definition: field.h:128
NDF
#define NDF
Definition: field_F_imp_SU2-inc.h:17
tensorProd_Field_F
void tensorProd_Field_F(Field_G &u, const Field_F &v1, const Field_F &v2)
Definition: tensorProd.cpp:35
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
NC
#define NC
Definition: field_F_imp_SU2-inc.h:15
NCD2
#define NCD2
Definition: field_F_imp_SU2-inc.h:20
ND
#define ND
Definition: field_F_imp_SU2-inc.h:18
Field::nvol
int nvol() const
Definition: field.h:127
Field::ptr
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:153
CommonParameters::Nd
static int Nd()
Definition: commonParameters.h:116
Field_F
Wilson-type fermion field.
Definition: field_F.h:37
field_thread-inc.h
tensorProd.h
Field_G
SU(N) gauge field.
Definition: field_G.h:38