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