CHROMA
invcg2_array.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Conjugate-Gradient algorithm for a generic Linear Operator
4  */
5 
6 #ifndef __invcg2_array__
7 #define __invcg2_array__
8 
9 #include "linearop.h"
10 #include "syssolver.h"
11 
12 namespace Chroma
13 {
14 
15  //! Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator
16  /*! \ingroup invert
17  * This subroutine uses the Conjugate Gradient (CG) algorithm to find
18  * the solution of the set of linear equations
19  *
20  * Chi = A . Psi
21  *
22  * where A = M^dag . M
23  *
24  * Algorithm:
25 
26  * Psi[0] := initial guess; Linear interpolation (argument)
27  * r[0] := Chi - M^dag . M . Psi[0] ; Initial residual
28  * p[1] := r[0] ; Initial direction
29  * IF |r[0]| <= RsdCG |Chi| THEN RETURN; Converged?
30  * FOR k FROM 1 TO MaxCG DO CG iterations
31  * a[k] := |r[k-1]|**2 / <Mp[k],Mp[k]> ;
32  * Psi[k] += a[k] p[k] ; New solution std::vector
33  * r[k] -= a[k] M^dag . M . p[k] ; New residual
34  * IF |r[k]| <= RsdCG |Chi| THEN RETURN; Converged?
35  * b[k+1] := |r[k]|**2 / |r[k-1]|**2 ;
36  * p[k+1] := r[k] + b[k+1] p[k]; New direction
37  *
38  * Arguments:
39  *
40  * \param M Linear Operator (Read)
41  * \param chi Source (Read)
42  * \param psi Solution (Modify)
43  * \param RsdCG CG residual accuracy (Read)
44  * \param MaxCG Maximum CG iterations (Read)
45  * \param n_count Number of CG iteration (Write)
46  *
47  * Local Variables:
48  *
49  * p Direction std::vector
50  * r Residual std::vector
51  * cp | r[k] |**2
52  * c | r[k-1] |**2
53  * k CG iteration counter
54  * a a[k]
55  * b b[k+1]
56  * d < p[k], A.p[k] >
57  * Mp Temporary for M.p
58  *
59  * Subroutines:
60  * +
61  * A Apply matrix M or M to std::vector
62  *
63  * Operations:
64  *
65  * 2 A + 2 Nc Ns + N_Count ( 2 A + 10 Nc Ns )
66  *
67  * @{
68  */
69  // Single precision
70  SystemSolverResults_t
71  InvCG2(const LinearOperatorArray<LatticeFermionF>& M,
72  const multi1d<LatticeFermionF>& chi,
73  multi1d<LatticeFermionF>& psi,
74  const Real& RsdCG,
75  int MaxCG);
76 
77  // Double precision
78  SystemSolverResults_t
79  InvCG2(const LinearOperatorArray<LatticeFermionD>& M,
80  const multi1d<LatticeFermionD>& chi,
81  multi1d<LatticeFermionD>& psi,
82  const Real& RsdCG,
83  int MaxCG);
84 
85  /*! @} */ // end of group invert
86 
87 } // end namespace Chroma
88 
89 #endif
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
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
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
Linear system solvers.