CHROMA
eo_linop.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*! @file
4  * @brief Linear Operators
5  */
6 
7 #ifndef __eo_linop_h__
8 #define __eo_linop_h__
9 
10 #include "linearop.h"
11 
12 namespace Chroma
13 {
14 
15  //---------------------------------------------------------------------
16  //! Even odd Linear Operator (for staggered like things )
17  /*! @ingroup linop
18  *
19  * Support for even-odd staggered-like linear operators
20  *
21  * [ D_ee D_eo ]
22  * [ D_oe D_oo ]
23  *
24  * Usually D_ee = D_oo = 2m
25  */
26  template<typename T, typename P, typename Q>
28  {
29  public:
30  //! Virtual destructor to help with cleanup;
32 
33  //! Only defined on the even lattice
34  const Subset& subset() const {return all;}
35 
36  //! Return the fermion BC object for this linear operator
37  virtual const FermBC<T,P,Q>& getFermBC() const = 0;
38 
39  //! Apply the even-even block onto a source std::vector
40  virtual void evenEvenLinOp(T& chi, const T& psi,
41  enum PlusMinus isign) const = 0;
42 
43  //! Apply the the even-odd block onto a source std::vector
44  virtual void evenOddLinOp(T& chi, const T& psi,
45  enum PlusMinus isign) const = 0;
46 
47  //! Apply the the odd-even block onto a source std::vector
48  virtual void oddEvenLinOp(T& chi, const T& psi,
49  enum PlusMinus isign) const = 0;
50 
51  //! Apply the the odd-odd block onto a source std::vector
52  virtual void oddOddLinOp(T& chi, const T& psi,
53  enum PlusMinus isign) const = 0;
54 
55  //! Apply the operator onto a source std::vector
56  /*! User should make sure deriv routines do a resize */
57  virtual void operator() (T& chi, const T& psi,
58  enum PlusMinus isign) const
59  {
60  T tmp1, tmp2; // if an array is used here, the space is not reserved
61  moveToFastMemoryHint(tmp1);
62  moveToFastMemoryHint(tmp2);
63 
64  /* Chi = D Psi + D Psi */
65  /* E E,E E E,O O */
66  evenEvenLinOp(tmp1, psi, isign);
68  chi[rb[0]] = tmp1 + tmp2;
69 
70  /* Chi = D Psi + D Psi */
71  /* O O,E E O,O O */
72  oddEvenLinOp(tmp1, psi, isign);
74  chi[rb[1]] = tmp1 + tmp2;
75 
76  getFermBC().modifyF(chi, rb[1]);
77  }
78 
79  //! Apply the even-even block onto a source std::vector
80  virtual void derivEvenEvenLinOp(P& ds_u,
81  const T& chi, const T& psi,
82  enum PlusMinus isign) const
83  {
84  QDPIO::cerr << "EvenOdd: not implemented" << std::endl;
85  QDP_abort(1);
86  }
87 
88  //! Apply the the even-odd block onto a source std::vector
89  virtual void derivEvenOddLinOp(P& ds_u,
90  const T& chi, const T& psi,
91  enum PlusMinus isign) const
92  {
93  QDPIO::cerr << "EvenOdd: not implemented" << std::endl;
94  QDP_abort(1);
95  }
96 
97  //! Apply the the odd-even block onto a source std::vector
98  virtual void derivOddEvenLinOp(P& ds_u,
99  const T& chi, const T& psi,
100  enum PlusMinus isign) const
101  {
102  QDPIO::cerr << "EvenOdd: not implemented" << std::endl;
103  QDP_abort(1);
104  }
105 
106  //! Apply the the odd-odd block onto a source std::vector
107  virtual void derivOddOddLinOp(P& ds_u,
108  const T& chi, const T& psi,
109  enum PlusMinus isign) const
110  {
111  QDPIO::cerr << "EvenOdd: not implemented" << std::endl;
112  QDP_abort(1);
113  }
114 
115  //! Apply the operator onto a source std::vector
116  virtual void deriv(P& ds_u,
117  const T& chi, const T& psi,
118  enum PlusMinus isign) const
119  {
120  // Need deriv of chi_e^dag * (D_ee * psi_e + D_eo * psi_i)
121  // Need deriv of chi_o^dag * (D_oe * psi_e + D_oo * psi_i)
122 
123  //
124  // NOTE: even with even-odd decomposition, the ds_u will still have contributions
125  // on all cb. So, no adding of ds_1 onto ds_u under a subset
126  //
127  T tmp1, tmp2; // if an array is used here, the space is not reserved
128  moveToFastMemoryHint(tmp1);
129  moveToFastMemoryHint(tmp2);
130 
131  P ds_1; // routines should resize
132 
133  // ds_u = chi_e ^dag * D'_ee * psi_e
134  derivEvenEvenLinOp(ds_u, chi, psi, isign);
135 
136  // ds_u += chi_e ^dag * D'_eo * psi_o
137  derivEvenOddLinOp(ds_1, chi, psi, isign);
138  ds_u += ds_1;
139 
140  // ds_u += chi_o ^dag * D'_oe * psi_e
141  derivOddEvenLinOp(ds_1, chi, psi, isign);
142  ds_u += ds_1;
143 
144  // ds_u += chi_o ^dag * D'_oo * psi_o
145  derivOddOddLinOp(ds_1, chi, psi, isign);
146  ds_u += ds_1;
147 
148  getFermBC().zero(ds_u);
149  }
150 
151  //! Return flops performed by the evenEvenLinOp
152  virtual unsigned long evenEvenNFlops() const { return 0; }
153 
154  //! Return flops performed by the evenOddLinOp
155  virtual unsigned long evenOddNFlops() const { return 0; }
156 
157  //! Return flops performed by the oddEvenLinOp
158  virtual unsigned long oddEvenNFlops() const { return 0; }
159 
160  //! Return flops performed by the oddOddLinOp
161  virtual unsigned long oddOddNFlops() const { return 0; }
162 
163 
164  //! Return flops performed by the operator()
165  virtual unsigned long nFlops() const {
166  return this->oddOddNFlops()
167  +this->oddEvenNFlops()
168  +this->evenEvenNFlops()
169  +this->evenOddNFlops();
170  }
171  };
172 
173 }
174 
175 
176 #endif
Differentiable Linear Operator.
Definition: linearop.h:98
Even odd Linear Operator (for staggered like things )
Definition: eo_linop.h:28
virtual void deriv(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const
Apply the operator onto a source std::vector.
Definition: eo_linop.h:116
virtual const FermBC< T, P, Q > & getFermBC() const =0
Return the fermion BC object for this linear operator.
virtual unsigned long evenEvenNFlops() const
Return flops performed by the evenEvenLinOp.
Definition: eo_linop.h:152
virtual unsigned long oddEvenNFlops() const
Return flops performed by the oddEvenLinOp.
Definition: eo_linop.h:158
const Subset & subset() const
Only defined on the even lattice.
Definition: eo_linop.h:34
virtual void operator()(T &chi, const T &psi, enum PlusMinus isign) const
Apply the operator onto a source std::vector.
Definition: eo_linop.h:57
virtual void oddOddLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the the odd-odd block onto a source std::vector.
virtual void evenEvenLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the even-even block onto a source std::vector.
virtual void derivOddEvenLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const
Apply the the odd-even block onto a source std::vector.
Definition: eo_linop.h:98
virtual void derivOddOddLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const
Apply the the odd-odd block onto a source std::vector.
Definition: eo_linop.h:107
virtual ~EvenOddLinearOperator()
Virtual destructor to help with cleanup;.
Definition: eo_linop.h:31
virtual unsigned long oddOddNFlops() const
Return flops performed by the oddOddLinOp.
Definition: eo_linop.h:161
virtual unsigned long evenOddNFlops() const
Return flops performed by the evenOddLinOp.
Definition: eo_linop.h:155
virtual void derivEvenEvenLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const
Apply the even-even block onto a source std::vector.
Definition: eo_linop.h:80
virtual void derivEvenOddLinOp(P &ds_u, const T &chi, const T &psi, enum PlusMinus isign) const
Apply the the even-odd block onto a source std::vector.
Definition: eo_linop.h:89
virtual unsigned long nFlops() const
Return flops performed by the operator()
Definition: eo_linop.h:165
virtual void evenOddLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the the even-odd block onto a source std::vector.
virtual void oddEvenLinOp(T &chi, const T &psi, enum PlusMinus isign) const =0
Apply the the odd-even block onto a source std::vector.
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Linear Operators.
Double tmp2
Definition: mesq.cc:30
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13