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 
27 
35  static bool isnan(const XNumericalType& value) { return value != value; }
36 
37  private:
38 };
39 
40 //overloads for numerical types
41 
48 template<> inline bool MHO_CheckForNaN< float >::isnan(const float& value)
49 {
50  return std::isnan(value);
51 }
52 
59 template<> inline bool MHO_CheckForNaN< double >::isnan(const double& value)
60 {
61  return std::isnan(value);
62 }
63 
70 template<> inline bool MHO_CheckForNaN< long double >::isnan(const long double& value)
71 {
72  return std::isnan(value);
73 }
74 
81 template<> inline bool MHO_CheckForNaN< std::complex< float > >::isnan(const std::complex< float >& value)
82 {
83  return std::isnan(value.real()) || std::isnan(value.imag());
84 }
85 
92 template<> inline bool MHO_CheckForNaN< std::complex< double > >::isnan(const std::complex< double >& value)
93 {
94  return std::isnan(value.real()) || std::isnan(value.imag());
95 }
96 
103 template<> inline bool MHO_CheckForNaN< std::complex< long double > >::isnan(const std::complex< long double >& value)
104 {
105  return std::isnan(value.real()) || std::isnan(value.imag());
106 }
107 
108 
109 }//end of namespace
110 
111 #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(const XNumericalType &value)
Checks if a numerical value is NaN by comparing it to itself. note that this primitive (X !...
Definition: MHO_CheckForNaN.hh:35
Definition: MHO_ChannelLabeler.hh:17
Definition: vex.h:175