CHROMA
multi_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 multi-shift CG
4  */
5 
6 #ifndef __multi_syssolver_mdagm_cg_array_h__
7 #define __multi_syssolver_mdagm_cg_array_h__
8 
9 #include "handle.h"
10 #include "syssolver.h"
11 #include "linearop.h"
15 
16 
17 namespace Chroma
18 {
19 
20  //! CG system solver namespace
21  namespace MdagMMultiSysSolverCGArrayEnv
22  {
23  //! Register the syssolver
24  bool registerAll();
25  }
26 
27 
28  //! Solve a CG 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 MultiSysSolverCGParams& 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< multi1d<T> >& psi,
61  const multi1d<Real>& shifts,
62  const multi1d<T>& chi) const
63  {
64  START_CODE();
65 
66  multi1d<Real> RsdCG(shifts.size());
67  if (invParam.RsdCG.size() == 1)
68  {
69  RsdCG = invParam.RsdCG[0];
70  }
71  else if (invParam.RsdCG.size() == RsdCG.size())
72  {
74  }
75  else
76  {
77  QDPIO::cerr << "MdagMMultiSysSolverCG: shifts incompatible" << std::endl;
78  QDP_abort(1);
79  }
80 
82  MInvCG(*A, chi, psi, shifts, RsdCG, invParam.MaxCG, res.n_count);
83 
84  END_CODE();
85 
86  return res;
87  }
88 
89 
90  private:
91  // Hide default constructor
93 
96  };
97 
98 } // End namespace
99 
100 #endif
101 
Class for counted reference semantics.
Definition: handle.h:33
Linear Operator to arrays.
Definition: linearop.h:61
Solve a CG system. Here, the operator is NOT assumed to be hermitian.
Handle< LinearOperatorArray< T > > A
const Subset & subset() const
Return the subset on which the operator acts.
SystemSolverResults_t operator()(multi1d< multi1d< T > > &psi, const multi1d< Real > &shifts, const multi1d< T > &chi) const
Solver the linear system.
MdagMMultiSysSolverCGArray(Handle< LinearOperatorArray< T > > A_, const MultiSysSolverCGParams &invParam_)
Constructor.
int size() const
Expected length of array index.
void MInvCG(const LinearOperator< LatticeFermion > &M, const LatticeFermion &chi, multi1d< LatticeFermion > &psi, const multi1d< Real > &shifts, const multi1d< Real > &RsdCG, int MaxCG, int &n_count)
Definition: minvcg.cc:407
Class for counted reference semantics.
Linear Operators.
Multishift Conjugate-Gradient algorithm for a Linear Operator.
Params of CG inverter.
Disambiguator for multi-shift MdagM system solvers.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
Definition: pbg5p_w.cc:30
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.