CHROMA
disp_colvec_map.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Holds displaced color vectors
4  */
5 
8 #include "meas/smear/displace.h"
9 
10 namespace Chroma
11 {
12  // Support for the keys of displaced color vectors
14  {
15  multi1d<int> lgaa(1);
16  lgaa[0] = a.colvec;
17  multi1d<int> lga = concat(lgaa, a.displacement);
18 
19  multi1d<int> lgbb(1);
20  lgbb[0] = b.colvec;
21  multi1d<int> lgb = concat(lgbb, b.displacement);
22 
23  return (lga < lgb);
24  }
25 
26 
27  // Constructor from smeared std::map
29  int disp_length,
30  const multi1d<LatticeColorMatrix>& u_smr,
31  const MapObject<int,EVPair<LatticeColorVector> >& eigen_vec)
32  : use_derivP(use_derivP_), displacement_length(disp_length), u(u_smr), eigen_source(eigen_vec)
33  {
34  }
35 
36 
37  //! Accessor
38  const LatticeColorVector
40  {
41  //Check if any displacement is needed
42  if (displacement_length == 0)
43  {
45  eigen_source.get(key.colvec, tmpvec);
46  return tmpvec.eigenVector;
47  }
48  else
49  {
50  return displaceObject(key);
51  }
52  }
53 
54 
55  //! Accessor
56  const LatticeColorVector&
58  {
59  // If no entry, then create a displaced version of the quark
60  if (disp_src_map.find(key) == disp_src_map.end())
61  {
62  // Insert an empty entry and then modify it. This saves on
63  // copying the data around
64  {
65  ValDispColorVector_t disp_empty;
66 
67  disp_src_map.insert(std::make_pair(key, disp_empty));
68 
69  // Sanity check - the entry better be there
70  if (disp_src_map.find(key) == disp_src_map.end())
71  {
72  QDPIO::cerr << __func__
73  << ": internal error - could not insert empty key in std::map"
74  << std::endl;
75  QDP_abort(1);
76  }
77  }
78 
79  // Modify the previous empty entry
80  ValDispColorVector_t& disp_q = disp_src_map.find(key)->second;
81  {
83  eigen_source.get(key.colvec, tmpvec);
84  disp_q.vec = tmpvec.eigenVector;
85  }
86 
87  for(int i=0; i < key.displacement.size(); ++i)
88  {
89  if (key.displacement[i] > 0)
90  {
91  int disp_dir = key.displacement[i] - 1;
92  int disp_len = displacement_length;
93  if (use_derivP)
94  disp_q.vec = rightNabla(disp_q.vec, u, disp_dir, disp_len);
95  else
96  displacement(u, disp_q.vec, disp_len, disp_dir);
97  }
98  else if (key.displacement[i] < 0)
99  {
100  if (use_derivP)
101  {
102  QDPIO::cerr << __func__ << ": do not support (rather do not want to support) negative displacements for rightNabla\n";
103  QDP_abort(1);
104  }
105 
106  int disp_dir = -key.displacement[i] - 1;
107  int disp_len = -displacement_length;
108  displacement(u, disp_q.vec, disp_len, disp_dir);
109  }
110  }
111 
112  } // if find in std::map
113 
114  // The key now must exist in the std::map, so return the std::vector
115  ValDispColorVector_t& disp_q = disp_src_map.find(key)->second;
116 
117  return disp_q.vec;
118  }
119 
120  /*! @} */ // end of group smear
121 
122 } // namespace Chroma
std::map< KeyDispColorVector_t, ValDispColorVector_t > disp_src_map
Maps of displaced color vectors.
const QDP::MapObject< int, EVPair< LatticeColorVector > > & eigen_source
Lattice color vectors.
DispColorVectorMap(bool use_derivP, int disp_length, const multi1d< LatticeColorMatrix > &u_smr, const QDP::MapObject< int, EVPair< LatticeColorVector > > &eigen_source)
Constructor for displaced std::map.
const multi1d< LatticeColorMatrix > & u
Gauge field.
int use_derivP
Displacements or derivatives?
const LatticeColorVector getDispVector(const KeyDispColorVector_t &key)
Accessor.
int displacement_length
Displacement length.
const LatticeColorVector & displaceObject(const KeyDispColorVector_t &key)
Displace an object.
Holds displaced color vectors.
Parallel transport a lattice field.
Parallel transport a lattice field.
LatticeColorVector rightNabla(const multi1d< LatticeColorMatrix > &u, const LatticeColorVector &chi, int length, const multi1d< int > &path)
Apply a right nabla path to a lattice field.
LatticePropagator displacement(const multi1d< LatticeColorMatrix > &u, const LatticePropagator &chi, int length, int dir)
Apply a displacement operator to a lattice field.
MODS_t & eigen_source
Eigenvectors.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
bool operator<(const KeyDispColorVector_t &a, const KeyDispColorVector_t &b)
Support for the keys of smeared and displaced color vectors.
static multi1d< LatticeColorMatrix > u
int i
Definition: pbg5p_w.cc:55
Complex a
Definition: invbicg.cc:95
Complex b
Definition: invbicg.cc:96
A Pair type.
The key for displaced color vectors.
The value of the std::map.