CHROMA
llincomb.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 #ifndef __llincomb_h__
4 #define __llincomb_h__
5 
6 #include "handle.h"
7 #include "linearop.h"
8 
9 
10 namespace Chroma
11 {
12  //! Linear combination of a Linear Operator
13  /*!
14  * \ingroup linop
15  *
16  * This operator does the linear combination (z1 + z2*B)*psi
17  */
18  template<typename T, class C>
19  class llincomb : public LinearOperator<T>
20  {
21  public:
22  //! Initialize pointer with existing pointer
23  /*! Requires that the pointer p is a return value of new */
24  llincomb(const LinearOperator<T>* p, const C& add_const_, const C& scale_fact_) :
25  A(p), add_const(add_const_), scale_fact(scale_fact_) {}
26 
27  //! Copy pointer (one more owner)
28  llincomb(Handle<const LinearOperator<T> > p, const C& add_const_, const C& scale_fact_) :
29  A(p), add_const(add_const_), scale_fact(scale_fact_) {}
30 
31  //! Destructor
32  ~llincomb() {}
33 
34  //! Subset comes from underlying operator
35  inline const Subset& subset() const {return A->subset();}
36 
37  //! Apply the operator onto a source std::vector
38  /*! For this operator, the sign is ignored */
39  inline void operator() (T& chi, const T& psi, enum PlusMinus isign) const
40  {
41  const Subset& sub = A->subset();
42  (*A)(chi, psi, isign);
43  chi[sub] *= scale_fact;
44  chi[sub] += add_const*psi;
45  }
46 
47  private:
49  const C add_const;
50  const C scale_fact;
51  };
52 }
53 
54 
55 #endif
Class for counted reference semantics.
Definition: handle.h:33
Linear Operator.
Definition: linearop.h:27
Linear combination of a Linear Operator.
Definition: llincomb.h:20
llincomb(const LinearOperator< T > *p, const C &add_const_, const C &scale_fact_)
Initialize pointer with existing pointer.
Definition: llincomb.h:24
const Handle< const LinearOperator< T > > A
Definition: llincomb.h:48
const Subset & subset() const
Subset comes from underlying operator.
Definition: llincomb.h:35
~llincomb()
Destructor.
Definition: llincomb.h:32
void operator()(T &chi, const T &psi, enum PlusMinus isign) const
Apply the operator onto a source std::vector.
Definition: llincomb.h:39
const C scale_fact
Definition: llincomb.h:50
llincomb(Handle< const LinearOperator< T > > p, const C &add_const_, const C &scale_fact_)
Copy pointer (one more owner)
Definition: llincomb.h:28
const C add_const
Definition: llincomb.h:49
Class for counted reference semantics.
Linear Operators.
SpinMatrix C()
C = Gamma(10)
Definition: barspinmat_w.cc:29
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LinOpSysSolverMGProtoClover::T T
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35