CHROMA
single_phase.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Compute a single phase factor
3  */
4 
5 #include "chromabase.h"
6 #include "util/ft/single_phase.h"
7 
8 namespace Chroma
9 {
10 
11  //! A single exp(ip.x) phase used in hadron construction
12  /*! @ingroup ft */
13  LatticeComplex singlePhase(const multi1d<int>& t_srce,
14  const multi1d<int>& sink_mom,
15  int j_decay)
16  {
17  START_CODE();
18 
19  // Sanity checks
20  if (j_decay < 0 || j_decay >= Nd)
21  {
22  QDPIO::cerr << __func__ << ": j_decay out of bounds" << std::endl;
23  QDP_abort(1);
24  }
25 
26  if (t_srce.size() != Nd)
27  {
28  QDPIO::cerr << __func__ << ": t_srce not of size = " << Nd << std::endl;
29  QDP_abort(1);
30  }
31 
32  if (sink_mom.size() != Nd-1)
33  {
34  QDPIO::cerr << __func__ << ": mom not of size = " << Nd-1 << std::endl;
35  QDP_abort(1);
36  }
37 
38  /*
39  * We now inject momentum at sink if required
40  */
41  LatticeReal p_dot_x = zero;
42  bool nonzeroP = false;
43  for(int mu=0, j=0; mu < Nd; mu++)
44  {
45  if (mu != j_decay)
46  {
47  if (sink_mom[j] != 0)
48  {
49  nonzeroP = true;
50  p_dot_x += (Layout::latticeCoordinate(mu) - t_srce[mu]) * sink_mom[j]
51  * twopi / Real(Layout::lattSize()[mu]);
52  }
53  j++;
54  }
55  }
56 
57  LatticeComplex phase;
58 
59  if (nonzeroP)
60  phase = cmplx(cos(p_dot_x),sin(p_dot_x));
61  else
62  phase = 1.0;
63 
64  END_CODE();
65 
66  return phase;
67  }
68 
69  LatticeComplex singlePhase(const multi1d<int>& t_srce,
70  const multi1d<int>& sink_mom)
71  {
72  START_CODE();
73 
74  if (t_srce.size() != Nd)
75  {
76  QDPIO::cerr << __func__ << ": t_srce not of size = " << Nd << std::endl;
77  QDP_abort(1);
78  }
79 
80  if (sink_mom.size() != Nd)
81  {
82  QDPIO::cerr << __func__ << ": mom not of size = " << Nd << std::endl;
83  QDP_abort(1);
84  }
85 
86  /*
87  * We now inject momentum at sink if required
88  */
89  LatticeReal p_dot_x = zero;
90  bool nonzeroP = false;
91  for(int mu=0, j=0; mu < Nd; mu++)
92  {
93  if (sink_mom[mu] != 0)
94  {
95  nonzeroP = true;
96  p_dot_x += (Layout::latticeCoordinate(mu) - t_srce[mu]) * sink_mom[mu]
97  * twopi / Real(Layout::lattSize()[mu]);
98  }
99  }
100 
101  LatticeComplex phase;
102 
103  if (nonzeroP)
104  phase = cmplx(cos(p_dot_x),sin(p_dot_x));
105  else
106  phase = 1.0;
107 
108  END_CODE();
109 
110  return phase;
111  }
112 
113 } // end namespace Chroma
Primary include file for CHROMA library code.
int mu
Definition: cool.cc:24
LatticeComplex singlePhase(const multi1d< int > &t_srce, const multi1d< int > &sink_mom, int j_decay)
A single exp(ip.x) phase used in hadron construction.
Definition: single_phase.cc:13
multi1d< int > t_srce
unsigned j
Definition: ldumul_w.cc:35
int j_decay
Definition: meslate.cc:22
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
const Real twopi
Definition: chromabase.h:55
START_CODE()
Double zero
Definition: invbicg.cc:106
Compute a single phase factor.