Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tensorProd.cpp
Go to the documentation of this file.
1 
10 #include "tensorProd.h"
11 #include <cassert>
12 
13 // This implementation only applies to SU(3) group and Nd=4 case.
14 #define NC 3
15 #define NC2 6
16 #define NDF 18
17 #define ND 4
18 #define NCD 12
19 #define NCD2 24
20 
21 void tensorProd_Field_F(Field_G& u, const Field_F& v1, const Field_F& v2)
22 {
23  int Nvol = u.nvol();
24 
25  assert(Nvol == v1.nvol());
26  assert(Nvol == v2.nvol());
27  assert(u.nex() == 1);
28  assert(v1.nex() == 1);
29  assert(v2.nex() == 1);
30 
31  double *w1;
32  double *w2;
33  double *g;
34  w1 = const_cast<Field_F *>(&v1)->ptr(0);
35  w2 = const_cast<Field_F *>(&v2)->ptr(0);
36  g = (&u)->ptr(0);
37 
38  for (int site = 0; site < Nvol; ++site) {
39  int iw = NCD2 * site;
40  int ig = NDF * site;
41  for (int c1 = 0; c1 < NC; ++c1) {
42  for (int c2 = 0; c2 < NC; ++c2) {
43  int ig2 = c2 * 2 + c1 * NC2 + ig;
44  g[ig2] = 0.0;
45  g[ig2 + 1] = 0.0;
46  for (int s = 0; s < ND; ++s) {
47  g[ig2] +=
48  w1[2 * c2 + s * NC2 + iw] * w2[2 * c1 + s * NC2 + iw]
49  + w1[2 * c2 + 1 + s * NC2 + iw] * w2[2 * c1 + 1 + s * NC2 + iw];
50  g[ig2 + 1] +=
51  w1[2 * c2 + s * NC2 + iw] * w2[2 * c1 + 1 + s * NC2 + iw]
52  - w1[2 * c2 + 1 + s * NC2 + iw] * w2[2 * c1 + s * NC2 + iw];
53  }
54  }
55  }
56  }
57 }