CMS 3D CMS Logo

Power.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Power_h
2 #define PhysicsTools_Utilities_Power_h
3 #include <cmath>
4 
5 namespace funct {
6  template <typename A, typename B>
7  struct PowerStruct {
8  PowerStruct(const A& a, const B& b) : _1(a), _2(b) {}
9  double operator()() const { return std::pow(_1(), _2()); }
10  operator double() const { return std::pow(_1(), _2()); }
11  double operator()(double x) const { return std::pow(_1(x), _2(x)); }
12  double operator()(double x, double y) const { return std::pow(_1(x, y), _2(x, y)); }
13  A _1;
14  B _2;
15  };
16 
17  template <typename A, typename B>
18  struct Power {
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 Power<A, B>::type operator^(const A& a, const B& b) {
25  return Power<A, B>::combine(a, b);
26  }
27 
28  template <typename A, typename B>
29  inline typename Power<A, B>::type pow(const A& a, const B& b) {
30  return Power<A, B>::combine(a, b);
31  }
32 
33 } // namespace funct
34 
35 #endif
funct::PowerStruct::operator()
double operator()(double x) const
Definition: Power.h:11
funct::PowerStruct::operator()
double operator()(double x, double y) const
Definition: Power.h:12
funct::B
TEMPL(T2) struct Divides B
Definition: Factorize.h:24
funct::operator^
Power< A, B >::type operator^(const A &a, const B &b)
Definition: Power.h:24
funct::PowerStruct
Definition: Power.h:7
funct::PowerStruct::operator()
double operator()() const
Definition: Power.h:9
funct::Power
Definition: Power.h:18
b
double b
Definition: hdecay.h:118
funct::Power::combine
static type combine(const A &a, const B &b)
Definition: Power.h:20
a
double a
Definition: hdecay.h:119
A
funct::Power::type
PowerStruct< A, B > type
Definition: Power.h:19
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
funct::PowerStruct::PowerStruct
PowerStruct(const A &a, const B &b)
Definition: Power.h:8
funct::PowerStruct::_1
A _1
Definition: Power.h:13
funct
Definition: Abs.h:5
funct::PowerStruct::_2
B _2
Definition: Power.h:14