diff options
Diffstat (limited to 'boost/math/policies/error_handling.hpp')
-rw-r--r-- | boost/math/policies/error_handling.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/boost/math/policies/error_handling.hpp b/boost/math/policies/error_handling.hpp index 8e1b96d6f5..d4306c6006 100644 --- a/boost/math/policies/error_handling.hpp +++ b/boost/math/policies/error_handling.hpp @@ -12,6 +12,7 @@ #include <iomanip> #include <string> #include <cerrno> +#include <complex> #include <boost/config/no_tr1/cmath.hpp> #include <stdexcept> #include <boost/math/tools/config.hpp> @@ -576,6 +577,15 @@ inline bool check_overflow(T val, R* result, const char* function, const Policy& return false; } template <class R, class T, class Policy> +inline bool check_overflow(std::complex<T> val, R* result, const char* function, const Policy& pol) +{ + typedef typename R::value_type r_type; + r_type re, im; + bool r = check_overflow<r_type>(val.real(), &re, function, pol) || check_overflow<r_type>(val.imag(), &im, function, pol); + *result = R(re, im); + return r; +} +template <class R, class T, class Policy> inline bool check_underflow(T val, R* result, const char* function, const Policy& pol) { if((val != 0) && (static_cast<R>(val) == 0)) @@ -586,6 +596,15 @@ inline bool check_underflow(T val, R* result, const char* function, const Policy return false; } template <class R, class T, class Policy> +inline bool check_underflow(std::complex<T> val, R* result, const char* function, const Policy& pol) +{ + typedef typename R::value_type r_type; + r_type re, im; + bool r = check_underflow<r_type>(val.real(), &re, function, pol) || check_underflow<r_type>(val.imag(), &im, function, pol); + *result = R(re, im); + return r; +} +template <class R, class T, class Policy> inline bool check_denorm(T val, R* result, const char* function, const Policy& pol) { BOOST_MATH_STD_USING @@ -596,14 +615,29 @@ inline bool check_denorm(T val, R* result, const char* function, const Policy& p } return false; } +template <class R, class T, class Policy> +inline bool check_denorm(std::complex<T> val, R* result, const char* function, const Policy& pol) +{ + typedef typename R::value_type r_type; + r_type re, im; + bool r = check_denorm<r_type>(val.real(), &re, function, pol) || check_denorm<r_type>(val.imag(), &im, function, pol); + *result = R(re, im); + return r; +} // Default instantiations with ignore_error policy. template <class R, class T> inline bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&){ return false; } template <class R, class T> +inline bool check_overflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&){ return false; } +template <class R, class T> inline bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&){ return false; } template <class R, class T> +inline bool check_underflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&){ return false; } +template <class R, class T> inline bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&){ return false; } +template <class R, class T> +inline bool check_denorm(std::complex<T> /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&){ return false; } } // namespace detail |