CHROMA
syssolver_mdagm_cg_timing.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Solve a MdagM*psi=chi linear system by CG2
4  */
5 
6 #ifndef __syssolver_mdagm_cg_timing_h__
7 #define __syssolver_mdagm_cg_timing_h__
8 #include "chroma_config.h"
9 #include "handle.h"
10 #include "syssolver.h"
11 #include "linearop.h"
12 #include "lmdagm.h"
16 
17 
18 namespace Chroma
19 {
20 
21  //! CG2 system solver namespace
22  namespace MdagMSysSolverCGTimingsEnv
23  {
24  //! Register the syssolver
25  bool registerAll();
26  }
27 
28 
29  //! Solve a CG2 system. Here, the operator is NOT assumed to be hermitian
30  /*! \ingroup invert
31  */
32  template<typename T>
34  {
35  public:
36  //! Constructor
37  /*!
38  * \param M_ Linear operator ( Read )
39  * \param invParam inverter parameters ( Read )
40  */
42  const SysSolverCGParams& invParam_) :
43  A(A_), invParam(invParam_)
44  {}
45 
46  //! Destructor is automatic
48 
49  //! Return the subset on which the operator acts
50  const Subset& subset() const {return A->subset();}
51 
52  //! Solver the linear system
53  /*!
54  * \param psi solution ( Modify )
55  * \param chi source ( Read )
56  * \return syssolver results
57  */
59  {
60  START_CODE();
61 
62  SystemSolverResults_t res; // initialized by a constructor
63  {
64  res = InvCG2_timings(*A, chi, psi, invParam.MaxCG);
65 
66 #ifdef CHROMA_DO_ONE_CG_RESTART
67  int n_count = res.n_count;
69  res.n_count += n_count;
70 #endif
71  }
72 
73  END_CODE();
74 
75  return res;
76  }
77 
78 
79  //! Solve the linear system starting with a chrono guess
80  /*!
81  * \param psi solution (Write)
82  * \param chi source (Read)
83  * \param predictor a chronological predictor (Read)
84  * \return syssolver results
85  */
86 
88  AbsChronologicalPredictor4D<T>& predictor) const
89  {
90 
91  START_CODE();
92 
93  // This solver uses InvCG2, so A is just the matrix.
94  // I need to predict with A^\dagger A
95  {
97  predictor(psi, (*MdagM), chi);
98  }
99  // Do solve
100  SystemSolverResults_t res=(*this)(psi,chi);
101 
102  // Store result
103  predictor.newVector(psi);
104  END_CODE();
105  return res;
106  }
107 
108 
109  private:
110  // Hide default constructor
112 
115  };
116 
117 
118 } // End namespace
119 
120 #endif
121 
Abstract interface for a Chronological Solution predictor.
virtual void newVector(const T &psi)=0
Class for counted reference semantics.
Definition: handle.h:33
Linear Operator.
Definition: linearop.h:27
M^dag.M linear operator.
Definition: lmdagm.h:22
Solve a CG2 system. Here, the operator is NOT assumed to be hermitian.
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
~MdagMSysSolverCGTimings()
Destructor is automatic.
const Subset & subset() const
Return the subset on which the operator acts.
SystemSolverResults_t operator()(T &psi, const T &chi, AbsChronologicalPredictor4D< T > &predictor) const
Solve the linear system starting with a chrono guess.
MdagMSysSolverCGTimings(Handle< LinearOperator< T > > A_, const SysSolverCGParams &invParam_)
Constructor.
SystemSolver disambiguator.
SystemSolverResults_t InvCG2_timings(const LinearOperator< LatticeFermion > &M, const LatticeFermion &chi, LatticeFermion &psi, int MaxCG)
Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator.
Class for counted reference semantics.
Conjugate-Gradient algorithm for a generic Linear Operator.
Linear Operators.
M^dag*M composition of a linear operator.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int n_count
Definition: invbicg.cc:78
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Params for CG inverter.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.
Solve a CG1 system.
Disambiguator for MdagM system solvers.
Handle< LinearOperator< T > > MdagM