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
) {
return
PowN<
N
/2>::op(t)*PowN<(
N
+1)/2>::op(t);}
8
};
9
template
<>
10
struct
PowN<0> {
11
template
<
typename
T>
12
static
T
op(
T
t
) {
return
T
(1);}
13
};
14
template
<>
15
struct
PowN<1> {
16
template
<
typename
T>
17
static
T
op(
T
t
) {
return
t
;}
18
};
19
template
<>
20
struct
PowN<2> {
21
template
<
typename
T>
22
static
T
op(
T
t
) {
return
t*
t
;}
23
};
24
25
template
<
typename
T>
26
T
powN(
T
t
,
int
n
) {
27
switch
(n) {
28
case
4:
return
PowN<4>::op(t);
// the only one that matters
29
case
3:
return
PowN<3>::op(t);
// and this
30
case
8:
return
PowN<8>::op(t);
// used in conversion????
31
case
2:
return
PowN<2>::op(t);
32
case
5:
return
PowN<5>::op(t);
33
case
6:
return
PowN<6>::op(t);
34
case
7:
return
PowN<7>::op(t);
35
case
0:
return
PowN<0>::op(t);
36
case
1:
return
PowN<1>::op(t);
37
default
:
return
std::pow
(t,
T
(n));
38
}
39
}
40
}
41
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:66
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