Main Page
Namespaces
Classes
Package Documentation
RecoTracker
FinalTrackSelectors
plugins
powN.h
Go to the documentation of this file.
1
#include <cmath>
2
namespace
{
3
// not a generic solution (wrong for N negative for instance)
4
template
<
int
N>
5
struct
PowN {
6
template
<
typename
T>
7
static
T
op(
T
t
) {
8
return
PowN<
N
/ 2>::op(t) * PowN<(
N
+ 1) / 2>::op(t);
9
}
10
};
11
template
<>
12
struct
PowN<0> {
13
template
<
typename
T>
14
static
T
op(
T
t
) {
15
return
T
(1);
16
}
17
};
18
template
<>
19
struct
PowN<1> {
20
template
<
typename
T>
21
static
T
op(
T
t
) {
22
return
t
;
23
}
24
};
25
template
<>
26
struct
PowN<2> {
27
template
<
typename
T>
28
static
T
op(
T
t
) {
29
return
t *
t
;
30
}
31
};
32
33
template
<
typename
T>
34
T
powN(
T
t
,
int
n
) {
35
switch
(n) {
36
case
4:
37
return
PowN<4>::op(t);
// the only one that matters
38
case
3:
39
return
PowN<3>::op(t);
// and this
40
case
8:
41
return
PowN<8>::op(t);
// used in conversion????
42
case
2:
43
return
PowN<2>::op(t);
44
case
5:
45
return
PowN<5>::op(t);
46
case
6:
47
return
PowN<6>::op(t);
48
case
7:
49
return
PowN<7>::op(t);
50
case
0:
51
return
PowN<0>::op(t);
52
case
1:
53
return
PowN<1>::op(t);
54
default
:
55
return
std::pow
(t,
T
(n));
56
}
57
}
58
}
// namespace
OrderedSet.t
t
Definition:
OrderedSet.py:90
dqmiodumpmetadata.n
n
Definition:
dqmiodumpmetadata.py:28
N
#define N
Definition:
blowfish.cc:9
T
long double T
Definition:
Basic3DVectorLD.h:48
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition:
Power.h:30
Generated for CMSSW Reference Manual by
1.8.11