CHROMA
invdd_deflated.cc
Go to the documentation of this file.
1 /*! \file
2  * \brief Conjugate-Gradient algorithm for a generic Linear Operator
3  */
4 
5 #include "chromabase.h"
7 
8 
9 namespace Chroma {
10 
11  namespace InvDDDeflatedEnv {
12 
13 
14  /*****************************************************
15  * A : The linear operator which is to be inverted
16  * chi : The source on which to invert
17  * psi : the result of the inversion
18  * vecs : The vectors which span the deflation subspace
19  * blk : The definition of the domain decompostion
20  * RsdCG : The maximim allowed residual
21  * MaxCG : The maximum number of iterations
22  * *******************************************************/
23 
26  const LatticeFermion& chi,
27  LatticeFermion& psi,
28  const mutli1d<LatticeFermion>& vecs,
29  const QDP::Set blk,
30  const Real& RsdCG,
31  int MaxCG) {
32 
33  START_CODE();
34 
35  //The struct which contains inversion information
37 
38  //First, form the projection of chi onto the deflation subspace
39  int nvecs_per_block = vecs.size();
40  int nblocks = blk.getNumSubsets();
41  multi1d<Complex> chi_little(nblocks * nvecs_per_block);
42  int cntr = 0;
43  for (int v = 0 ; v < nvecs_per_block ; ++v) {
44  LatticeComplex prod = localInnerProduct( vecs[v] , chi);
45  multi1d<Complex> temp = sumMulti( prod, blk);
46  for (int b = 0 ; b < nblocks ; ++b) {
47  chi_little[cntr] = temp[b];
48  cntr++;
49  }
50  }
51 
52  //Next, solve the little dirac equation with chi_little as a source
53  multi1d<Complex> ainv_chi_little;
54  SystemSolverResults_t lres = solve_little( A, chi_little, ainv_chi_little,
55  vecs, blk, RsdCG, MaxCG);
56 
57  //Now Form P_L * \chi
58  ///!!!!Could be sped up???
59  LatticeFermion pl_chi = chi;
60  cntr = 0;
61  for (int v = 0 ; v < nvecs_per_block ; ++v)
62  for (int b = 0 ; b < nblocks ; ++b) {
63  LatticeFermion temp = zero;
64  //Need to restrict the action of A to a subspace, I hope this works
65  A(temp[blk[b]], vecs[v], Plus);
66  pl_chi[blk[b]] -= temp * ainv_chi_little[cntr];
67  cntr++;
68  }
69 
70  //Now send P_L * \chi to a normal solver
71  SystemSolverResults_t dres = any_old_solve(A, psi, pl_chi);
72 
73  //Act with P_R on psi
74  LatticeFermion dpsi = zero;
75  A(dpsi, psi, Plus);
76  multi1d<Complex> dpsi_little(nblocks * nvecs_per_block);
77  cntr = 0;
78  for (int v = 0 ; v < nvecs_per_block ; ++v) {
79  LatticeComplex prod = localInnerProduct( vecs[v] , dpsi);
80  multi1d<Complex> temp = sumMulti( prod, blk);
81  for (int b = 0 ; b < nblocks ; ++b) {
82  dpsi_little[cntr] = temp[b];
83  cntr++;
84  }
85  }
86 
87  cntr = 0;
88  for (int v = 0 ; v < nvecs_per_block ; ++v)
89  for (int b = 0 ; b < nblocks ; ++b) {
90  psi[blk[b]] -= vecs[v] * dpsi_little[cntr];
91  cntr++;
92  }
93 
94  //Add the little solution to the orthogonal compliment solution
95  cntr = 0;
96  for (int v = 0 ; v < nvecs_per_block ; ++v)
97  for (int b = 0 ; b < nblocks ; ++b)
98  {
99  psi[blk[b]] += ainv_chi_little[cntr] * vecs[v];
100  cntr++;
101  }
102 
103  END_CODE();
104  return res;
105 }
106 
107 } //end namespace
108 } // end namespace Chroma
Primary include file for CHROMA library code.
QDPSubTypeTrait< typename BinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Type_t localInnerProduct(const QDPSubType< T1, C1 > &l, const QDPType< T2, C2 > &r)
SystemSolverResults_t ddDeflInv(const LinearOperator< LatticeFermion > &A, const LatticeFermion &chi, LatticeFermion &psi, const mutli1d< LatticeFermion > &vecs, const QDP::Set blk, const Real &RsdCG, int MaxCG)
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
START_CODE()
A(A, psi, r, Ncb, PLUS)
Complex b
Definition: invbicg.cc:96
Double zero
Definition: invbicg.cc:106
Holds return info from SystemSolver call.
Definition: syssolver.h:17