FWCore
Utilities
interface
math.h
Go to the documentation of this file.
1
#ifndef FWCore_Utilities_math_h
2
#define FWCore_Utilities_math_h
3
4
#include <cmath>
5
#include <sys/types.h>
6
#include "
math_private.h
"
7
8
namespace
edm
9
{
10
11
namespace
detail
12
{
13
inline
bool
isnan
(
float
x)
14
{
15
u_int32_t wx;
16
17
GET_FLOAT_WORD
(wx, x);
18
wx &= 0x7fffffff;
19
return
(
bool
)(wx > 0x7f800000);
20
}
21
22
inline
bool
isnan
(
double
x)
23
{
24
u_int32_t hx, lx;
25
26
EXTRACT_WORDS
(hx, lx, x);
27
lx |= hx & 0xfffff;
28
hx &= 0x7ff00000;
29
return
(
bool
)(hx == 0x7ff00000) && (lx != 0);
30
}
31
32
inline
bool
isnan
(
long
double
x)
33
{
34
u_int32_t ex, hx, lx;
35
36
GET_LDOUBLE_WORDS
(ex, hx, lx, x);
37
ex &= 0x7fff;
38
return
(
bool
)((ex == 0x7fff) && ((hx & 0x7fffffff) | lx));
39
}
40
}
41
42
43
template
<
class
FP>
inline
bool
asm_isnan
(FP x)
44
{
45
// I do not know of a preprocessor symbol used to identify the
46
// presence of an x87 floating-point processor.
47
#if defined(__i386__)||defined(__x86_64)
48
u_int16_t
flags
;
49
__asm__(
"fxam\n\t"
50
"fstsw %%ax"
51
:
"=a"
(
flags
)
/* output */
52
:
"t"
(x)
/* input */
53
:
/* clobbered */
54
);
55
return
(
flags
& 0x4500)==0x0100;
56
#else
57
#error No asm_isnan for this architecture.
58
#endif
59
}
60
61
template
<
class
FP>
inline
bool
equal_isnan
(FP x)
62
{
63
return
x !=x;
64
}
65
66
// Here are the public functions, chosen by best timing on Intel
67
// Pentium 4. Other architectures are likely to have different
68
// orderings.
69
inline
bool
isnan
(
float
f
) {
return
detail::isnan
(
f
); }
70
71
inline
bool
isnan
(
double
d
) {
return
equal_isnan
(
d
); }
72
73
inline
bool
isnan
(
long
double
q
) {
return
detail::isnan
(
q
); }
74
75
}
// namespace edm
76
77
#endif
math_private.h
f
double f[11][100]
Definition:
MuScleFitUtils.cc:78
edm
HLT enums.
Definition:
AlignableModifier.h:19
data-class-funcs.q
q
Definition:
data-class-funcs.py:169
edm::isnan
bool isnan(float f)
Definition:
math.h:69
edm::equal_isnan
bool equal_isnan(FP x)
Definition:
math.h:61
EXTRACT_WORDS
#define EXTRACT_WORDS(ix0, ix1, d)
Definition:
math_private.h:66
edm::detail::isnan
bool isnan(float x)
Definition:
math.h:13
GET_FLOAT_WORD
#define GET_FLOAT_WORD(i, d)
Definition:
math_private.h:58
ztail.d
d
Definition:
ztail.py:151
HLT_2018_cff.flags
flags
Definition:
HLT_2018_cff.py:11758
edm::asm_isnan
bool asm_isnan(FP x)
Definition:
math.h:43
GET_LDOUBLE_WORDS
#define GET_LDOUBLE_WORDS(exp, ix0, ix1, d)
Definition:
math_private.h:75
Generated for CMSSW Reference Manual by
1.8.16