Bridge++  Version 1.4.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  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  int NC = CommonParameters::Nc();
51  int ND = CommonParameters::Nd();
52  int NC2 = 2 * NC;
53  int NDF = 2 * NC * NC;
54  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  for (int c1 = 0; c1 < NC; ++c1) {
65  for (int c2 = 0; c2 < NC; ++c2) {
66  int ig2 = c2 * 2 + c1 * NC2 + ig;
67  g[ig2] = 0.0;
68  g[ig2 + 1] = 0.0;
69  for (int s = 0; s < ND; ++s) {
70  g[ig2] +=
71  w1[2 * c2 + s * NC2 + iw] * w2[2 * c1 + s * NC2 + iw]
72  + w1[2 * c2 + 1 + s * NC2 + iw] * w2[2 * c1 + 1 + s * NC2 + iw];
73  g[ig2 + 1] +=
74  w1[2 * c2 + s * NC2 + iw] * w2[2 * c1 + 1 + s * NC2 + iw]
75  - w1[2 * c2 + 1 + s * NC2 + iw] * w2[2 * c1 + s * NC2 + iw];
76  }
77  }
78  }
79  }
80 }
81 
82 
83 //================================================================
const double * ptr(const int jin, const int site, const int jex) const
Definition: field.h:142
int nvol() const
Definition: field.h:116
#define NC
Wilson-type fermion field.
Definition: field_F.h:37
SU(N) gauge field.
Definition: field_G.h:38
int nex() const
Definition: field.h:117
void tensorProd_Field_F(Field_G &u, const Field_F &v1, const Field_F &v2)
Definition: tensorProd.cpp:32