IMP logo
IMP Reference Guide  2.6.1
The Integrative Modeling Platform
math.h
Go to the documentation of this file.
1 /**
2  * \file IMP/math.h
3  * \brief Declare an efficient stl-compatible map
4  *
5  * Copyright 2007-2016 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 */
bool isnan(const T &a)
Return true if a number is NaN.
Definition: math.h:24
bool isinf(const T &a)
Return true if a number is infinite.
Definition: math.h:35