Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
field_F.cpp
Go to the documentation of this file.
1 
14 #include "Field/field_F.h"
15 #include "Field/index_lex.h"
16 
17 using std::valarray;
18 
19 //====================================================================
20 void Field_F::check()
21 {
22  // do nothing.
23 }
24 
25 
26 //====================================================================
27 void mult_Field_Gn(Field_F& y, const int ex,
28  const Field_G& U, int ex1,
29  const Field_F& x, int ex2)
30 {
31  assert(ex < y.nex());
32  assert(ex1 < U.nex());
33  assert(ex2 < x.nex());
34  assert(U.nvol() == y.nvol());
35  assert(x.nvol() == y.nvol());
36 
37  const int Nvol = x.nvol();
38  const int Nd = x.nd();
39  const int Nc = x.nc();
40 
41  for (int site = 0; site < Nvol; ++site) {
42  for (int s = 0; s < Nd; ++s) {
43  y.set_vec(s, site, ex, U.mat(site, ex1) * x.vec(s, site, ex2));
44  }
45  }
46 }
47 
48 
49 //====================================================================
50 void mult_Field_Gd(Field_F& y, const int ex,
51  const Field_G& U, int ex1,
52  const Field_F& x, int ex2)
53 {
54  assert(ex < y.nex());
55  assert(ex1 < U.nex());
56  assert(ex2 < x.nex());
57  assert(U.nvol() == y.nvol());
58  assert(x.nvol() == y.nvol());
59 
60  const int Nvol = y.nvol();
61  const int Nd = y.nd();
62  const int Nc = y.nc();
63 
64  for (int site = 0; site < Nvol; ++site) {
65  for (int s = 0; s < Nd; ++s) {
66  y.set_vec(s, site, ex, U.mat_dag(site, ex1) * x.vec(s, site, ex2));
67  }
68  }
69 }
70 
71 
72 //====================================================================
73 void multadd_Field_Gn(Field_F& y, const int ex,
74  const Field_G& U, int ex1,
75  const Field_F& x, int ex2,
76  const double a)
77 {
78  assert(ex < y.nex());
79  assert(ex1 < U.nex());
80  assert(ex2 < x.nex());
81  assert(U.nvol() == y.nvol());
82  assert(x.nvol() == y.nvol());
83 
84  const int Nvol = y.nvol();
85  const int Nd = y.nd();
86  const int Nc = y.nc();
87 
88  Vec_SU_N vec(Nc);
89 
90  for (int site = 0; site < Nvol; ++site) {
91  for (int s = 0; s < Nd; ++s) {
92  y.add_vec(s, site, ex, U.mat(site, ex1) * x.vec(s, site, ex2) * a);
93  }
94  }
95 }
96 
97 
98 //====================================================================
99 void multadd_Field_Gd(Field_F& y, const int ex,
100  const Field_G& U, int ex1,
101  const Field_F& x, int ex2,
102  const double a)
103 {
104  assert(ex < y.nex());
105  assert(ex1 < U.nex());
106  assert(ex2 < x.nex());
107  assert(U.nvol() == y.nvol());
108  assert(x.nvol() == y.nvol());
109 
110  const int Nvol = y.nvol();
111  const int Nd = y.nd();
112  const int Nc = y.nc();
113 
114  for (int site = 0; site < Nvol; ++site) {
115  for (int s = 0; s < Nd; ++s) {
116  y.add_vec(s, site, ex, U.mat_dag(site, ex1) * x.vec(s, site, ex2) * a);
117  }
118  }
119 }
120 
121 
122 //====================================================================
123 void mult_GM(Field_F& v, const GammaMatrix& gm, const Field_F& w)
124 {
125  assert(w.nex() == v.nex());
126  assert(w.nvol() == v.nvol());
127 
128  const int Nvol = v.nvol();
129  const int Nex = v.nex();
130  const int Nd = v.nd();
131  const int Nc = v.nc();
132 
133  valarray<int> id(Nd);
134  valarray<int> idc_r(Nd);
135  valarray<int> idc_i(Nd);
136  valarray<double> gv_r(Nd);
137  valarray<double> gv_i(Nd);
138 
139  for (int s = 0; s < Nd; ++s) {
140  id[s] = gm.index(s);
141  gv_r[s] = gm.value_r(s);
142  gv_i[s] = gm.value_i(s);
143  idc_r[s] = gm.index_c(s);
144  idc_i[s] = 1 - idc_r[s];
145  }
146 
147  for (int ex = 0; ex < Nex; ++ex) {
148  for (int site = 0; site < Nvol; ++site) {
149  for (int s = 0; s < Nd; ++s) {
150  for (int c = 0; c < Nc; ++c) {
151  double ww[2];
152  ww[0] = w.cmp_r(c, id[s], site, ex);
153  ww[1] = w.cmp_i(c, id[s], site, ex);
154 
155  v.set_ri(c, s, site, ex,
156  gv_r[s] * ww[idc_r[s]],
157  gv_i[s] * ww[idc_i[s]]);
158  }
159  }
160  }
161  }
162 }
163 
164 
165 //====================================================================
166 void mult_iGM(Field_F& v, const GammaMatrix& gm, const Field_F& w)
167 {
168  assert(w.nex() == v.nex());
169  assert(w.nvol() == v.nvol());
170 
171  const int Nvol = v.nvol();
172  const int Nex = v.nex();
173  const int Nd = v.nd();
174  const int Nc = v.nc();
175 
176  valarray<int> id(Nd);
177  valarray<int> idc_r(Nd);
178  valarray<int> idc_i(Nd);
179  valarray<double> gv_r(Nd);
180  valarray<double> gv_i(Nd);
181 
182  for (int s = 0; s < Nd; ++s) {
183  id[s] = gm.index(s);
184  gv_r[s] = -gm.value_i(s);
185  gv_i[s] = gm.value_r(s);
186  idc_r[s] = 1 - gm.index_c(s);
187  idc_i[s] = 1 - idc_r[s];
188  }
189 
190  for (int ex = 0; ex < Nex; ++ex) {
191  for (int site = 0; site < Nvol; ++site) {
192  for (int s = 0; s < Nd; ++s) {
193  for (int c = 0; c < Nc; ++c) {
194  double ww[2];
195  ww[0] = w.cmp_r(c, id[s], site, ex);
196  ww[1] = w.cmp_i(c, id[s], site, ex);
197 
198  v.set_ri(c, s, site, ex,
199  gv_r[s] * ww[idc_r[s]],
200  gv_i[s] * ww[idc_i[s]]);
201  }
202  }
203  }
204  }
205 }
206 
207 
208 //====================================================================
210  const int pm, const GammaMatrix& gm,
211  const Field_F& w)
212 {
213  assert(w.nvol() == v.nvol());
214  assert(w.nex() == v.nex());
215  assert(pm == 1 || pm == -1);
216 
217  mult_GM(v, gm, w);
218 
219  if (pm == 1) {
220  axpy(v, 1.0, w); // v += w;
221  scal(v, 0.5); // v *= 0.5;
222  } else if (pm == -1) {
223  axpy(v, -1.0, w); // v -= w i.e. v = (gamma - 1) * w
224  scal(v, -0.5); // v *= -0.5 i.e. v = (1 - gamma)/2 * w
225  } else {
226  vout.crucial("Error at %s: wrong pm = %d\n", __func__, pm);
227  exit(EXIT_FAILURE);
228  }
229 }
230 
231 
232 //====================================================================
234  const int pm, const GammaMatrix& gm,
235  const Field_F& w)
236 {
237  assert(w.nvol() == v.nvol());
238  assert(w.nex() == v.nex());
239  assert(pm == 1 || pm == -1);
240 
241  mult_GM(v, gm, w);
242 
243  if (pm == 1) {
244  axpy(v, 1.0, w); // v += w;
245  } else if (pm == -1) {
246  axpy(v, -1.0, w); // v -= w;
247  scal(v, -1.0); // v *= -1.0;
248  } else {
249  vout.crucial("Error at %s: wrong pm = %d\n", __func__, pm);
250  exit(EXIT_FAILURE);
251  }
252 }
253 
254 
255 //====================================================================
257  const double nu_s,
258  const int pm,
259  const double r_s,
260  const GammaMatrix& gm,
261  const Field_F& w)
262 {
263  assert(w.nvol() == v.nvol());
264  assert(w.nex() == v.nex());
265  assert(pm == 1 || pm == -1);
266 
267  mult_GM(v, gm, w);
268  scal(v, nu_s); // v *= nu_s;
269 
270  if (pm == 1) {
271  axpy(v, r_s, w); // v += r_s * w;
272  } else if (pm == -1) {
273  axpy(v, -r_s, w); // v -= r_s * w i.e. v = (nu_s * gamma - r_s) * w
274  scal(v, -1.0); // v *= -1.0 i.e. v = (r_s - nu_s * gamma) * w
275  } else {
276  vout.crucial("Error at %s: wrong pm = %d\n", __func__, pm);
277  exit(EXIT_FAILURE);
278  }
279 }
280 
281 
282 //====================================================================
283 //============================================================END=====
void scal(Field &x, const double a)
scal(x, a): x = a * x
Definition: field.cpp:433
BridgeIO vout
Definition: bridgeIO.cpp:503
double cmp_i(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:100
void set_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:134
void mult_Field_Gn(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2)
Definition: field_F.cpp:27
void check()
check several assumptions for performance implementation.
Definition: field_F_imp.cpp:25
int nvol() const
Definition: field.h:127
void multadd_Field_Gn(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2, const double a)
Definition: field_F.cpp:73
void multadd_Field_Gd(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2, const double a)
Definition: field_F.cpp:99
Wilson-type fermion field.
Definition: field_F.h:37
Gamma Matrix class.
Definition: gammaMatrix.h:44
double value_r(int row) const
Definition: gammaMatrix.h:98
SU(N) gauge field.
Definition: field_G.h:38
void set_ri(const int cc, const int s, const int site, const int e, const double re, const double im)
Definition: field_F.h:116
void mult_iGM(Field_F &v, const GammaMatrix &gm, const Field_F &w)
gamma matrix multiplication (i is multiplied)
Definition: field_F.cpp:166
int nex() const
Definition: field.h:128
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:319
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void mult_GMproj2(Field_F &v, const int pm, const GammaMatrix &gm, const Field_F &w)
projection with gamma matrix: (1 gamma)
Definition: field_F.cpp:233
int index_c(int row) const
Definition: gammaMatrix.h:93
int nc() const
Definition: field_F.h:89
void mult_GMproj(Field_F &v, const int pm, const GammaMatrix &gm, const Field_F &w)
projection with gamma matrix: (1 gamma)/2
Definition: field_F.cpp:209
Vec_SU_N vec(const int s, const int site, const int e=0) const
Definition: field_F.h:122
Mat_SU_N mat_dag(const int site, const int mn=0) const
Definition: field_G.h:127
double value_i(int row) const
Definition: gammaMatrix.h:103
void mult_GM(Field_F &v, const GammaMatrix &gm, const Field_F &w)
gamma matrix multiplication
Definition: field_F.cpp:123
void add_vec(const int s, const int site, const int e, const Vec_SU_N &F)
Definition: field_F.h:142
int nd() const
Definition: field_F.h:91
Mat_SU_N mat(const int site, const int mn=0) const
Definition: field_G.h:114
void mult_Field_Gd(Field_F &y, const int ex, const Field_G &U, int ex1, const Field_F &x, int ex2)
Definition: field_F.cpp:50
int index(int row) const
Definition: gammaMatrix.h:83
double cmp_r(const int cc, const int s, const int site, const int e=0) const
Definition: field_F.h:94