CHROMA
polprec_op.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Maybe usefull for polynomial preconditioning. It contructs an
4  * operator that is \f$QP(Q^2)Q\f$, where \f$Q = \gamma_5 M\f$, with M any 4D dirac
5  * operator (including EO preconditioned variants). P(Q^2) is could be any
6  * function of Q^2.
7  *
8  * Initial version Feb. 6, 2006 (Kostas Orginos)
9  */
10 
11 #ifndef _LPOLPREC_H
12 #define _LPOLPREC_H
13 
14 #include "handle.h"
15 #include "linearop.h"
16 
17 using namespace QDP::Hints;
18 
19 namespace Chroma
20 {
21  //! Polynomial preconditioner
22  /*! \ingroup linop */
23  template<typename T, typename P, typename Q>
24  class PolyPrec: public DiffLinearOperator<T,P,Q>
25  {
26  private:
27  Handle< DiffLinearOperator<T,P,Q> > M ; // this is the operator
28  Handle< DiffLinearOperator<T,P,Q> > Pol ; // this is the preconditioner
29 
30  public:
31  // constructor
33  Handle< DiffLinearOperator<T,P,Q> > p_) : M(m_), Pol(p_) { }
34 
35 
37 
38  //! Return the fermion BC object for this linear operator
39  const FermBC<T,P,Q>& getFermBC() const {return M->getFermBC();}
40 
41  //! Subset comes from underlying operator
42  // Hopefully the subsets of the preconditioner and the matrix
43  // are the same...
44  inline const Subset& subset() const {return M->subset();}
45 
46  inline void g5M(T& out, const T& in, enum PlusMinus isign) const
47  {
48  const int G5=Ns*Ns-1;
49 
50  T tmp;
51  const Subset& sub = M->subset();
52 
53  // [ Gamma(5) D ]^{dag} = Gamma(5) D
54  // using D = gamma_5 D^{dag} gamma_5
55 
56  (*M)(tmp, in, PLUS);
57  out[sub] = Gamma(G5)*tmp;
58  }
59 
60 
61  //! The operator is Q P(Q^2) Q
62  // Q is g5M
63  // If I ever do this for DWF the g5M definition has to change....
64  void operator()(T& chi, const T& psi, PlusMinus isign) const
65  {
66  T tmp ;
67 
68  g5M(chi,psi,PLUS) ;
69  (*Pol)(tmp,chi,PLUS) ;
70  g5M(chi,tmp,PLUS) ;
71 
72  }
73 
74 
75  //! Apply the derivative of the linop
76  void deriv(P& ds_u, const T& chi, const T& psi, PlusMinus isign) const
77  {
78  const int G5=Ns*Ns-1;
79  // So do something like
80  ds_u.resize(Nd);
81  ds_u = zero;
82  P ds_tmp;
83 
84 
85  const Subset& sub = M->subset();
86 
87  T g5Mchi,g5Mpsi ;
88  T g5Pg5Mchi, g5Pg5Mpsi ;
89  {
90  T tt ;
91  g5M(g5Mchi,chi,PLUS);
92  (*Pol)(tt,g5Mchi,PLUS) ;
93  g5Pg5Mchi[sub] = Gamma(G5)*tt ;
94 
95  g5M(g5Mpsi,psi,PLUS) ;
96  (*Pol)(tt,g5Mpsi,PLUS) ;
97  g5Pg5Mpsi[sub] = Gamma(G5)*tt ;
98  }
99 
100  M->deriv(ds_tmp, g5Pg5Mchi, psi, PLUS);
101  ds_u += ds_tmp; // build up force
102  Pol->deriv(ds_tmp, g5Mchi, g5Mpsi, PLUS);
103  ds_u += ds_tmp; // build up force
104  M->deriv(ds_tmp, chi, g5Pg5Mpsi, MINUS);
105  ds_u += ds_tmp; // build up force
106  }
107 
108  };
109 
110 }// End Namespace Chroma
111 
112 #endif
Differentiable Linear Operator.
Definition: linearop.h:98
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Class for counted reference semantics.
Definition: handle.h:33
Polynomial preconditioner.
Definition: polprec_op.h:25
PolyPrec(Handle< DiffLinearOperator< T, P, Q > > m_, Handle< DiffLinearOperator< T, P, Q > > p_)
Definition: polprec_op.h:32
const Subset & subset() const
Subset comes from underlying operator.
Definition: polprec_op.h:44
const FermBC< T, P, Q > & getFermBC() const
Return the fermion BC object for this linear operator.
Definition: polprec_op.h:39
void deriv(P &ds_u, const T &chi, const T &psi, PlusMinus isign) const
Apply the derivative of the linop.
Definition: polprec_op.h:76
Handle< DiffLinearOperator< T, P, Q > > Pol
Definition: polprec_op.h:28
void operator()(T &chi, const T &psi, PlusMinus isign) const
The operator is Q P(Q^2) Q.
Definition: polprec_op.h:64
Handle< DiffLinearOperator< T, P, Q > > M
Definition: polprec_op.h:27
void g5M(T &out, const T &in, enum PlusMinus isign) const
Definition: polprec_op.h:46
Class for counted reference semantics.
Linear Operators.
Double tmp
Definition: meslate.cc:60
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
int G5
Definition: pbg5p_w.cc:57
LinOpSysSolverMGProtoClover::T T
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
static QDP_ColorVector * out
Constructor.
Double zero
Definition: invbicg.cc:106
static QDP_ColorVector * in
chi
Definition: pade_trln_w.cc:24
psi
Definition: pade_trln_w.cc:191
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13