CHROMA
lwldslash_base_array_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Wilson Dslash linear operator over arrays
3  */
4 
5 #include "chromabase.h"
7 
8 
9 namespace Chroma
10 {
11  //! Take deriv of D
12  /*!
13  * \param chi left std::vector (Read)
14  * \param psi right std::vector (Read)
15  * \param isign D'^dag or D' ( MINUS | PLUS ) resp. (Read)
16  *
17  * \return Computes \f$\chi^\dag * \dot(D} * \psi\f$
18  */
19  void
20  WilsonDslashBaseArray::deriv(multi1d<LatticeColorMatrix>& ds_u,
21  const multi1d<LatticeFermion>& chi,
22  const multi1d<LatticeFermion>& psi,
23  enum PlusMinus isign) const
24  {
25  ds_u.resize(Nd);
26  ds_u = zero;
27  multi1d<LatticeColorMatrix> ds_tmp(Nd);
28 
29  for(int n = 0; n < psi.size(); ++n)
30  {
31  deriv(ds_tmp, chi[n], psi[n], isign, 0);
32  ds_u += ds_tmp;
33  deriv(ds_tmp, chi[n], psi[n], isign, 1);
34  ds_u += ds_tmp;
35  }
36  }
37 
38 
39  //! Take deriv of D
40  /*! \return Computes \f$\chi^\dag * \dot(D} * \psi\f$ */
41  void
42  WilsonDslashBaseArray::deriv(multi1d<LatticeColorMatrix>& ds_u,
43  const multi1d<LatticeFermion>& chi,
44  const multi1d<LatticeFermion>& psi,
45  enum PlusMinus isign, int cb) const
46  {
47  START_CODE();
48 
49  ds_u.resize(Nd);
50  ds_u = zero;
51 
52  multi1d<LatticeColorMatrix> ds_tmp(Nd);
53 
54  for(int n = 0; n < psi.size(); ++n)
55  {
56  deriv(ds_tmp, chi[n], psi[n], isign, cb);
57  ds_u += ds_tmp;
58  }
59 
60  END_CODE();
61  }
62 
63 
64  //! Take deriv of D
65  /*! \return Computes \f$\chi^\dag * \dot(D} * \psi\f$ */
66  void
67  WilsonDslashBaseArray::deriv(multi1d<LatticeColorMatrix>& ds_u,
68  const LatticeFermion& chi,
69  const LatticeFermion& psi,
70  enum PlusMinus isign, int cb) const
71  {
72  START_CODE();
73 
74  ds_u.resize(Nd);
75 
76  const multi1d<Real>& anisoWeights = getCoeffs();
77 
78  // Carbon copy of the 4D case, so play the same tricks
79  for(int mu = 0; mu < Nd; ++mu) {
80 
81  // Break this up to use fewer expressions:
82  LatticeFermion temp_ferm1;
83  LatticeHalfFermion tmp_h;
84 
85  // Instead of using Gamma(1 << mu) use a spinProject followed by
86  // reconstruct.
87  switch (isign) {
88  case PLUS:
89 
90  // Undaggered: Minus Projectors
91  {
92 
93  switch(mu) {
94  case 0:
95  tmp_h[rb[1-cb]] = spinProjectDir0Minus(psi);
96  temp_ferm1[rb[1-cb]] = spinReconstructDir0Minus(tmp_h);
97  break;
98  case 1:
99  tmp_h[rb[1-cb]] = spinProjectDir1Minus(psi);
100  temp_ferm1[rb[1-cb]] = spinReconstructDir1Minus(tmp_h);
101  break;
102  case 2:
103  tmp_h[rb[1-cb]] = spinProjectDir2Minus(psi);
104  temp_ferm1[rb[1-cb]] = spinReconstructDir2Minus(tmp_h);
105  break;
106  case 3:
107  tmp_h[rb[1-cb]] = spinProjectDir3Minus(psi);
108  temp_ferm1[rb[1-cb]] = spinReconstructDir3Minus(tmp_h);
109  break;
110  default:
111  break;
112  };
113 
114  }
115  break;
116 
117  case MINUS:
118  {
119  // Daggered: Plus Projectors
120  LatticeHalfFermion tmp_h;
121  switch(mu) {
122  case 0:
123  tmp_h[rb[1-cb]] = spinProjectDir0Plus(psi);
124  temp_ferm1[rb[1-cb]] = spinReconstructDir0Plus(tmp_h);
125  break;
126  case 1:
127  tmp_h[rb[1-cb]] = spinProjectDir1Plus(psi);
128  temp_ferm1[rb[1-cb]] = spinReconstructDir1Plus(tmp_h);
129  break;
130  case 2:
131  tmp_h[rb[1-cb]] = spinProjectDir2Plus(psi);
132  temp_ferm1[rb[1-cb]] = spinReconstructDir2Plus(tmp_h);
133  break;
134  case 3:
135  tmp_h[rb[1-cb]] = spinProjectDir3Plus(psi);
136  temp_ferm1[rb[1-cb]] = spinReconstructDir3Plus(tmp_h);
137  break;
138  default:
139  break;
140  };
141  }
142  break;
143  default:
144  QDP_error_exit("unknown case");
145  }
146 
147  // QDP Shifts the whole darn thing anyhow
148  LatticeFermion temp_ferm2 = shift(temp_ferm1, FORWARD, mu);
149  LatticeColorMatrix temp_mat;
150 
151  // This step supposedly optimised in QDP++
152  temp_mat[rb[cb]] = traceSpin(outerProduct(temp_ferm2,chi));
153 
154  // Just do the bit we need.
155  ds_u[mu][rb[cb]] = anisoWeights[mu] * temp_mat;
156  ds_u[mu][rb[1-cb]] = zero;
157  }
158 
159  getFermBC().zero(ds_u);
160  END_CODE();
161  }
162 
163 
164  //! Return flops performed by the operator()
165  unsigned long
166  WilsonDslashBaseArray::nFlops() const {return size()*1320;}
167 
168 } // End Namespace Chroma
169 
Primary include file for CHROMA library code.
unsigned long nFlops() const
Return flops performed by the operator()
virtual const multi1d< Real > & getCoeffs() const =0
Get the anisotropy parameters.
virtual const FermBC< T, P, Q > & getFermBC() const =0
Return the fermion BC object for this linear operator.
virtual void deriv(multi1d< LatticeColorMatrix > &ds_u, const multi1d< LatticeFermion > &chi, const multi1d< LatticeFermion > &psi, enum PlusMinus isign) const
Take deriv of D.
int mu
Definition: cool.cc:24
unsigned n
Definition: ldumul_w.cc:36
Wilson Dslash linear operator over arrays.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
int cb
Definition: invbicg.cc:120
Double zero
Definition: invbicg.cc:106
#define FORWARD
Definition: primitives.h:82