Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/math/special_functions/sign.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/math/special_functions/sign.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/math/special_functions/sign.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -31,7 +31,10 @@ } #endif - template<class T> + // Generic versions first, note that these do not handle + // signed zero or NaN. + + template<class T> inline int signbit_impl(T x, generic_tag<true> const&) { return x < 0; @@ -43,7 +46,25 @@ return x < 0; } - template<class T> +#if defined(__GNUC__) && (LDBL_MANT_DIG == 106) + // + // Special handling for GCC's "double double" type, + // in this case the sign is the same as the sign we + // get by casting to double, no overflow/underflow + // can occur since the exponents are the same magnitude + // for the two types: + // + inline int signbit_impl(long double x, generic_tag<true> const&) + { + return (boost::math::signbit)(static_cast<double>(x)); + } + inline int signbit_impl(long double x, generic_tag<false> const&) + { + return (boost::math::signbit)(static_cast<double>(x)); + } +#endif + + template<class T> inline int signbit_impl(T x, ieee_copy_all_bits_tag const&) { typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits; @@ -65,6 +86,9 @@ } // Changesign + + // Generic versions first, note that these do not handle + // signed zero or NaN. template<class T> inline T (changesign_impl)(T x, generic_tag<true> const&) @@ -77,7 +101,27 @@ { return -x; } - +#if defined(__GNUC__) && (LDBL_MANT_DIG == 106) + // + // Special handling for GCC's "double double" type, + // in this case we need to change the sign of both + // components of the "double double": + // + inline long double (changesign_impl)(long double x, generic_tag<true> const&) + { + double* pd = reinterpret_cast<double*>(&x); + pd[0] = boost::math::changesign(pd[0]); + pd[1] = boost::math::changesign(pd[1]); + return x; + } + inline long double (changesign_impl)(long double x, generic_tag<false> const&) + { + double* pd = reinterpret_cast<double*>(&x); + pd[0] = boost::math::changesign(pd[0]); + pd[1] = boost::math::changesign(pd[1]); + return x; + } +#endif template<class T> inline T changesign_impl(T x, ieee_copy_all_bits_tag const&)