CMS 3D CMS Logo

SimplifyNumerical.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_SimplifyNumerical_h
2 #define PhysicsTools_Utilities_SimplifyNumerical_h
6 
7 namespace funct {
8 
9  template <int n, int m>
10  struct Sum<Numerical<n>, Numerical<m> > {
12  inline static type combine(const Numerical<n>&, const Numerical<m>&) { return type(); }
13  };
14 
15  template <int n, int m>
17  typedef Numerical<n - m> type;
18  inline static type combine(const Numerical<n>&, const Numerical<m>&) { return type(); }
19  };
20 
21  template <int n>
22  struct Minus<Numerical<n> > {
23  typedef Numerical<-n> type;
24  inline static type operate(const Numerical<n>&) { return type(); }
25  };
26 
27  template <int n, int m>
28  struct Product<Numerical<n>, Numerical<m> > {
30  inline static type combine(const Numerical<n>&, const Numerical<m>&) { return type(); }
31  };
32 
33  template <int n>
34  struct Ratio<Numerical<n>, Numerical<1> > {
35  typedef Numerical<n> type;
36  inline static type combine(const Numerical<n>&, const Numerical<1>&) { return type(); }
37  };
38 
39  // n ^ m = n * n ^ ( m - 1 )
40  template <int n, int m, bool posM = (m > 0)>
41  struct NumPower {
43  inline static type combine(const Numerical<n>&, const Numerical<m>&) { return type(); }
44  };
45 
46  // 1 ^ m = 1
47  template <int m, bool posM>
48  struct NumPower<1, m, posM> {
49  typedef Numerical<1> type;
50  inline static type combine(const Numerical<1>&, const Numerical<m>&) { return type(); }
51  };
52 
53  // n ^ 1 = n
54  template <int n>
55  struct NumPower<n, 1, true> {
56  typedef Numerical<n> type;
57  inline static type combine(const Numerical<n>&, const Numerical<1>&) { return type(); }
58  };
59 
60  // n ^ 0 = 1
61  template <int n>
62  struct NumPower<n, 0, true> {
63  typedef Numerical<1> type;
64  inline static type combine(const Numerical<n>&, const Numerical<0>&) { return type(); }
65  };
66 
67  // n ^ (-m) = 1 / n ^ m
68  template <int n, int m>
69  struct NumPower<n, m, false> {
70  typedef typename Fraction<1, NumPower<n, -m>::type::value>::type type;
71  inline static type combine(const Numerical<n>&, const Numerical<m>&) { return type(); }
72  };
73 
74  template <int n, int m>
75  struct Power<Numerical<n>, Numerical<m> > : public NumPower<n, m> {};
76 
77 } // namespace funct
78 
79 #endif
funct::Minus
Definition: Minus.h:18
funct::false
false
Definition: Factorize.h:34
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
funct::Minus< Numerical< n > >::operate
static type operate(const Numerical< n > &)
Definition: SimplifyNumerical.h:24
Fraction.h
funct::NumPower::type
Numerical< n *NumPower< n, m - 1 >::type::value > type
Definition: SimplifyNumerical.h:42
funct::Product< Numerical< n >, Numerical< m > >::type
Numerical< n *m > type
Definition: SimplifyNumerical.h:29
funct::NumPower< n, m, false >::type
Fraction< 1, NumPower< n, -m >::type::value >::type type
Definition: SimplifyNumerical.h:70
funct::Sum< Numerical< n >, Numerical< m > >::combine
static type combine(const Numerical< n > &, const Numerical< m > &)
Definition: SimplifyNumerical.h:12
funct::Difference< Numerical< n >, Numerical< m > >::type
Numerical< n - m > type
Definition: SimplifyNumerical.h:17
funct::Ratio
Definition: Ratio.h:18
funct::Sum< Numerical< n >, Numerical< m > >::type
Numerical< n+m > type
Definition: SimplifyNumerical.h:11
funct::Product::type
ProductStruct< A, B > type
Definition: Product.h:19
funct::Difference< Numerical< n >, Numerical< m > >::combine
static type combine(const Numerical< n > &, const Numerical< m > &)
Definition: SimplifyNumerical.h:18
funct::Minus< Numerical< n > >::type
Numerical<-n > type
Definition: SimplifyNumerical.h:23
funct::NumPower< n, m, false >::combine
static type combine(const Numerical< n > &, const Numerical< m > &)
Definition: SimplifyNumerical.h:71
funct::NumPower< n, 0, true >::combine
static type combine(const Numerical< n > &, const Numerical< 0 > &)
Definition: SimplifyNumerical.h:64
Numerical.h
funct::NumPower< n, 1, true >::combine
static type combine(const Numerical< n > &, const Numerical< 1 > &)
Definition: SimplifyNumerical.h:57
funct::Difference::type
Sum< A, typename Minus< B >::type >::type type
Definition: Difference.h:10
funct::m
m
Definition: Factorize.h:50
funct::Power
Definition: Power.h:19
funct::FractionStruct
Definition: Fraction.h:11
funct::true
true
Definition: Factorize.h:173
funct::Ratio< Numerical< n >, Numerical< 1 > >::type
Numerical< n > type
Definition: SimplifyNumerical.h:35
funct::Ratio< Numerical< n >, Numerical< 1 > >::combine
static type combine(const Numerical< n > &, const Numerical< 1 > &)
Definition: SimplifyNumerical.h:36
funct::Fraction
Definition: Fraction.h:31
funct::NumPower< n, 0, true >::type
Numerical< 1 > type
Definition: SimplifyNumerical.h:63
funct::NumPower
Definition: SimplifyNumerical.h:41
funct::Difference
Definition: Difference.h:9
funct::type
arg type
Definition: Factorize.h:37
funct::Product< Numerical< n >, Numerical< m > >::combine
static type combine(const Numerical< n > &, const Numerical< m > &)
Definition: SimplifyNumerical.h:30
Operations.h
relativeConstraints.value
value
Definition: relativeConstraints.py:53
funct::NumPower< n, 1, true >::type
Numerical< n > type
Definition: SimplifyNumerical.h:56
funct::Product
Definition: Product.h:18
funct::Minus::type
MinusStruct< A > type
Definition: Minus.h:19
funct::Ratio::type
RatioStruct< A, B > type
Definition: Ratio.h:19
funct::Sum::type
SumStruct< A, B > type
Definition: Sum.h:19
funct::Sum
Definition: Sum.h:18
funct::NumPower< 1, m, posM >::combine
static type combine(const Numerical< 1 > &, const Numerical< m > &)
Definition: SimplifyNumerical.h:50
funct::Numerical
Definition: Numerical.h:7
funct::NumPower< 1, m, posM >::type
Numerical< 1 > type
Definition: SimplifyNumerical.h:49
funct::NumPower::combine
static type combine(const Numerical< n > &, const Numerical< m > &)
Definition: SimplifyNumerical.h:43
funct
Definition: Abs.h:5