CHROMA
minvmr.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Multishift Conjugate-Gradient algorithm for a Linear Operator
4  */
5 
6 #ifndef __minvmr_h__
7 #define __minvmr_h__
8 
9 #include "linearop.h"
10 
11 namespace Chroma
12 {
13 
14 
15  //! Multishift Conjugate-Gradient (CG1) algorithm for a Linear Operator
16  /*! \ingroup invert
17  *
18  * This subroutine uses the Conjugate Gradient (CG) algorithm to find
19  * the solution of the set of linear equations
20  * Method used is described in Jegerlehner, hep-lat/9708029
21 
22  * We are searching in a subspace orthogonal to the eigenvectors EigVec
23  * of A. The source chi is assumed to already be orthogonal!
24 
25  * Chi = A . Psi
26 
27  * Algorithm:
28 
29  * Psi[0] := 0; Zeroed
30  * r[0] := Chi; Initial residual
31  * p[1] := Chi ; Initial direction
32  * b[0] := |r[0]|**2 / <p[0],Ap[0]> ;
33  * z[0] := 1 / (1 - (shift - shift(0))*b)
34  * bs[0] := b[0] * z[0]
35  * r[1] += b[k] A . p[0] ; New residual
36  * Psi[1] = - b[k] p[k] ; Starting solution std::vector
37  * IF |r[0]| <= RsdCG |Chi| THEN RETURN; Converged?
38  * FOR k FROM 1 TO MaxCG DO CG iterations
39  * a[k] := |r[k]|**2 / |r[k-1]|**2 ;
40  * p[k] := r[k] + a[k] p[k-1]; New direction
41  * b[k+1] := |r[k]|**2 / <p[k],Ap[k]> ;
42  * r[k+1] += b[k+1] A . p[k] ; New residual
43  * Psi[k+1] -= b[k+1] p[k] ; New solution std::vector
44  * IF |[k+1]| <= RsdCG |Chi| THEN RETURN; Converged?
45 
46  * Arguments:
47 
48  * A Hermitian linear operator (Read)
49  * Chi Source (Read)
50  * Psi array of solutions (Write)
51  * shifts shifts of form A + mass (Read)
52  * RsdCG residual accuracy (Read/Write)
53  * n_count Number of CG iteration (Write)
54 
55  * Local Variables:
56 
57  * p Direction std::vector
58  * r Residual std::vector
59  * cp | r[k] |**2
60  * c | r[k-1] |**2
61  * k CG iteration counter
62  * a a[k]
63  * b b[k+1]
64  * d < p[k], A.p[k] >
65  * Ap Temporary for M.p
66 
67  * MaxCG Maximum number of CG iterations allowed
68 
69  * Subroutines:
70  * A Apply matrix hermitian A to std::vector
71  *
72  * @{
73  */
74  template<typename T>
75  void MInvMR(const LinearOperator<T>& A,
76  const T& chi,
77  multi1d<T>& psi,
78  const multi1d<Real>& shifts,
79  const multi1d<Real>& RsdCG,
80  int MaxCG,
81  int &n_count);
82 
83  template<typename T, typename P, typename Q>
84  void MInvMR(const DiffLinearOperator<T,P,Q>& A,
85  const T& chi,
86  multi1d<T>& psi,
87  const multi1d<Real>& shifts,
88  const multi1d<Real>& RsdCG,
89  int MaxCG,
90  int &n_count);
91 
92  /*! @} */ // end of group invert
93 
94 } // end namespace Chroma
95 
96 
97 #endif
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
Linear Operators.
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
int n_count
Definition: invbicg.cc:78
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > int MaxCG
Definition: pbg5p_w.cc:32
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
A(A, psi, r, Ncb, PLUS)
LatticeFermion T
Definition: t_clover.cc:11