CHROMA
last_solution_predictor.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Last solution predictor
4  *
5  * Predictors for HMC
6  */
7 
8 #ifndef __last_solution_predictor_h__
9 #define __last_solution_predictor_h__
10 
11 #include "chromabase.h"
14 
15 
16 namespace Chroma
17 {
18 
19  /*! @ingroup predictor */
20  namespace LastSolution4DChronoPredictorEnv
21  {
22  extern const std::string name;
23  bool registerAll();
24  }
25 
26 
27  //! Last solution predictor
28  /*! @ingroup predictor */
30  public AbsTwoStepChronologicalPredictor4D<LatticeFermion>
31  {
32 
33  public:
34 
35  // Destructor is automagic
37 
42 
48 
49  // Zero out psi -- it is a zero guess after all
50  void predictX(LatticeFermion& X,
52  const LatticeFermion& chi)
53  {
54  START_CODE();
55 
56  QDPIO::cout << "LastSolution4DChronoPredictor: ";
58  QDPIO::cout << "Giving you the last solution" << std::endl;
59  X = last_solutionX;
60  }
61  else {
62  QDPIO::cout << "No available last guess. Giving you zero" << std::endl;
63  X = zero;
64  }
65 
66  END_CODE();
67  }
68 
69  // Zero out psi -- it is a zero guess after all
70  void predictY(LatticeFermion& Y,
72  const LatticeFermion& chi)
73  {
74  START_CODE();
75 
76  QDPIO::cout << "LastSolution4DChronoPredictor: ";
78  QDPIO::cout << "Giving you the last solution" << std::endl;
79  Y = last_solutionY;
80  }
81  else {
82  QDPIO::cout << "No available last guess. Giving you zero" << std::endl;
83  Y = zero;
84  }
85 
86  END_CODE();
87  }
88 
89  // No internal state so reset is a nop
90  void reset(void)
91  {
92 
93  // Set the dirty bit
96 
97  }
98 
99  // Ignore new std::vector
100  void newXVector(const LatticeFermion& X)
101  {
102  START_CODE();
103 
104  QDPIO::cout << "LastSolutionPredictor: registering new solution" << std::endl;
105  last_solutionX = X;
107 
108  END_CODE();
109  }
110 
111  // Ignore new std::vector
112  void newYVector(const LatticeFermion& Y)
113  {
114  START_CODE();
115 
116  QDPIO::cout << "LastSolutionPredictor: registering new solution" << std::endl;
117  last_solutionY = Y;
119 
120  END_CODE();
121  }
122 
123  private:
124 
127  LatticeFermion last_solutionX;
128  LatticeFermion last_solutionY;
129 
130  };
131 
132 
133 
134  /*! @ingroup predictor */
135  namespace LastSolution5DChronoPredictorEnv
136  {
137  extern const std::string name;
138  bool registerAll();
139  }
140 
141  //! Last solution predictor
142  /*! @ingroup predictor */
144  public AbsChronologicalPredictor5D<LatticeFermion>
145  {
146 
147  public:
149 
150  // Creation
152 
153  // Copying
156 
157  // Zero out psi -- it is a zero guess after all
158  void operator()(multi1d<LatticeFermion>& psi,
160  const multi1d<LatticeFermion>& chi)
161  {
162  START_CODE();
163 
164  QDPIO::cout << "LastSolutionPredictor:";
165  psi.resize(N5);
166  if( last_solution_available ) {
167  QDPIO::cout << " last solution is available. Giving you it" << std::endl;
168  psi = last_solution;
169  }
170  else {
171  QDPIO::cout << " last solution is not available. Giving you zero" << std::endl;
172  psi = zero;
173  }
174 
175  END_CODE();
176  }
177 
178 
179  // No internal state so reset is a Nop
180  void reset(void) {
181  last_solution_available = false;
182  }
183 
184  // Ignore new std::vector
185  void newVector(const multi1d<LatticeFermion>& psi)
186  {
187  START_CODE();
188 
189  QDPIO::cout << "LastSolutionPredictor: registering new solution" << std::endl;
190 
191  if ( psi.size() != N5 ) {
192  QDPIO::cerr << "Vector of incompatible size presented to Chronological Predictor. Vector.size() = " << psi.size() << " predictor.size()=" << N5 << std::endl;
193  QDP_abort(1);
194  }
195 
196  last_solution = psi;
198 
199  END_CODE();
200  }
201 
202  private:
203  const int N5;
204  multi1d<LatticeFermion> last_solution;
206 
207  };
208 
209 } // End Namespace Chroma
210 
211 #endif
Primary include file for CHROMA library code.
Chronological predictor for HMC.
Monomial factories.
Abstract interface for a Chronological Solution predictor in 5D.
Abstract interface for a Chronological Solution predictor.
void predictX(LatticeFermion &X, const LinearOperator< LatticeFermion > &A, const LatticeFermion &chi)
void newXVector(const LatticeFermion &X)
LastSolution4DChronoPredictor(const LastSolution4DChronoPredictor &p)
void newYVector(const LatticeFermion &Y)
void predictY(LatticeFermion &Y, const LinearOperator< LatticeFermion > &A, const LatticeFermion &chi)
LastSolution5DChronoPredictor(const LastSolution5DChronoPredictor &p)
void newVector(const multi1d< LatticeFermion > &psi)
void operator()(multi1d< LatticeFermion > &psi, const LinearOperatorArray< LatticeFermion > &A, const multi1d< LatticeFermion > &chi)
Linear Operator to arrays.
Definition: linearop.h:61
bool registerAll()
Register all the factories.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
A(A, psi, r, Ncb, PLUS)
Double zero
Definition: invbicg.cc:106
::std::string string
Definition: gtest.h:1979