CHROMA
displace.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Parallel transport a lattice field
3  *
4  * Description:
5  *
6  * Suppose q(x) is a quark field.
7  * Displacement operator D_j^{(p)} moves quark field
8  * for p lattice sites to the direction j in covariant
9  * fashion.
10  *
11  * Namely,
12  * D_j^{(p)} q(x) = U_j(x) U_j(x+j) U_j(x+2j)...U_j(x+(p-1)j) q(x+pj),
13  * where U is the gauge-link.
14  *
15  * dir: x(0), y(1), z(2)
16  *
17  */
18 
19 #include "meas/smear/displace.h"
20 #include "util/ferm/symtensor.h"
22 #include "util/ferm/etensor.h"
23 
24 namespace Chroma
25 {
26 
27  //! Apply a displacement operator to a lattice field
28  /*!
29  * \ingroup smear
30  *
31  * Arguments:
32  *
33  * \param u gauge field ( Read )
34  * \param psi lattice field ( Read )
35  * \param length length of displacement ( Read )
36  * \param dir direction of displacement ( Read )
37  *
38  * \return displaced field
39  */
40  template<typename T>
41  T displace(const multi1d<LatticeColorMatrix>& u,
42  const T& psi,
43  int length, int dir,
44  const Subset& sub)
45  {
46  if (dir < 0 || dir >= Nd)
47  {
48  QDPIO::cerr << __func__ << ": invalid direction: dir=" << dir << std::endl;
49  QDP_abort(1);
50  }
51 
52  T tmp;
53  T chi;
54  chi[sub] = psi;
55 
56  if (length > 0)
57  {
58  for(int n = 0; n < length; ++n)
59  {
60  tmp[sub] = shift(chi, FORWARD, dir);
61  chi[sub] = u[dir] * tmp;
62  }
63  }
64  else // If length = or < 0. If length == 0, does nothing.
65  {
66  for(int n = 0; n > length; --n)
67  {
68  tmp[sub] = shift(adj(u[dir])*chi, BACKWARD, dir);
69  chi[sub] = tmp;
70  }
71  }
72  return chi;
73  }
74 
75 
76  // Apply a displacement operator to a lattice field
77  LatticeColorVector displace(const multi1d<LatticeColorMatrix>& u,
78  const LatticeColorVector& chi,
79  int length, int dir)
80  {
81  return displace<LatticeColorVector>(u, chi, length, dir, QDP::all);
82  }
83 
84 
85  LatticeColorVector displace(const multi1d<LatticeColorMatrix>& u,
86  const LatticeColorVector& chi,
87  int length, int dir, const Subset& sub)
88  {
89  return displace<LatticeColorVector>(u, chi, length, dir, sub);
90  }
91 
92 
93  // Apply a displacement operator to a lattice field
94  LatticeColorMatrix displace(const multi1d<LatticeColorMatrix>& u,
95  const LatticeColorMatrix& chi,
96  int length, int dir)
97  {
98  return displace<LatticeColorMatrix>(u, chi, length, dir, QDP::all);
99  }
100 
101 
102  LatticeColorMatrix displace(const multi1d<LatticeColorMatrix>& u,
103  const LatticeColorMatrix& chi,
104  int length, int dir, const Subset& sub)
105  {
106  return displace<LatticeColorMatrix>(u, chi, length, dir, sub);
107  }
108 
109 
110  // Apply a displacement operator to a lattice field
111  LatticeFermion displace(const multi1d<LatticeColorMatrix>& u,
112  const LatticeFermion& chi,
113  int length, int dir)
114  {
115  return displace<LatticeFermion>(u, chi, length, dir, QDP::all);
116  }
117 
118  // Apply a displacement operator to a lattice field
119  LatticePropagator displace(const multi1d<LatticeColorMatrix>& u,
120  const LatticePropagator& chi,
121  int length, int dir)
122  {
123  return displace<LatticePropagator>(u, chi, length, dir, QDP::all);
124  }
125 
126 
127 #ifndef QDP_IS_QDPJIT_NO_NVPTX
128  // Apply a displacement operator to a lattice field
129  LatticeColorVectorSpinMatrix displace(const multi1d<LatticeColorMatrix>& u,
130  const LatticeColorVectorSpinMatrix& chi,
131  int length, int dir)
132  {
133  return displace<LatticeColorVectorSpinMatrix>(u, chi, length, dir, QDP::all);
134  }
135 #endif
136 
137  // Apply a displacement operator to a lattice field
138  LatticeStaggeredFermion displace(const multi1d<LatticeColorMatrix>& u,
139  const LatticeStaggeredFermion& chi,
140  int length, int dir)
141  {
142  return displace<LatticeStaggeredFermion>(u, chi, length, dir, QDP::all);
143  }
144 
145 
146  // Apply a displacement operator to a lattice field
147  LatticeStaggeredPropagator displace(const multi1d<LatticeColorMatrix>& u,
148  const LatticeStaggeredPropagator& chi,
149  int length, int dir)
150  {
151  return displace<LatticeStaggeredPropagator>(u, chi, length, dir, QDP::all);
152  }
153 
154 
155 
156  //! Apply a displacement path to a lattice field
157  /*!
158  * \ingroup smear
159  *
160  * Arguments:
161  *
162  * \param u gauge field ( Read )
163  * \param chi color std::vector field ( Read )
164  * \param length displacement length - must be greater than zero ( Read )
165  * \param path array of direction of displacement paths - pos/neg, or zero ( Read )
166  * \param sub Subset of sites to act ( Read )
167  *
168  * \return displaced field
169  */
170  template<typename T>
171  T displace(const multi1d<LatticeColorMatrix>& u,
172  const T& psi,
173  int displacement_length,
174  const multi1d<int>& path,
175  const Subset& sub)
176  {
177  if (displacement_length < 0)
178  {
179  QDPIO::cerr << __func__ << ": invalid length=" << displacement_length << std::endl;
180  QDP_abort(1);
181  }
182 
183  T chi;
184  chi[sub] = psi;
185 
186  for(int i=0; i < path.size(); ++i)
187  {
188  if (path[i] > 0)
189  {
190  int disp_dir = path[i] - 1;
191  int disp_len = displacement_length;
192  chi[sub] = displace<T>(u, chi, disp_len, disp_dir, sub);
193  }
194  else if (path[i] < 0)
195  {
196  int disp_dir = -path[i] - 1;
197  int disp_len = -displacement_length;
198  chi[sub] = displace<T>(u, chi, disp_len, disp_dir, sub);
199  }
200  }
201 
202  return chi;
203  }
204 
205 
206  // Apply a displacement path to a lattice field
207  LatticeColorVector displace(const multi1d<LatticeColorMatrix>& u,
208  const LatticeColorVector& chi,
209  int length, const multi1d<int>& path)
210  {
211  return displace<LatticeColorVector>(u, chi, length, path, QDP::all);
212  }
213 
214  // Apply a displacement path to a lattice field
215  LatticeColorVector displace(const multi1d<LatticeColorMatrix>& u,
216  const LatticeColorVector& chi,
217  int length, const multi1d<int>& path,
218  const Subset& sub)
219  {
220  return displace<LatticeColorVector>(u, chi, length, path, sub);
221  }
222 
223 
224  // Apply a displacement path to a lattice field
225  LatticeColorMatrix displace(const multi1d<LatticeColorMatrix>& u,
226  const LatticeColorMatrix& chi,
227  int length, const multi1d<int>& path)
228  {
229  return displace<LatticeColorMatrix>(u, chi, length, path, QDP::all);
230  }
231 
232  // Apply a displacement path to a lattice field
233  LatticeColorMatrix displace(const multi1d<LatticeColorMatrix>& u,
234  const LatticeColorMatrix& chi,
235  int length, const multi1d<int>& path,
236  const Subset& sub)
237  {
238  return displace<LatticeColorMatrix>(u, chi, length, path, sub);
239  }
240 
241 
242  // Apply a displacement path to a lattice field
243  LatticeFermion displace(const multi1d<LatticeColorMatrix>& u,
244  const LatticeFermion& chi,
245  int length, const multi1d<int>& path)
246  {
247  return displace<LatticeFermion>(u, chi, length, path, QDP::all);
248  }
249 
250  // Apply a displacement path to a lattice field
251  LatticeFermion displace(const multi1d<LatticeColorMatrix>& u,
252  const LatticeFermion& chi,
253  int length, const multi1d<int>& path,
254  const Subset& sub)
255  {
256  return displace<LatticeFermion>(u, chi, length, path, sub);
257  }
258 
259  // Apply a displacement path to a lattice field
260  LatticePropagator displace(const multi1d<LatticeColorMatrix>& u,
261  const LatticePropagator& p,
262  int length, const multi1d<int>& path)
263  {
264  return displace<LatticePropagator>(u, p, length, path, QDP::all);
265  }
266 
267  // Apply a displacement path to a lattice field
268  LatticePropagator displace(const multi1d<LatticeColorMatrix>& u,
269  const LatticePropagator& p,
270  int length, const multi1d<int>& path,
271  const Subset& sub )
272  {
273  return displace<LatticePropagator>(u, p, length, path, sub);
274  }
275 
276 
277  //! Apply a right derivative path to a lattice field
278  /*! \ingroup smear */
279  template<typename T>
280  T rightNablaT(const T& F,
281  const multi1d<LatticeColorMatrix>& u,
282  int mu, int length)
283  {
284  return displace<T>(u, F, length, mu, QDP::all) - displace<T>(u, F, -length, mu, QDP::all);
285  }
286 
287 
288  //! Apply first deriv to the right onto source
289  /*!
290  * \ingroup sources
291  *
292  * \f$\nabla_\mu f(x) = U_\mu(x)f(x+\mu) - U_{-\mu}(x)f(x-\mu)\f$
293  *
294  * \return $\f \nabla_\mu F(x)\f$
295  */
296  LatticeColorVector rightNabla(const LatticeColorVector& F,
297  const multi1d<LatticeColorMatrix>& u,
298  int mu, int length)
299  {
300  return rightNablaT<LatticeColorVector>(F, u, mu, length);
301  }
302 
303  //! Apply first deriv to the right onto source
304  LatticeFermion rightNabla(const LatticeFermion& F,
305  const multi1d<LatticeColorMatrix>& u,
306  int mu, int length)
307  {
308  return rightNablaT<LatticeFermion>(F, u, mu, length);
309  }
310 
311  //! Apply first deriv to the right onto source
312  LatticePropagator rightNabla(const LatticePropagator& F,
313  const multi1d<LatticeColorMatrix>& u,
314  int mu, int length)
315  {
316  return rightNablaT<LatticePropagator>(F, u, mu, length);
317  }
318 
319 
320  //! Apply a right derivative path to a lattice field
321  /*! \ingroup smear */
322  template<typename T>
323  T rightNablaT(const multi1d<LatticeColorMatrix>& u,
324  const T& psi,
325  int displacement_length,
326  const multi1d<int>& path)
327  {
328  if (displacement_length < 0)
329  {
330  QDPIO::cerr << __func__ << ": invalid length=" << displacement_length << std::endl;
331  QDP_abort(1);
332  }
333 
334  T chi;
335  chi = psi;
336 
337  for(int i=0; i < path.size(); ++i)
338  {
339  if (path[i] > 0)
340  {
341  int disp_dir = path[i] - 1;
342  int disp_len = displacement_length;
343  chi = rightNablaT<T>(chi, u, disp_dir, disp_len);
344  }
345  else if (path[i] <= 0)
346  {
347  QDPIO::cerr << __func__ << ": invalid path dir=" << path[i] << std::endl;
348  QDP_abort(1);
349  }
350  }
351 
352  return chi;
353  }
354 
355 
356  //! Apply first deriv to the right onto source
357  LatticeColorVector rightNabla(const multi1d<LatticeColorMatrix>& u,
358  const LatticeColorVector& chi,
359  int length, const multi1d<int>& path)
360  {
361  return rightNablaT<LatticeColorVector>(u, chi, length, path);
362  }
363 
364  //! Apply first deriv to the right onto source
365  LatticeColorMatrix rightNabla(const multi1d<LatticeColorMatrix>& u,
366  const LatticeColorMatrix& chi,
367  int length, const multi1d<int>& path)
368  {
369  return rightNablaT<LatticeColorMatrix>(u, chi, length, path);
370  }
371 
372 
373  //! Apply first deriv to the right onto source
374  LatticeFermion rightNabla(const multi1d<LatticeColorMatrix>& u,
375  const LatticeFermion& chi,
376  int length, const multi1d<int>& path)
377  {
378  return rightNablaT<LatticeFermion>(u, chi, length, path);
379  }
380 
381  //! Apply first deriv to the right onto source
382  LatticePropagator rightNabla(const multi1d<LatticeColorMatrix>& u,
383  const LatticePropagator& chi,
384  int length, const multi1d<int>& path)
385  {
386  return rightNablaT<LatticePropagator>(u, chi, length, path);
387  }
388 
389 
390  //----------------------------------------------------------------------------------
391  //! Apply a left-right derivative to a lattice field
392  /*! \ingroup smear */
393  template<typename T>
394  T leftRightNablaT(const T& F,
395  const multi1d<LatticeColorMatrix>& u,
396  int mu, int length,
397  int mom)
398  {
399  Real angle = twopi*mom / Real(Layout::lattSize()[mu]);
400  Complex phase = cmplx(cos(angle),sin(angle));
401 
402  return (Real(1) + conj(phase))*displace<T>(u, F, -length, mu, QDP::all) - (Real(1) + phase)*displace<T>(u, F, length, mu, QDP::all);
403  }
404 
405 
406  //! Apply left-right deriv to the right onto source
407  /*!
408  * \ingroup sources
409  *
410  * \f$\right\nabla_\mu f(x) = U_\mu(x)f(x+\mu) - U_{-\mu}(x)f(x-\mu)\f$
411  * \f$\left\nabla_\mu f(x) = f(x+\mu)U_{-\mu}(x) - f(x-\mu)U_\mu(x-\mu)\f$
412  *
413  * \return $\f (\left\nabla_\mu - \right\nabla_\mu) F(x)\f$
414  */
415  LatticeColorVector leftRightNabla(const LatticeColorVector& F,
416  const multi1d<LatticeColorMatrix>& u,
417  int mu, int length,
418  int mom)
419  {
420  return leftRightNablaT<LatticeColorVector>(F, u, mu, length, mom);
421  }
422 
423  //! Apply left-right deriv to the right onto source
424  LatticeFermion leftRightNabla(const LatticeFermion& F,
425  const multi1d<LatticeColorMatrix>& u,
426  int mu, int length,
427  int mom)
428  {
429  return leftRightNablaT<LatticeFermion>(F, u, mu, length, mom);
430  }
431 
432  //! Apply first deriv to the right onto source
433  LatticePropagator leftRightNabla(const LatticePropagator& F,
434  const multi1d<LatticeColorMatrix>& u,
435  int mu, int length,
436  int mom)
437  {
438  return leftRightNablaT<LatticePropagator>(F, u, mu, length, mom);
439  }
440 
441 #ifndef QDP_IS_QDPJIT_NO_NVPTX
442  //! Apply first deriv to the right onto source
443  LatticeColorVectorSpinMatrix leftRightNabla(const LatticeColorVectorSpinMatrix& F,
444  const multi1d<LatticeColorMatrix>& u,
445  int mu, int length,
446  int mom)
447  {
448  return leftRightNablaT<LatticeColorVectorSpinMatrix>(F, u, mu, length, mom);
449  }
450 
451 #endif
452 
453  //! Apply a right derivative path to a lattice field
454  /*! \ingroup smear */
455  template<typename T>
456  T leftRightNablaT(const multi1d<LatticeColorMatrix>& u,
457  const T& psi,
458  int displacement_length,
459  const multi1d<int>& path,
460  const multi1d<int>& mom)
461  {
462  if (displacement_length < 0)
463  {
464  QDPIO::cerr << __func__ << ": invalid length=" << displacement_length << std::endl;
465  QDP_abort(1);
466  }
467 
468  T chi;
469  chi = psi;
470 
471  for(int i=0; i < path.size(); ++i)
472  {
473  if (path[i] > 0)
474  {
475  int disp_dir = path[i] - 1;
476  int disp_len = displacement_length;
477  chi = leftRightNablaT<T>(chi, u, disp_dir, disp_len, mom[disp_dir]);
478  }
479  else if (path[i] <= 0)
480  {
481  QDPIO::cerr << __func__ << ": invalid path dir=" << path[i] << std::endl;
482  QDP_abort(1);
483  }
484  }
485 
486  return chi;
487  }
488 
489 
490  //! Apply first deriv to the right onto source
491  LatticeColorVector leftRightNabla(const multi1d<LatticeColorMatrix>& u,
492  const LatticeColorVector& chi,
493  int length,
494  const multi1d<int>& path,
495  const multi1d<int>& mom)
496  {
497  return leftRightNablaT<LatticeColorVector>(u, chi, length, path, mom);
498  }
499 
500  //! Apply first deriv to the right onto source
501  LatticeColorMatrix leftRightNabla(const multi1d<LatticeColorMatrix>& u,
502  const LatticeColorMatrix& chi,
503  int length,
504  const multi1d<int>& path,
505  const multi1d<int>& mom)
506  {
507  return leftRightNablaT<LatticeColorMatrix>(u, chi, length, path, mom);
508  }
509 
510 
511 
512  //----------------------------------------------------------------------------------
513  //! Apply "D_i" operator to the right onto source
514  /*!
515  * \ingroup sources
516  *
517  * \f$D_i = s_{ijk}\nabla_j\nabla_k\f$
518  *
519  * where \f$s_{ijk} = +1 \quad\forall i\ne j, j\ne k, i \ne k\f$
520  *
521  * \return $\f F(z,0) D_\mu\f$
522  */
523  LatticePropagator rightD(const LatticePropagator& F,
524  const multi1d<LatticeColorMatrix>& u,
525  int mu, int length)
526  {
527  LatticePropagator tmp = zero;
528 
529  // Slow implementation - to speed up could compute once the \nabla_j deriv
530  for(int j=0; j < 3; ++j)
531  for(int k=0; k < 3; ++k)
532  {
533  if (symTensor3d(mu,j,k) != 0)
534  tmp += rightNabla(rightNabla(F,u,j,length), u,k,length);
535  }
536 
537  return tmp;
538  }
539 
540 
541  //! Apply "B_i" operator to the right onto source
542  /*!
543  * \ingroup sources
544  *
545  * \f$B_i = \epsilon_{ijk}\nabla_j\nabla_k\f$
546  *
547  * \return $\f F(z,0) B_\mu\f$
548  */
549  LatticePropagator rightB(const LatticePropagator& F,
550  const multi1d<LatticeColorMatrix>& u,
551  int mu, int length)
552  {
553  LatticePropagator tmp = zero;
554 
555  // Slow implementation - to speed up could compute once the \nabla_j deriv
556  for(int j=0; j < 3; ++j)
557  for(int k=0; k < 3; ++k)
558  {
559  if (antiSymTensor3d(mu,j,k) != 0)
560  tmp += Real(antiSymTensor3d(mu,j,k)) * rightNabla(rightNabla(F,u,j,length), u,k,length);
561  }
562 
563  return tmp;
564  }
565 
566 
567  //! Apply "E_i" operator to the right onto source
568  /*!
569  * \ingroup smear
570  *
571  * \f$E_0 = (1/sqrt{2})*\nabla_x\nabla_x - \nabla_y\nabla_y\f$
572  * \f$E_1 = -(1/sqrt{6})*\nabla_x\nabla_x + \nabla_y\nabla_y - 2*\nabla_z\nabla_z\f$
573  *
574  * \return $\f E_\alpha F(z,0) \f$
575  */
576  LatticePropagator rightE(const LatticePropagator& F,
577  const multi1d<LatticeColorMatrix>& u,
578  int mu, int length)
579  {
580  LatticePropagator tmp;
581 
582  switch (mu)
583  {
584  case 0:
585  tmp = rightNabla(rightNabla(F,u,0,length), u,0,length);
586  tmp -= rightNabla(rightNabla(F,u,1,length), u,1,length);
587  tmp *= Real(1)/Real(sqrt(Real(2)));
588  break;
589 
590  case 1:
591  tmp = rightNabla(rightNabla(F,u,0,length), u,0,length);
592  tmp += rightNabla(rightNabla(F,u,1,length), u,1,length);
593  tmp -= Real(2)*rightNabla(rightNabla(F,u,2,length), u,2,length);
594  tmp *= Real(-1)/Real(sqrt(Real(6)));
595  break;
596 
597  default:
598  QDPIO::cerr << __func__ << ": invalid direction for E: mu=" << mu << std::endl;
599  QDP_abort(1);
600  }
601 
602  return tmp;
603  }
604 
605 
606  //! Apply "Laplacian" operator to the right onto source
607  /*!
608  * \ingroup smear
609  *
610  * \f$Laplacian = \sum_{i=1}^3\nabla_i\nabla_i\f$
611  *
612  * \return $\f \nabla^2 F(z,0) \f$
613  */
614  LatticePropagator rightLap(const LatticePropagator& F,
615  const multi1d<LatticeColorMatrix>& u,
616  int length)
617  {
618  LatticePropagator tmp = zero;
619 
620  for(int i=0; i < 3; ++i)
621  {
622  tmp += rightNabla(rightNabla(F,u,i,length), u,i,length);
623  }
624 
625  return tmp;
626  }
627 
628 
629 } // end namespace Chroma
Compute anti-symmetric tensors.
int mu
Definition: cool.cc:24
Parallel transport a lattice field.
Tensor used for E representations.
int symTensor3d(int i, int j, int k)
Return 3d symmetric tensor.
Definition: symtensor.cc:54
int antiSymTensor3d(int i, int j, int k)
Return 3d symmetric tensor.
LatticeColorVector rightNabla(const multi1d< LatticeColorMatrix > &u, const LatticeColorVector &chi, int length, const multi1d< int > &path)
Apply a right nabla path to a lattice field.
T rightNablaT(const T &F, const multi1d< LatticeColorMatrix > &u, int mu, int length)
Apply a right derivative path to a lattice field.
Definition: displace.cc:280
LatticePropagator rightLap(const LatticePropagator &F, const multi1d< LatticeColorMatrix > &u, int length)
Apply "E_i" operator to the right onto source.
Definition: displace.cc:614
T leftRightNablaT(const multi1d< LatticeColorMatrix > &u, const T &psi, int displacement_length, const multi1d< int > &path, const multi1d< int > &mom)
Apply a right derivative path to a lattice field.
Definition: displace.cc:456
T displace(const multi1d< LatticeColorMatrix > &u, const T &psi, int length, int dir, const Subset &sub)
Apply a displacement operator to a lattice field.
Definition: displace.cc:41
LatticeColorVector leftRightNabla(const LatticeColorVector &F, const multi1d< LatticeColorMatrix > &u, int mu, int length, int mom)
Apply first deriv to the right onto source.
Definition: displace.cc:415
LatticePropagator rightB(const LatticePropagator &F, const multi1d< LatticeColorMatrix > &u, int mu, int length)
Apply "D_i" operator to the right onto source.
Definition: displace.cc:549
unsigned j
Definition: ldumul_w.cc:35
unsigned n
Definition: ldumul_w.cc:36
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
static multi1d< LatticeColorMatrix > u
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
multi1d< LatticeFermion > chi(Ncb)
const Real twopi
Definition: chromabase.h:55
LatticeFermion psi
Definition: mespbg5p_w.cc:35
Double zero
Definition: invbicg.cc:106
int k
Definition: invbicg.cc:119
#define FORWARD
Definition: primitives.h:82
#define BACKWARD
Definition: primitives.h:83
Compute symmetric tensors.
LatticeFermion T
Definition: t_clover.cc:11
static INTERNAL_PRECISION F