CHROMA
syssolver_mdagm_cg_array.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_array_h__
7 #define __syssolver_mdagm_cg_array_h__
8 #include "chroma_config.h"
9 #include "handle.h"
10 #include "syssolver.h"
11 #include "linearop.h"
15 
16 
17 namespace Chroma
18 {
19 
20  //! CG2 system solver namespace
21  namespace MdagMSysSolverCGArrayEnv
22  {
23  //! Register the syssolver
24  bool registerAll();
25  }
26 
27 
28  //! Solve a CG2 system. Here, the operator is NOT assumed to be hermitian
29  /*! \ingroup invert
30  */
31  template<typename T>
33  {
34  public:
35  //! Constructor
36  /*!
37  * \param M_ Linear operator ( Read )
38  * \param invParam inverter parameters ( Read )
39  */
41  const SysSolverCGParams& invParam_) :
42  A(A_), invParam(invParam_)
43  {}
44 
45  //! Destructor is automatic
47 
48  //! Expected length of array index
49  int size() const {return A->size();}
50 
51  //! Return the subset on which the operator acts
52  const Subset& subset() const {return A->subset();}
53 
54  //! Solver the linear system
55  /*!
56  * \param psi solution ( Modify )
57  * \param chi source ( Read )
58  * \return syssolver results
59  */
60  SystemSolverResults_t operator() (multi1d<T>& psi, const multi1d<T>& chi) const
61  {
62  START_CODE();
63 
64  SystemSolverResults_t res; // initialized by a constructor
65  {
66  res = InvCG2(*A, chi, psi, invParam.RsdCG, invParam.MaxCG);
67 
68 #ifdef CHROMA_DO_ONE_CG_RESTART
69  int n_count = res.n_count;
71  res.n_count += n_count;
72 #endif
73 
74  }
75 
76  END_CODE();
77 
78  return res;
79  }
80 
81 
82  private:
83  // Hide default constructor
85 
88  };
89 
90 } // End namespace
91 
92 #endif
93 
Class for counted reference semantics.
Definition: handle.h:33
Linear Operator to arrays.
Definition: linearop.h:61
Solve a CG2 system. Here, the operator is NOT assumed to be hermitian.
SystemSolverResults_t operator()(multi1d< T > &psi, const multi1d< T > &chi) const
Solver the linear system.
int size() const
Expected length of array index.
MdagMSysSolverCGArray(Handle< LinearOperatorArray< T > > A_, const SysSolverCGParams &invParam_)
Constructor.
~MdagMSysSolverCGArray()
Destructor is automatic.
const Subset & subset() const
Return the subset on which the operator acts.
Handle< LinearOperatorArray< T > > A
SystemSolver disambiguator.
SystemSolverResults_t InvCG2(const LinearOperator< LatticeFermionF > &M, const LatticeFermionF &chi, LatticeFermionF &psi, const Real &RsdCG, int MaxCG)
Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator.
Definition: invcg2.cc:240
Class for counted reference semantics.
Conjugate-Gradient algorithm for a generic Linear Operator.
Linear Operators.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int n_count
Definition: invbicg.cc:78
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.