IMP  2.2.1
The Integrative Modeling Platform
base/math.h
Go to the documentation of this file.
1 /**
2  * \file IMP/base/math.h
3  * \brief Declare an efficient stl-compatible map
4  *
5  * Copyright 2007-2014 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPBASE_BASE_MATH_H
9 #define IMPBASE_BASE_MATH_H
10 
11 #include <IMP/base/base_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 IMPBASE_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 IMPBASE_END_NAMESPACE
45 
46 #endif /* IMPBASE_BASE_MATH_H */
bool isinf(const T &a)
Return true if a number is infinite.
Definition: base/math.h:35
bool isnan(const T &a)
Return true if a number is NaN.
Definition: base/math.h:24