CMS 3D CMS Logo

Ratio.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Ratio_h
2 #define PhysicsTools_Utilities_Ratio_h
3 #include <boost/static_assert.hpp>
4 
5 namespace funct {
6  template <typename A, typename B>
7  struct RatioStruct {
8  RatioStruct(const A& a, const B& b) : _1(a), _2(b) {}
9  double operator()() const { return _1() / _2(); }
10  operator double() const { return _1() / _2(); }
11  double operator()(double x) const { return _1(x) / _2(x); }
12  double operator()(double x, double y) const { return _1(x, y) / _2(x, y); }
13  A _1;
14  B _2;
15  };
16 
17  template <typename A, typename B>
18  struct Ratio {
20  static type combine(const A& a, const B& b) { return type(a, b); }
21  };
22 
23  template <typename A, typename B>
24  inline typename Ratio<A, B>::type operator/(const A& a, const B& b) {
25  return Ratio<A, B>::combine(a, b);
26  }
27 
28 } // namespace funct
29 
30 #endif
RatioStruct(const A &a, const B &b)
Definition: Ratio.h:8
Definition: Abs.h:5
Ratio< A, B >::type operator/(const A &a, const B &b)
Definition: Ratio.h:24
double operator()() const
Definition: Ratio.h:9
RatioStruct< A, B > type
Definition: Ratio.h:19
double b
Definition: hdecay.h:118
double operator()(double x, double y) const
Definition: Ratio.h:12
arg type
Definition: Factorize.h:37
double operator()(double x) const
Definition: Ratio.h:11
double a
Definition: hdecay.h:119
static type combine(const A &a, const B &b)
Definition: Ratio.h:20