HOPS
HOPS class reference
MHO_CheckForNaN.hh
Go to the documentation of this file.
1 #ifndef MHO_CheckForNaN_HH__
2 #define MHO_CheckForNaN_HH__
3 
12 #include <cmath>
13 #include <complex>
14 
15 namespace hops
16 {
17 
21 template< typename XNumericalType > class MHO_CheckForNaN
22 {
23  public:
25  virtual ~MHO_CheckForNaN();
26 
34  static bool isnan(XNumericalType value) { return value != value; }
35 
36  private:
37 };
38 
39 //overloads for numerical types
40 
47 template<> inline bool MHO_CheckForNaN< float >::isnan(float value)
48 {
49  return std::isnan(value);
50 }
51 
58 template<> inline bool MHO_CheckForNaN< double >::isnan(double value)
59 {
60  return std::isnan(value);
61 }
62 
69 template<> inline bool MHO_CheckForNaN< long double >::isnan(long double value)
70 {
71  return std::isnan(value);
72 }
73 
80 template<> inline bool MHO_CheckForNaN< std::complex< float > >::isnan(std::complex< float > value)
81 {
82  return std::isnan(value.real()) || std::isnan(value.imag());
83 }
84 
91 template<> inline bool MHO_CheckForNaN< std::complex< double > >::isnan(std::complex< double > value)
92 {
93  return std::isnan(value.real()) || std::isnan(value.imag());
94 }
95 
102 template<> inline bool MHO_CheckForNaN< std::complex< long double > >::isnan(std::complex< long double > value)
103 {
104  return std::isnan(value.real()) || std::isnan(value.imag());
105 }
106 
107 } // namespace hops
108 
109 #endif
checks if a value is NaN for various numerical types
Class MHO_CheckForNaN.
Definition: MHO_CheckForNaN.hh:22
virtual ~MHO_CheckForNaN()
static bool isnan(XNumericalType value)
Checks if a numerical value is NaN by comparing it to itself. note that this primitive (X !...
Definition: MHO_CheckForNaN.hh:34
Definition: MHO_AdhocFlagging.hh:18
Definition: vex.h:175