CHROMA
syssolver_mdagm_eigcg_qdp.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Solve a M^dag*M*psi=chi linear system by EigCG
4  */
5 
6 #ifndef __syssolver_mdagm_eigcg_qdp_h__
7 #define __syssolver_mdagm_eigcg_qdp_h__
8 
9 #include "handle.h"
10 #include "syssolver.h"
11 #include "linearop.h"
12 #include "lmdagm.h"
13 #include "named_obj.h"
15 
19 
20 namespace Chroma
21 {
22 
23  //! Eigenstd::vector accelerated CG system solver namespace
24  namespace MdagMSysSolverQDPEigCGEnv
25  {
26  //! Register the syssolver
27  bool registerAll();
28  }
29 
30 
31  //! Solve a M*psi=chi linear system by CG2 with eigenvectors
32  /*! \ingroup invert
33  */
34  template<typename T>
36  {
37  public:
38  //! Constructor
39  /*!
40  * \param M_ Linear operator ( Read )
41  * \param invParam_ inverter parameters ( Read )
42  */
44  const SysSolverEigCGParams& invParam_) :
45  MdagM(new MdagMLinOp<T>(A_)), A(A_), invParam(invParam_)
46  {
47  // NEED to grab the eignvectors from the named buffer here
49  {
51  LinAlg::RitzPairs<T>& GoodEvecs =
53 
54  if(invParam.Neig_max>0 ){
55  GoodEvecs.init(invParam.Neig_max);
56  }
57  else{
58  GoodEvecs.init(invParam.Neig);
59  }
60  }
61  }
62 
63  //! Destructor is automatic
65  {
67  {
69  }
70  }
71 
72  //! Return the subset on which the operator acts
73  const Subset& subset() const {return A->subset();}
74 
75  //! Solver the linear system
76  /*!
77  * \param psi solution ( Modify )
78  * \param chi source ( Read )
79  * \return syssolver results
80  *
81  * Definitions supplied in the correspond .cc file
82  */
84 
85 
86  //! Solve the linear system starting with a chrono guess
87  /*!
88  * \param psi solution (Write)
89  * \param chi source (Read)
90  * \param predictor a chronological predictor (Read)
91  * \return syssolver results
92  */
93 
95  AbsChronologicalPredictor4D<T>& predictor) const
96  {
97 
98  START_CODE();
99 
100  // This solver uses InvCG2, so A is just the matrix.
101  // I need to predict with A^\dagger A
102  {
104  predictor(psi, (*MdagM), chi);
105  }
106  // Do solve
107  SystemSolverResults_t res=(*this)(psi,chi);
108 
109  // Store result
110  predictor.newVector(psi);
111  END_CODE();
112  return res;
113  }
114 
115  private:
116  // Hide default constructor
118 
122  };
123 
124 } // End namespace
125 
126 #endif
127 
Abstract interface for a Chronological Solution predictor.
virtual void newVector(const T &psi)=0
Class for counted reference semantics.
Definition: handle.h:33
Holds eigenvalues and eigenvectors.
Definition: containers.h:282
Linear Operator.
Definition: linearop.h:27
M^dag.M linear operator.
Definition: lmdagm.h:22
Solve a M*psi=chi linear system by CG2 with eigenvectors.
Handle< LinearOperator< T > > MdagM
SystemSolverResults_t operator()(T &psi, const T &chi, AbsChronologicalPredictor4D< T > &predictor) const
Solve the linear system starting with a chrono guess.
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
Handle< LinearOperator< T > > A
const Subset & subset() const
Return the subset on which the operator acts.
~MdagMSysSolverQDPEigCG()
Destructor is automatic.
MdagMSysSolverQDPEigCG(Handle< LinearOperator< T > > A_, const SysSolverEigCGParams &invParam_)
Constructor.
SystemSolver disambiguator.
static T & Instance()
Definition: singleton.h:432
Class for counted reference semantics.
Linear Operators.
M^dag*M composition of a linear operator.
Named object support.
Named object function std::map.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Params for EigCG inverter.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.
Solve a CG1 system.
Disambiguator for MdagM system solvers.