CHROMA
lib
actions
ferm
invert
inv_rel_cg2.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 __inv_rel_cg2__
7
#define __inv_rel_cg2__
8
9
#include "
linearop.h
"
10
11
namespace
Chroma
{
12
13
//! Relaxed Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator
14
/*! \ingroup invert
15
* This subroutine uses the Conjugate Gradient (CG) algorithm to find
16
* the solution of the set of linear equations
17
*
18
* Chi = M^{dag}M . Psi
19
*
20
*
21
* Algorithm:
22
*
23
* Psi[0] := initial guess; Linear interpolation (argument)
24
* r[0] := Chi - M^dag . M . Psi[0] ; Initial residual
25
* p[1] := r[0] ; Initial direction
26
* c = cp := || r[0] ||^2
27
* zeta := 1/c;
28
*
29
* IF |r[0]| <= RsdCG |Chi| THEN RETURN; Converged?
30
*
31
* FOR k FROM 1 TO MaxCG DO CG iterations
32
*
33
* inner_tol := RsdCG*||chi||*||p||*sqrt(zeta)/2;
34
* q := M^{dag}(tol) M(tol) p;
35
* a[k] := c / <q , p>
36
* Psi[k] += a[k] p[k] ; New solution std::vector
37
* r[k] -= a[k] q; New residual
38
* c := || r[k]^2 ||
39
* zeta = zeta + 1/c;
40
* b[k+1] := |r[k]|**2 / |r[k-1]|**2 = c/cp;
41
* p[k+1] := r[k] + b[k+1] p[k]; New direction
42
* cp := c;
43
* IF |r[k]| <= RsdCG |Chi| THEN RETURN; Converged?
44
*
45
* Arguments:
46
*
47
* \param M ApproxLinear Operator (Read)
48
* \param chi Source (Read)
49
* \param psi Solution (Modify)
50
* \param RsdCG CG residual accuracy (Read)
51
* \param MaxCG Maximum CG iterations (Read)
52
* \param n_count Number of CG iteration (Write)
53
*
54
* Local Variables:
55
*
56
* p Direction std::vector
57
* r Residual std::vector
58
* cp | r[k] |**2
59
* c | r[k-1] |**2
60
* k CG iteration counter
61
* a a[k]
62
* b b[k+1]
63
* d < p[k], A.p[k] >
64
* Mp Temporary for M.p
65
*
66
* Subroutines:
67
* +
68
* A Apply matrix M or M to std::vector
69
*
70
* Operations:
71
*
72
* 2 A + 2 Nc Ns + N_Count ( 2 A + 10 Nc Ns )
73
*/
74
75
template
<
typename
T>
76
void
InvRelCG2
(
const
LinearOperator<T>& M,
77
const
T
&
chi
,
78
T
&
psi
,
79
const
Real&
RsdCG
,
80
int
MaxCG
,
81
int
&
n_count
);
82
83
}
// end namespace Chroma
84
85
#endif
Chroma::InvRelCG2
void InvRelCG2(const LinearOperator< LatticeFermion > &M, const LatticeFermion &chi, LatticeFermion &psi, const Real &RsdCG, int MaxCG, int &n_count)
Relaxed Conjugate-Gradient (CGNE) algorithm for a generic Linear Operator.
Definition:
inv_rel_cg2.cc:175
linearop.h
Linear Operators.
Chroma
Asqtad Staggered-Dirac operator.
Definition:
klein_gord.cc:10
Chroma::RsdCG
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > & RsdCG
Definition:
pbg5p_w.cc:30
Chroma::n_count
int n_count
Definition:
invbicg.cc:78
Chroma::MaxCG
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > const multi1d< Real > enum InvType invType const multi1d< Real > int MaxCG
Definition:
pbg5p_w.cc:32
Chroma::chi
multi1d< LatticeFermion > chi(Ncb)
Chroma::psi
LatticeFermion psi
Definition:
mespbg5p_w.cc:35
T
LatticeFermion T
Definition:
t_clover.cc:11
Generated by
1.9.1