CHROMA
unprec_ppdwf4d_linop_w.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Unpreconditioned projected DWF operator to 4D using prec 5D bits
3  */
4 
5 #include "chromabase.h"
9 
10 
11 namespace Chroma
12 {
13 
14  // Apply unpreconditioned linear operator
15  template<>
16  void
17  UnprecPPDWF4DLinOp<LatticeFermion,
18  multi1d<LatticeColorMatrix>,
19  multi1d<LatticeColorMatrix> >::operator()(LatticeFermion& chi,
20  const LatticeFermion& psi,
21  enum PlusMinus isign) const
22  {
23  START_CODE();
24 
25  const int N5 = size(); // array size better match
27 
28  // Initialize the 5D fields
29  multi1d<LatticeFermion> psi5(N5);
30  // psi5 = (psi,0,0,0,..,0)^T
31  psi5 = zero;
32  psi5[0] = psi;
33 
34  // tmp5 = P . psi5
35  multi1d<LatticeFermion> tmp5(N5);
36  DwfFld(tmp5, psi5, PLUS);
37 
38  multi1d<LatticeFermion> chi5(N5);
39 
40  switch(isign)
41  {
42  case PLUS:
43  {
44  // chi5 = D5(m_q) . tmp5 = D5(m_q) . P . (chi,0,0,..,0)^T
45  D->unprecLinOp(chi5, tmp5, PLUS);
46 
47  // Solve D5(1) . psi5 = chi5
48  psi5 = chi5;
49 
50  /* Step (i) */
51  /* chi_tmp_o = chi_o - D_oe * A_ee^-1 * chi_e */
52  multi1d<LatticeFermion> chi_tmp(N5);
53  {
54  multi1d<LatticeFermion> tmp1(N5);
55  multi1d<LatticeFermion> tmp2(N5);
56 
57  PV->evenEvenInvLinOp(tmp1, chi5, PLUS);
58  PV->oddEvenLinOp(tmp2, tmp1, PLUS);
59  for(int n=0; n < N5; ++n)
60  chi_tmp[n][rb[1]] = chi5[n] - tmp2[n];
61  }
62 
63 // case CG_INVERTER:
64  {
65  /* tmp5 = M_dag(u) * chi_tmp */
66  (*PV)(tmp5, chi_tmp, MINUS);
67 
68  /* psi5 = (M^dag * M)^(-1) chi_tmp */
69  res = InvCG2 (*PV, tmp5, psi5, invParam.RsdCG, invParam.MaxCG);
70  }
71 
72  /* Step (ii) */
73  /* psi_e = A_ee^-1 * [chi_e - D_eo * psi_o] */
74  {
75  multi1d<LatticeFermion> tmp1(N5);
76  multi1d<LatticeFermion> tmp2(N5);
77 
78  PV->evenOddLinOp(tmp1, psi5, PLUS);
79  for(int n=0; n < N5; ++n)
80  tmp2[n][rb[0]] = chi5[n] - tmp1[n];
81  PV->evenEvenInvLinOp(psi5, tmp2, PLUS);
82  }
83  }
84  break;
85 
86  case MINUS:
87  {
88  // Solve D5(1) . tmp5 = chi5
89  chi5 = tmp5;
90 
91  /* Step (i) */
92  /* chi_tmp_o = chi5_o - D_oe^dag * (A_ee^-1)^dag * chi5_e */
93  multi1d<LatticeFermion> chi_tmp(N5);
94  {
95  multi1d<LatticeFermion> tmp1(N5);
96  multi1d<LatticeFermion> tmp2(N5);
97 
98  PV->evenEvenInvLinOp(tmp1, chi5, MINUS);
99  PV->oddEvenLinOp(tmp2, tmp1, MINUS);
100  for(int n=0; n < N5; ++n)
101  chi_tmp[n][rb[1]] = chi5[n] - tmp2[n];
102  }
103 
104 // case CG_INVERTER:
105  {
106  multi1d<LatticeFermion> tmp1(N5);
107  for(int n=0; n < N5; ++n)
108  tmp1[n][rb[1]] = zero;
109 
110  /* tmp1 = (M^dag * M)^(-1) chi_tmp */
111  res = InvCG2(*PV, chi_tmp, tmp1, invParam.RsdCG, invParam.MaxCG);
112 
113  /* tmp5_o = M(u) * tmp1_o = (M^dag)^(-1) * chi_tmp_o */
114  (*PV)(tmp5, tmp1, PLUS);
115  }
116 
117  /* Step (ii) */
118  /* tmp5_e = (A_ee^-1)^dag * [chi5_e - D_eo^dag * tmp5_o] */
119  {
120  multi1d<LatticeFermion> tmp1(N5);
121  multi1d<LatticeFermion> tmp2(N5);
122 
123  PV->evenOddLinOp(tmp1, tmp5, MINUS);
124  for(int n=0; n < N5; ++n)
125  tmp2[n][rb[0]] = chi5[n] - tmp1[n];
126  PV->evenEvenInvLinOp(tmp5, tmp2, MINUS);
127  }
128 
129  // psi5 = D5(m_q)^dag . tmp5
130  D->unprecLinOp(psi5, tmp5, MINUS);
131  }
132  break;
133  }
134 
135  if ( res.n_count == invParam.MaxCG )
136  QDP_error_exit("no convergence in the inverter", res.n_count);
137 
138  // Project out first slice after chi <- chi5 <- P^(-1) . psi5
139  DwfFld(chi5, psi5, MINUS);
140  chi = chi5[0];
141 
142  END_CODE();
143  }
144 
145 }
Primary include file for CHROMA library code.
DWF parity/rotation operator.
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
void DwfFld(multi1d< LatticeFermion > &chi, const multi1d< LatticeFermion > &psi, enum PlusMinus isign)
DWF parity/rotation operator.
Definition: dwffld_w.cc:24
Conjugate-Gradient algorithm for a generic Linear Operator.
unsigned n
Definition: ldumul_w.cc:36
Double tmp2
Definition: mesq.cc:30
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
QDP_error_exit("too many BiCG iterations", n_count, rsd_sq, cp, c, re_rvr, im_rvr, re_a, im_a, re_b, im_b)
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Double zero
Definition: invbicg.cc:106
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Unpreconditioned projected DWF operator to 4D using prec 5D bits.