CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Power.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Power_h
2 #define PhysicsTools_Utilities_Power_h
3 #include <boost/static_assert.hpp>
4 #include <cmath>
5 
6 namespace funct {
7  template<typename A, typename B>
8  struct PowerStruct {
9  PowerStruct(const A & a, const B & b) : _1(a), _2(b) { }
10  double operator()() const {
11  return std::pow(_1(), _2());
12  }
13  operator double() const {
14  return std::pow(_1(), _2());
15  }
16  double operator()(double x) const {
17  return std::pow(_1(x), _2(x));
18  }
19  double operator()(double x, double y) const {
20  return std::pow(_1(x, y), _2(x, y));
21  }
22  A _1;
23  B _2;
24  };
25 
26  template<typename A, typename B>
27  struct Power {
29  static type combine(const A& a, const B& b) {
30  return type(a, b);
31  }
32  };
33 
34  template<typename A, typename B>
35  inline typename Power<A, B>::type operator^(const A& a, const B& b) {
36  return Power<A, B>::combine(a, b);
37  }
38 
39  template<typename A, typename B>
40  inline typename Power<A, B>::type pow(const A& a, const B& b) {
41  return Power<A, B>::combine(a, b);
42  }
43 
44 }
45 
46 #endif
PowerStruct< A, B > type
Definition: Power.h:28
PowerStruct(const A &a, const B &b)
Definition: Power.h:9
static type combine(const A &a, const B &b)
Definition: Power.h:29
double operator()(double x) const
Definition: Power.h:16
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
double operator()(double x, double y) const
Definition: Power.h:19
Power< A, B >::type operator^(const A &a, const B &b)
Definition: Power.h:35
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double operator()() const
Definition: Power.h:10