CHROMA
inv_borici_w.cc
Go to the documentation of this file.
1 #include "chromabase.h"
4 
5 namespace Chroma {
6 
7 
8 template<typename T>
9 void InvBorici_a( const LinearOperator<T>& D_4,
10  const LinearOperatorArray<T>& D_5,
11  const LinearOperatorArray<T>& D_dag_D_5,
12  const T& b,
13  T& x,
14  const Real& tol,
15  const Real& tol_1,
16  const int MaxIter,
17  const int MaxIter5D,
18  const Real& m,
19  int& n_iters)
20 {
21  START_CODE();
22 
23  // Initial setup
24  // x_0 = 0, r_0 = b, tol_0 = 1
25  x = zero;
26  T r = b;
27 
28  // Other useful things
29  Double b_norm = sqrt(norm2(b));
30  Double r_norm;
31 
32  // Convergence flag
33  bool convP = false;
34 
35 
36  // The 5D Auxiliaries
37  int N5 = D_5.size();
38  multi1d<T> chi(N5);
39  multi1d<T> eta(N5);
40  //multi1d<T> tmp(N5);
41  int n_iters5d;
42 
43  int G5 = Ns*Ns-1;
44  T y;
45 
46  Real tol_0 = 1;
47 
48  for(int k = 1; k <= MaxIter && !convP; k++) {
49 
50 
51  tol_0 *= tol_1;
52 
53  // Now solve the 5D system to tol_1
54  for(int n=0; n < N5-1; n++) {
55  eta[n] = zero;
56  // tmp[n] = zero;
57  }
58  // RHS is r
59  eta[N5-1] = Gamma(G5)*r;
60  // tmp[N5-1] = zero;
61 
62 
63 
64  // Solve D_5 chi = eta
65  // or D_5 y = r
66  //
67  // Solve with CGNE D^{dag} D tmp = r
68  // then chi = D^{dag} tmp = D^{dag} (D^{dag}D)^{-1} r
69  // = D^{-1} r
70 
71  InvMINRES(D_5, eta, chi, tol_0, MaxIter5D, n_iters5d);
72  // D_5(chi,tmp,MINUS);
73 
74  y = Real(2)/(Real(1)-m)*chi[N5-1];
75 
76  // Keep y as next initial guess
77  // x_i = x_{i-1} + y
78  x += y;
79 
80  // r_i = b - D_ov x_i
81  T tmp4;
82  D_4(tmp4, x, PLUS);
83 
84  r =b - tmp4;
85 
86  // Monitoring
87  r_norm = sqrt(norm2(r));
88  QDPIO::cout << "InvBorici: iter " << k
89  << " || r || = " << r_norm
90  << " || b || = " << b_norm
91  << " || r ||/|| b || = " << r_norm / b_norm
92  << " target = " << tol << std::endl;
93 
94  if( toBool( r_norm < tol*b_norm ) ) {
95  convP = true;
96  }
97  n_iters = k;
98 
99  }
100 
101  if( !convP ) {
102  QDPIO::cerr << "Nonconvergence warning: " << n_iters << " iters. || r || / || b || = " << r_norm / b_norm;
103  }
104 
105  END_CODE();
106 }
107 
108 template<>
111  const LinearOperatorArray<LatticeFermion>& D_dag_D_5,
112  const LatticeFermion& b,
113  LatticeFermion& x,
114  const Real& tol,
115  const Real& tol_1,
116  const int MaxIter,
117  const int MaxIter5D,
118  const Real& m,
119  int& n_iters)
120 {
121  InvBorici_a(D_4, D_5, D_dag_D_5, b, x, tol, tol_1, MaxIter, MaxIter5D, m, n_iters);
122 }
123 
124 } // end namespace Chroma
Primary include file for CHROMA library code.
Linear Operator to arrays.
Definition: linearop.h:61
virtual int size() const =0
Expected length of array index.
Linear Operator.
Definition: linearop.h:27
unsigned n
Definition: ldumul_w.cc:36
static int m[4]
Definition: make_seeds.cc:16
int y
Definition: meslate.cc:35
int x
Definition: meslate.cc:34
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int G5
Definition: pbg5p_w.cc:57
void InvMINRES(const LinearOperatorArray< LatticeFermion > &A, const multi1d< LatticeFermion > &chi, multi1d< LatticeFermion > &psi, const Real &RsdCG, int MaxCG, int &n_count)
LinOpSysSolverMGProtoClover::T T
@ PLUS
Definition: chromabase.h:45
void InvBorici_a(const LinearOperator< T > &D_4, const LinearOperatorArray< T > &D_5, const LinearOperatorArray< T > &D_dag_D_5, const T &b, T &x, const Real &tol, const Real &tol_1, const int MaxIter, const int MaxIter5D, const Real &m, int &n_iters)
Definition: inv_borici_w.cc:9
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion eta
Definition: mespbg5p_w.cc:37
void InvBorici(const LinearOperator< LatticeFermion > &D_4, const LinearOperatorArray< LatticeFermion > &D_5, const LinearOperatorArray< LatticeFermion > &D_dag_D_5, const LatticeFermion &b, LatticeFermion &x, const Real &tol, const Real &tol_1, const int MaxIter, const int MaxIter5D, const Real &m, int &n_iters)
START_CODE()
Complex b
Definition: invbicg.cc:96
Double zero
Definition: invbicg.cc:106
int k
Definition: invbicg.cc:119
FloatingPoint< double > Double
Definition: gtest.h:7351
Double r_norm
Definition: pade_trln_w.cc:86