npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
BindKernel.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_BINDKERNEL_HH_
2 #define NPSTAT_BINDKERNEL_HH_
3 
4 /*!
5 // \file BindKernel.hh
6 //
7 // \brief Special bind operation for two-argument functors which also
8 // converts them into Functor1<long double,long double>
9 //
10 // Author: I. Volobouev
11 //
12 // December 2022
13 */
14 
16 
17 namespace npstat {
18  template <class Kernel>
19  class BindKernelXHelper : public npstat::Functor1<long double,long double>
20  {
21  public:
22  inline BindKernelXHelper(const Kernel& kernel, const long double x)
23  : kernel_(kernel), x_(x) {}
24 
25  inline virtual ~BindKernelXHelper() {}
26 
27  inline virtual long double operator()(const long double& y) const
28  {return kernel_(x_, y);}
29 
30  private:
31  const Kernel& kernel_;
32  long double x_;
33  };
34 
35  // Note that the lifetime of the argument kernel should exceed
36  // the lifetime of the object produced by this function
37  template <class Kernel>
38  inline BindKernelXHelper<Kernel> BindKernelX(const Kernel& kernel,
39  const long double x)
40  {
41  return BindKernelXHelper<Kernel>(kernel, x);
42  }
43 
44  template <class Kernel>
45  class BindKernelYHelper : public npstat::Functor1<long double,long double>
46  {
47  public:
48  inline BindKernelYHelper(const Kernel& kernel, const long double y)
49  : kernel_(kernel), y_(y) {}
50 
51  inline virtual ~BindKernelYHelper() {}
52 
53  inline virtual long double operator()(const long double& x) const
54  {return kernel_(x, y_);}
55 
56  private:
57  const Kernel& kernel_;
58  long double y_;
59  };
60 
61  // Note that the lifetime of the argument kernel should exceed
62  // the lifetime of the object produced by this function
63  template <class Kernel>
64  inline BindKernelYHelper<Kernel> BindKernelY(const Kernel& kernel,
65  const long double y)
66  {
67  return BindKernelYHelper<Kernel>(kernel, y);
68  }
69 }
70 
71 #endif // NPSTAT_BINDKERNEL_HH_
Interface definitions and concrete simple functors for a variety of functor-based calculations.
Definition: BindKernel.hh:20
Definition: BindKernel.hh:46
Definition: AbsArrayProjector.hh:14
Definition: SimpleFunctors.hh:58