CHROMA
disp_soln_cache.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Cache for distillation - holds solution vectors
3  */
4 
5 #include "chromabase.h"
6 #ifndef QDP_IS_QDPJIT_NO_NVPTX
7 
9 #include "meas/smear/displace.h"
10 
11 
12 namespace Chroma
13 {
14  // Utility functions
15  namespace
16  {
17  //! Error output
18  StandardOutputStream& operator<<(StandardOutputStream& os, const multi1d<int>& d)
19  {
20  if (d.size() > 0)
21  {
22  os << d[0];
23 
24  for(int i=1; i < d.size(); ++i)
25  os << " " << d[i];
26  }
27 
28  return os;
29  }
30  }
31 
32 
33  //----------------------------------------------------------------------------
34  // Quark read
35  void read(BinaryReader& bin, KeyDispSolnVector_t& param)
36  {
37  read(bin, param.use_derivP);
38  read(bin, param.displacement);
39  read(bin, param.mom);
40  }
41 
42  // Quark write
43  void write(BinaryWriter& bin, const KeyDispSolnVector_t& param)
44  {
45  write(bin, param.use_derivP);
46  write(bin, param.displacement);
47  write(bin, param.mom);
48  }
49 
50 
51 
52  //----------------------------------------------------------------------------
53  // Constructor from smeared map
54  DispSolnCache::DispSolnCache(const multi1d<LatticeColorMatrix>& u_smr,
55  const LatticeColorVectorSpinMatrix& soln_)
56  : displacement_length(1), u(u_smr), soln(soln_)
57  {
58  }
59 
60 
61  //! Accessor
62  const LatticeColorVectorSpinMatrix&
63  DispSolnCache::getDispVector(bool use_derivP, const multi1d<int>& mom,
64  const std::vector<int>& disp)
65  {
67  key.use_derivP = use_derivP;
68  key.mom = mom;
69  key.displacement = disp;
70 
71  return displaceObject(key);
72  }
73 
74 
75  //! Accessor
76  const LatticeColorVectorSpinMatrix&
78  {
79 
80  // If no entry, then create a displaced version of the quark
81  if (! disp_src_map.exist(key))
82  {
83  // Only need to do more if there are displacements
84  if (key.displacement.size() == 0)
85  {
86  // Pull out the soln vector
87  // disp_src_map.insert(key, soln);
88  return soln;
89  }
90  else
91  {
92  // Have at least one displacement. Pull that one off the end of the list
93  KeyDispSolnVector_t prev_key = key;
94 
95  int d = key.displacement.back();
96  prev_key.displacement.pop_back();
97 
98  // Recursively get a reference to the object to be shifted
99  const LatticeColorVectorSpinMatrix& disp_q = this->displaceObject(prev_key);
100 
101  // Displace or deriv the old vector
102  if (d > 0)
103  {
104  int disp_dir = d - 1;
105  int disp_len = displacement_length;
106  if (key.use_derivP)
107  disp_src_map.insert(key, leftRightNabla(disp_q, u, disp_dir, disp_len, key.mom[disp_dir]));
108  else
109  disp_src_map.insert(key, displace(u, disp_q, disp_len, disp_dir));
110  }
111  else if (d < 0)
112  {
113  if (key.use_derivP)
114  {
115  QDPIO::cerr << __func__ << ": do not support (rather do not want to support) negative displacements for rightNabla\n";
116  QDP_abort(1);
117  }
118 
119  int disp_dir = -d - 1;
120  int disp_len = -displacement_length;
121  disp_src_map.insert(key, displace(u, disp_q, disp_len, disp_dir));
122  }
123  }
124  } // if find in map
125 
126  // The key now must exist in the map, so return the vector
127  return disp_src_map[key];
128  }
129 
130 
131  /*! @} */ // end of group smear
132 
133 } // namespace Chroma
134 #endif
135 
Primary include file for CHROMA library code.
const LatticeColorVectorSpinMatrix & soln
QDP::MapObjectMemory< KeyDispSolnVector_t, LatticeColorVectorSpinMatrix > disp_src_map
Unsmeared vectors.
const LatticeColorVectorSpinMatrix & displaceObject(const KeyDispSolnVector_t &key)
Displace an object.
const multi1d< LatticeColorMatrix > & u
Gauge field.
DispSolnCache(const multi1d< LatticeColorMatrix > &u_smr, const LatticeColorVectorSpinMatrix &soln_)
Default constructor.
int displacement_length
Displacement length.
const LatticeColorVectorSpinMatrix & getDispVector(bool use_derivP, const multi1d< int > &mom, const std::vector< int > &disp)
Accessor.
Cache for displaced solution vectors.
Parallel transport a lattice field.
void read(XMLReader &xml, const std::string &path, AsqtadFermActParams &param)
Read parameters.
void write(XMLWriter &xml, const std::string &path, const AsqtadFermActParams &param)
Writer parameters.
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
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP::StandardOutputStream & operator<<(QDP::StandardOutputStream &s, const multi1d< int > &d)
Definition: npr_vertex_w.cc:12
static multi1d< LatticeColorMatrix > u
int i
Definition: pbg5p_w.cc:55
DComplex d
Definition: invbicg.cc:99
The key for displaced color vectors.
std::vector< int > displacement