CHROMA
multi_syssolver_linop_mr.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Solve a (M+shift)*psi=chi linear system by MR
4  */
5 
6 #ifndef __multi_syssolver_linop_mr_h__
7 #define __multi_syssolver_linop_mr_h__
8 
9 #include "handle.h"
10 #include "syssolver.h"
11 #include "linearop.h"
15 
16 
17 namespace Chroma
18 {
19 
20  //! MR system solver namespace
21  namespace LinOpMultiSysSolverMREnv
22  {
23  //! Register the syssolver
24  bool registerAll();
25  }
26 
27 
28  //! Solve a MR 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 A_ Linear operator ( Read )
38  * \param invParam inverter parameters ( Read )
39  */
41  const MultiSysSolverMRParams& invParam_) :
42  A(A_), invParam(invParam_)
43  {}
44 
45  //! Destructor is automatic
47 
48  //! Return the subset on which the operator acts
49  const Subset& subset() const {return A->subset();}
50 
51  //! Solver the linear system
52  /*!
53  * \param psi solution ( Modify )
54  * \param chi source ( Read )
55  * \return syssolver results
56  */
57  SystemSolverResults_t operator() (multi1d<T>& psi, const multi1d<Real>& shifts, const T& chi) const
58  {
59  START_CODE();
60 
61  multi1d<Real> RsdCG(shifts.size());
62  if (invParam.RsdCG.size() == 1)
63  {
64  RsdCG = invParam.RsdCG[0];
65  }
66  else if (invParam.RsdCG.size() == RsdCG.size())
67  {
69  }
70  else
71  {
72  QDPIO::cerr << "LinOpMultiSysSolverMR: shifts incompatible" << std::endl;
73  QDP_abort(1);
74  }
75 
77  MInvMR(*A, chi, psi, shifts, RsdCG, invParam.MaxCG, res.n_count);
78 
79  END_CODE();
80 
81  return res;
82  }
83 
84 
85  private:
86  // Hide default constructor
88 
91  };
92 
93 
94 } // End namespace
95 
96 #endif
97 
Class for counted reference semantics.
Definition: handle.h:33
Solve a MR system. Here, the operator is NOT assumed to be hermitian.
const Subset & subset() const
Return the subset on which the operator acts.
LinOpMultiSysSolverMR(Handle< LinearOperator< T > > A_, const MultiSysSolverMRParams &invParam_)
Constructor.
Handle< LinearOperator< T > > A
~LinOpMultiSysSolverMR()
Destructor is automatic.
SystemSolverResults_t operator()(multi1d< T > &psi, const multi1d< Real > &shifts, const T &chi) const
Solver the linear system.
Linear Operator.
Definition: linearop.h:27
void MInvMR(const LinearOperator< LatticeFermion > &M, const LatticeFermion &chi, multi1d< LatticeFermion > &psi, const multi1d< Real > &shifts, const multi1d< Real > &RsdMR, int MaxMR, int &n_count)
Multishift Conjugate-Gradient (CG1) algorithm for a Linear Operator.
Definition: minvmr.cc:258
Class for counted reference semantics.
Linear Operators.
Multishift Conjugate-Gradient algorithm for a Linear Operator.
Disambiguator for multi-shift linop system solvers.
Params of MR inverter.
bool registerAll()
Register all the factories.
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
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
SystemSolver disambiguator.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.