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 <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 { return std::pow(_1(), _2()); }
11  operator double() const { return std::pow(_1(), _2()); }
12  double operator()(double x) const { return std::pow(_1(x), _2(x)); }
13  double operator()(double x, double y) const { return std::pow(_1(x, y), _2(x, y)); }
14  A _1;
15  B _2;
16  };
17 
18  template <typename A, typename B>
19  struct Power {
21  static type combine(const A& a, const B& b) { return type(a, b); }
22  };
23 
24  template <typename A, typename B>
25  inline typename Power<A, B>::type operator^(const A& a, const B& b) {
26  return Power<A, B>::combine(a, b);
27  }
28 
29  template <typename A, typename B>
30  inline typename Power<A, B>::type pow(const A& a, const B& b) {
31  return Power<A, B>::combine(a, b);
32  }
33 
34 } // namespace funct
35 
36 #endif
funct::PowerStruct::operator()
double operator()(double x) const
Definition: Power.h:12
funct::PowerStruct::operator()
double operator()(double x, double y) const
Definition: Power.h:13
funct::B
TEMPL(T2) struct Divides B
Definition: Factorize.h:29
funct::operator^
Power< A, B >::type operator^(const A &a, const B &b)
Definition: Power.h:25
funct::PowerStruct
Definition: Power.h:8
funct::PowerStruct::operator()
double operator()() const
Definition: Power.h:10
funct::Power
Definition: Power.h:19
b
double b
Definition: hdecay.h:118
funct::Power::combine
static type combine(const A &a, const B &b)
Definition: Power.h:21
a
double a
Definition: hdecay.h:119
A
funct::Power::type
PowerStruct< A, B > type
Definition: Power.h:20
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
funct::PowerStruct::PowerStruct
PowerStruct(const A &a, const B &b)
Definition: Power.h:9
funct::PowerStruct::_1
A _1
Definition: Power.h:14
funct
Definition: Abs.h:5
funct::PowerStruct::_2
B _2
Definition: Power.h:15