#include <base/config.h>
+#include <complex>
DEAL_II_NAMESPACE_OPEN
*/
static const double SQRT1_2 = 0.70710678118654752440;
- /**
- * 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).
+ /**
+ * 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).
*
* Note that the argument type of
* this function is
* number is finite with respect
* to type <code>long
* double</code>.
- */
+ */
bool is_finite (const double x);
+
+ /**
+ * Return @p true if real and
+ * imaginary parts of the given
+ * complex number are finite.
+ */
+ bool is_finite (const std::complex<double> x);
+
+ /**
+ * Return @p true if real and
+ * imaginary parts of the given
+ * complex number are finite.
+ *
+ * Again may not work correctly if
+ * real or imaginary parts are very
+ * large numbers that are infinite in
+ * terms of <code>double</code>, but
+ * finite with respect to
+ * <code>long double</code>.
+ */
+ bool is_finite (const std::complex<long double> x);
}
DEAL_II_NAMESPACE_CLOSE
#include <base/config.h>
#include <cmath>
#include <limits>
+#include <complex>
DEAL_II_NAMESPACE_OPEN
#ifdef DEAL_II_HAVE_ISFINITE
return std::isfinite (x);
#else
- // check against infinities. not
+ // 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<long double> x)
+ {
+ // Same for std::complex<long double>
+ return ( is_finite (x.real())
+ &&
+ is_finite (x.imag()) );
+ }
}
DEAL_II_NAMESPACE_CLOSE
Assert (deal_II_numbers::is_finite(s),
ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
- if (s != 0.)
+ if (s != Number())
Assert (vec_size!=0, ExcEmptyObject());
if (vec_size!=0)
std::fill (begin(), end(), s);