CHROMA
tprec_linop.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! @file
3  * @brief Time-preconditioned Linear Operators
4  */
5 
6 #ifndef __tprec_linop_h__
7 #define __tprec_linop_h__
8 
9 #include "linearop.h"
10 
11 namespace Chroma
12 {
13 
14  //-----------------------------------------------------------------------------------
15  //! Time preconditioned linear operator
16  /*! @ingroup linop
17  *
18  * Support for time preconditioned linear operators
19  * Given a matrix M written in block form:
20  *
21  * M = D_t + D_s
22  *
23  * The preconditioning consists of multiplying by the inverse
24  * of the time operator
25  *
26  * This class is used to implement the resulting linear operator
27  *
28  * M' = 1 + D_t^(-1)*D_s
29  *
30  * M'^dag = 1 + D_s^dag * (D_t^(-1))^dag
31  *
32  * The non-symmetrical nature of the daggered version means the two
33  * cases (no-dagger and dagger) must be handled separately. This is
34  * in contrast to the standard (4D) even-odd precond. case where the
35  * the daggered version has the same structure, except the dagger
36  * is pushed down into the individual pieces.
37  */
38 
39  template<typename T, typename P, typename Q>
41  {
42  public:
43  //! Virtual destructor to help with cleanup;
45 
46  //! Defined on the entire lattice
47  const Subset& subset() const {return all;}
48 
49  //! Return the fermion BC object for this linear operator
50  virtual const FermBC<T,P,Q>& getFermBC() const = 0;
51 
52  //! The time direction
53  int tDir() const = 0;
54 
55  //! Apply the time block onto a source std::vector
56  /*! This does not need to be optimized */
57  virtual void timeLinOp(T& chi, const T& psi,
58  enum PlusMinus isign) const = 0;
59 
60  //! Apply the inverse of the time block onto a source std::vector
61  virtual void timeInvLinOp(T& chi, const T& psi,
62  enum PlusMinus isign) const = 0;
63 
64  //! Apply the the space block onto a source std::vector
65  virtual void spaceLinOp(T& chi, const T& psi,
66  enum PlusMinus isign) const = 0;
67 
68  //! Apply the operator onto a source std::vector
69  virtual void operator() (T& chi, const T& psi,
70  enum PlusMinus isign) const
71  {
72  T tmp1, tmp2; moveToFastMemoryHint(tmp1); moveToFastMemoryHint(tmp2);
73 
74  switch (isign)
75  {
76  case PLUS:
77  // chi = psi + D_t^(-1)*D_s*psi
78  spaceLinOp(tmp1, psi, isign);
79  timeInvLinOp(tmp2, tmp1, isign);
80  chi = psi + tmp2;
81  break;
82 
83  case MINUS:
84  // chi = psi + D_s^dag*D_t^(-1)^dag*psi
85  timeInvLinOp(tmp1, psi, isign);
86  spaceLinOp(tmp2, tmp1, isign);
87  chi = psi + tmp2;
88  break;
89 
90  default:
91  QDPIO::cerr << "unknown sign" << std::endl;
92  QDP_abort(1);
93  }
94  }
95 
96  //! Apply the UNPRECONDITIONED operator onto a source std::vector
97  /*! Mainly intended for debugging */
98  virtual void unprecLinOp(T& chi, const T& psi,
99  enum PlusMinus isign) const
100  {
101  T tmp1, tmp2; moveToFastMemoryHint(tmp1); moveToFastMemoryHint(tmp2);
102 
103  // chi = D_t*psi + D_s*psi
104  timeLinOp(tmp1, psi, isign);
106  chi = tmp1 + tmp2;
107  }
108 
109  //! Apply the even-even block onto a source std::vector
110  virtual void derivTimeLinOp(P& ds_u, const T& chi, const T& psi,
111  enum PlusMinus isign) const = 0;
112 
113  //! Apply the space block onto a source std::vector
114  virtual void derivSpaceLinOp(P& ds_u, const T& chi, const T& psi,
115  enum PlusMinus isign) const = 0;
116 
117  //! Apply the derivative of the operator onto a source std::vector
118  /*! User should make sure deriv routines do a resize */
119  virtual void deriv(P& ds_u, const T& chi, const T& psi,
120  enum PlusMinus isign) const = 0;
121 
122  //! Apply the derivative of the UNPRECONDITIONED operator onto a source std::vector
123  /*! Mainly intended for debugging */
124  virtual void derivUnprecLinOp(P& ds_u, const T& chi, const T& psi,
125  enum PlusMinus isign) const = 0;
126  };
127 
128 }
129 
130 #endif
Differentiable Linear Operator.
Definition: linearop.h:98
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Time preconditioned linear operator.
Definition: tprec_linop.h:41
virtual void deriv(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the derivative of the operator onto a source std::vector.
virtual const FermBC< T, P, Q > & getFermBC() const =0
Return the fermion BC object for this linear operator.
virtual void derivSpaceLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the space block onto a source std::vector.
virtual void derivUnprecLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the derivative of the UNPRECONDITIONED operator onto a source std::vector.
virtual void operator()(T &chi, const T &psi, enum PlusMinus isign) const
Apply the operator onto a source std::vector.
Definition: tprec_linop.h:69
const Subset & subset() const
Defined on the entire lattice.
Definition: tprec_linop.h:47
virtual void unprecLinOp(T &chi, const T &psi, enum PlusMinus isign) const
Apply the UNPRECONDITIONED operator onto a source std::vector.
Definition: tprec_linop.h:98
int tDir() const =0
The time direction.
virtual void timeInvLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the inverse of the time block onto a source std::vector.
virtual void spaceLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the the space block onto a source std::vector.
virtual ~TimePrecLinearOperator()
Virtual destructor to help with cleanup;.
Definition: tprec_linop.h:44
virtual void derivTimeLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the even-even block onto a source std::vector.
virtual void timeLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the time block onto a source std::vector.
Linear Operators.
Double tmp2
Definition: mesq.cc:30
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::T T
@ MINUS
Definition: chromabase.h:45
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13