*/
static const double SQRT1_2 = 0.70710678118654752440;
+ /**
+ * Check whether a value is not a number.
+ *
+ * This function uses either <code>std::isnan</code>,
+ * <code>isnan</code>, or <code>_isnan</code>, whichever is
+ * available on the system and returns the result.
+ *
+ * If none of the functions detecting NaN is available, this
+ * function returns false.
+ */
+ bool is_nan (const double x);
+
/**
* Return @p true if the given value is a finite floating point number, i.e.
* is neither plus or minus infinity nor NaN (not a number).
real_type abs (const std::complex<number> &x);
};
-}
+ // --------------- inline and template functions ---------------- //
+ inline bool is_nan (const double x)
+ {
+#ifdef DEAL_II_HAVE_STD_ISNAN
+ return std::isnan(x);
+#elif defined(DEAL_II_HAVE_ISNAN)
+ return isnan(x);
+#elif defined(DEAL_II_HAVE_UNDERSCORE_ISNAN)
+ return _isnan(x);
+#else
+ return false;
+#endif
+ }
+
+ inline bool is_finite (const double x)
+ {
+#ifdef DEAL_II_HAVE_ISFINITE
+ return !is_nan(x) && std::isfinite (x);
+#else
+ // Check against infinities. Note
+ // that if x is a NaN, then both
+ // comparisons will be false
+ return ((x >= -std::numeric_limits<double>::max())
+ &&
+ (x <= std::numeric_limits<double>::max()));
+#endif
+ }
+
+
+
+ inline bool is_finite (const std::complex<double> &x)
+ {
+ // Check complex numbers for infinity
+ // by testing real and imaginary part
+ return ( is_finite (x.real())
+ &&
+ is_finite (x.imag()) );
+ }
+
+
+
+ inline bool is_finite (const std::complex<float> &x)
+ {
+ // Check complex numbers for infinity
+ // by testing real and imaginary part
+ return ( is_finite (x.real())
+ &&
+ is_finite (x.imag()) );
+ }
+
+
+
+ inline bool is_finite (const std::complex<long double> &x)
+ {
+ // Same for std::complex<long double>
+ return ( is_finite (x.real())
+ &&
+ is_finite (x.imag()) );
+ }
-// --------------- inline and template functions ---------------- //
-namespace numbers
-{
template <typename number>
const number &
NumberTraits<number>::conjugate (const number &x)
namespace numbers
{
- bool is_finite (const double x)
- {
-#ifdef DEAL_II_HAVE_ISFINITE
- return !std::isnan(x) && std::isfinite (x);
-#else
- // Check against infinities. Note
- // that if x is a NaN, then both
- // comparisons will be false
- return ((x >= -std::numeric_limits<double>::max())
- &&
- (x <= std::numeric_limits<double>::max()));
-#endif
- }
-
-
-
- bool is_finite (const std::complex<double> &x)
- {
- // Check complex numbers for infinity
- // by testing real and imaginary part
- return ( is_finite (x.real())
- &&
- is_finite (x.imag()) );
- }
-
-
-
- bool is_finite (const std::complex<float> &x)
- {
- // Check complex numbers for infinity
- // by testing real and imaginary part
- return ( is_finite (x.real())
- &&
- is_finite (x.imag()) );
- }
-
-
-
- bool is_finite (const std::complex<long double> &x)
- {
- // Same for std::complex<long double>
- return ( is_finite (x.real())
- &&
- is_finite (x.imag()) );
- }
-
-
template <typename number>
const bool NumberTraits<number>::is_complex;