home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
2.18.0
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
Modules
Classes
Examples
include
IMP
version 2.18.0
math.h
Go to the documentation of this file.
1
/**
2
* \file IMP/math.h
3
* \brief Helper functions to check for NaN or infinity
4
*
5
* Copyright 2007-2022 IMP Inventors. All rights reserved.
6
*/
7
8
#ifndef IMPKERNEL_BASE_MATH_H
9
#define IMPKERNEL_BASE_MATH_H
10
11
#include <IMP/kernel_config.h>
12
#include <boost/version.hpp>
13
#include <cmath>
14
#if !defined(_GLIBCXX_USE_C99_MATH)
15
#include <boost/math/special_functions/fpclassify.hpp>
16
#endif
17
18
IMPKERNEL_BEGIN_NAMESPACE
19
//! Return true if a number is NaN
20
/** With certain compiler settings the compiler can optimize
21
out a!=a (and certain Intel chips had issues with it too).
22
*/
23
template
<
class
T>
24
inline
bool
isnan
(
const
T& a) {
25
#if defined(_GLIBCXX_USE_C99_MATH)
26
// Not all gcc versions include C99 math
27
return
(
std::isnan
)(a);
28
#else
29
return
(
boost::math::isnan
)(a);
30
#endif
31
}
32
33
//! Return true if a number is infinite
34
template
<
class
T>
35
inline
bool
isinf
(
const
T& a) {
36
#if defined(_GLIBCXX_USE_C99_MATH)
37
// Not all gcc versions include C99 math
38
return
(
std::isinf
)(a);
39
#else
40
return
(
boost::math::isinf
)(a);
41
#endif
42
}
43
44
IMPKERNEL_END_NAMESPACE
45
46
#endif
/* IMPKERNEL_BASE_MATH_H */
IMP::isnan
bool isnan(const T &a)
Return true if a number is NaN.
Definition:
math.h:24
IMP::isinf
bool isinf(const T &a)
Return true if a number is infinite.
Definition:
math.h:35