CHROMA
zN_src.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Variety of Z(N) noise sources
3  */
4 
5 #include "chromabase.h"
6 #include "meas/sources/zN_src.h"
7 
8 namespace Chroma
9 {
10 
11  // Z(N)-rng
12  Complex zN_rng(int N)
13  {
14  Real rnd1;
15  random(rnd1);
16 
17  Real twopiN = Chroma::twopi / N;
18  Real theta = twopiN * floor(N*rnd1);
19 
20  return cmplx(cos(theta),sin(theta));
21  }
22 
23 
24  //! Volume source of Z(N) noise
25  /*!
26  * \ingroup sources
27  *
28  * This routine is specific to Wilson fermions!
29  *
30  * \param a Source fermion
31  * \param N The N in Z(N)
32  *
33  *
34  * This type of source is required to compute disconnected
35  * diagrams. The source is complex Z(N) noise, hence there
36  * is an additional normalization factor of 1/sqrt(N) or somesuch.
37  *
38  *
39  */
40 
41  void zN_src(LatticeFermion & a, int N)
42  {
43  a = zero;
44  LatticeReal rnd1, theta;
45  Real twopiN = Chroma::twopi / N; // twopi defined in chroma/lib/chromabase.h
46  LatticeComplex c;
47  LatticeColorVector colorvec = zero;
48 
49  for(int spin_index= 0; spin_index < Ns; ++spin_index)
50  for(int color_index= 0; color_index < Nc; ++color_index)
51  {
52  random(rnd1);
53  theta = twopiN * floor(N*rnd1);
54  c = cmplx(cos(theta),sin(theta));
55 
56  colorvec = peekSpin(a,spin_index);
57 
58  pokeSpin(a,pokeColor(colorvec,c,color_index),spin_index);
59  }
60 
61  }
62 
63 
64 } // end namespace Chroma
65 
Primary include file for CHROMA library code.
void zN_src(LatticeFermion &a, int N)
Volume source of Z(N) noise.
Definition: zN_src.cc:41
Complex zN_rng(int N)
Z(N)-rng.
Definition: zN_src.cc:12
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
Double c
Definition: invbicg.cc:108
const Real twopi
Definition: chromabase.h:55
Complex a
Definition: invbicg.cc:95
Double zero
Definition: invbicg.cc:106
Volume source of Z(N) noise.