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