CHROMA
shifted_linop_w.h
Go to the documentation of this file.
1 /* even-odd preconditioned fermion linear operator with
2  * shifted mass term i*\mu*\gamma5*A_oo
3  * based on template, which can be used both to
4  * symmetric and asymmetric eo precondition
5  */
6 
7 #ifndef __SHIFTED_LINOP_W_H__
8 #define __SHIFTED_LINOP_W_H__
9 
10 #include "seoprec_constdet_linop.h"
11 #include "eoprec_constdet_linop.h"
12 #include "seoprec_logdet_linop.h"
13 #include "eoprec_logdet_linop.h"
14 #include "eoprec_linop.h"
16 
17 namespace Chroma
18 {
19  using namespace QDP::Hints;
20 
21  template<typename T, typename P, typename Q,
22  template<typename, typename, typename> class LinOp>
23  class TwistedShiftedLinOp : public DiffLinearOperator<T,P,Q> {};
24 
25  // Symmetric partial specialization
26  template<typename T, typename P, typename Q>
28  public:
30  base_op(base_op_), mu(mu_){}
31 
32  const Subset& subset() const override { return base_op.subset(); }
33 
34  const FermBC<T,P,Q>& getFermBC() const override { return base_op.getFermBC() ; }
35 
36  void operator()(T& out, const T& in, enum PlusMinus isign) const override
37  {
38  START_CODE();
39  T tmp;
40  moveToFastMemoryHint(tmp);
41 
42  if(isign == PLUS){
43  // shift with i\gamma_5 A_oo
44  base_op(out, in, isign);
45  base_op.unprecOddOddLinOp(tmp, in, isign);
46  out[rb[1]] += mu*(Gamma(15)*timesI(tmp));
47  }else{
48  // shift with -i\gamma_5 A_oo
49  base_op(out, in, isign);
50  base_op.unprecOddOddLinOp(tmp, in, isign);
51  out[rb[1]] -= mu*(Gamma(15)*timesI(tmp));
52  }
53  END_CODE();
54  }
55 
56  void deriv(P& ds_u, const T& Y, const T& X, enum PlusMinus isign)const override
57  {
58  START_CODE();
59  //const SymEvenOddPrecConstDetLinearOperator<T,P,Q>& constdet_op =
60  // static_cast<const SymEvenOddPrecConstDetLinearOperator<T,P,Q>&>(base_op);
61 
62  P ds_extra;
63  ds_extra.resize(Nd);
64  ds_u.resize(Nd);
65  for(int i=0; i<Nd; ++i){
66  ds_extra[i] = zero;
67  ds_u[i] = zero;
68  }
69  //constdet_op.deriv(ds_u, Y, X, isign);
70  base_op.deriv(ds_u, Y, X, isign);
71  // add deriv of shifted mass term
72  T Y_prime = zero;
73  Y_prime = Gamma(15)*Y;
74  base_op.derivUnprecOddOddLinOp(ds_extra, Y_prime, X, isign);
75  for(int i=0; i<Nd; ++i)
76  ds_extra[i] *= mu;
77 
78  if(isign == PLUS){
79  for(int i=0; i<Nd; ++i)
80  ds_u[i] += timesI(ds_extra[i]);
81  }else{
82  for(int i=0; i<Nd; ++i)
83  ds_u[i] -= timesI(ds_extra[i]);
84  }
85  END_CODE();
86  }
87 
88  private:
89  const Real mu;
90  //SymEvenOddPrecConstDetLinearOperator<T,P,Q> base_op;
92  };
93 
94  // Asymmetric partial specialization
95  // EvenOddPrecLogDetLinearOperator and EvenOddPrecConstDetLinearOperator both
96  // inherit from EvenOddPrecLinearOperator
97  // different from SymEvenOddPrecLogDetLinearOperator inherit from
98  // SymEvenOddPrecConstDetLinearOperator
99  // therefore slightly different specialization parameter for LinOp
100  template<typename T, typename P, typename Q>
102  public DiffLinearOperator<T,P,Q> {
103  public:
104  TwistedShiftedLinOp(const EvenOddPrecLinearOperator<T,P,Q>& base_op_, const Real& mu_):
105  base_op(base_op_), mu(mu_){}
106 
107  const Subset& subset() const override { return base_op.subset(); }
108  const FermBC<T,P,Q>& getFermBC() const override { return base_op.getFermBC(); }
109  void operator()(T& out, const T& in, enum PlusMinus isign)const override
110  {
111  START_CODE();
112  if(isign == PLUS){
113  // shift with i\gamma_5
114  base_op(out, in, isign);
115  out[rb[1]] += mu*(Gamma(15)*timesI(in));
116  }else{
117  // shift with -i\gamma_5
118  base_op(out, in, isign);
119  out[rb[1]] -= mu*(Gamma(15)*timesI(in));
120  }
121  END_CODE();
122  }
123 
124  void deriv(P& ds_u, const T& Y, const T& X, enum PlusMinus isign)const override
125  {
126  // its +/- i gamma_5 so indep of gauge fields
127  base_op.deriv(ds_u, Y, X, isign);
128  }
129 
130  private:
131  const Real mu;
133  };
134 }
135 #endif
Differentiable Linear Operator.
Definition: linearop.h:98
Even-odd preconditioned linear operator.
Definition: eoprec_linop.h:92
Base class for all fermion action boundary conditions.
Definition: fermbc.h:20
Even-odd preconditioned linear operator.
void operator()(T &out, const T &in, enum PlusMinus isign) const override
Apply the operator onto a source std::vector.
const Subset & subset() const override
Return the subset on which the operator acts.
const EvenOddPrecLinearOperator< T, P, Q > & base_op
TwistedShiftedLinOp(const EvenOddPrecLinearOperator< T, P, Q > &base_op_, const Real &mu_)
const FermBC< T, P, Q > & getFermBC() const override
Return the fermion BC object for this linear operator.
void deriv(P &ds_u, const T &Y, const T &X, enum PlusMinus isign) const override
Apply the derivative of the operator onto a source std::vector.
const SymEvenOddPrecLogDetLinearOperator< T, P, Q > & base_op
TwistedShiftedLinOp(const SymEvenOddPrecLogDetLinearOperator< T, P, Q > &base_op_, const Real &mu_)
const FermBC< T, P, Q > & getFermBC() const override
Return the fermion BC object for this linear operator.
void deriv(P &ds_u, const T &Y, const T &X, enum PlusMinus isign) const override
Apply the derivative of the operator onto a source std::vector.
void operator()(T &out, const T &in, enum PlusMinus isign) const override
Apply the operator onto a source std::vector.
const Subset & subset() const override
Return the subset on which the operator acts.
int mu
Definition: cool.cc:24
Include possibly optimized Wilson dslash.
Preconditioned 4D Linop with Gauge Independent Even-Even part.
Base class for even-odd preconditioned 4D and 5D Linop.
Preconditioned Linear Operators where the Even Even part depends on the gauge field.
Nd
Definition: meslate.cc:74
multi1d< LatticeColorMatrix > P
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::Q Q
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
LinOpSysSolverMGProtoClover::T T
int i
Definition: pbg5p_w.cc:55
@ PLUS
Definition: chromabase.h:45
static QDP_ColorVector * out
Constructor.
START_CODE()
Double zero
Definition: invbicg.cc:106
static QDP_ColorVector * in
Preconditioned 4D Linop with Gauge Independent Even-Even part.
Symmetric preconditioned linear pperators where the even-even and odd-odd parts depends on the gauge ...
Handle< LinearOperator< T > > LinOp
multi1d< LatticeColorMatrix > P
Definition: t_clover.cc:13