From 1891aaf46836999d0bd154554d9eb201fae925df Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Tue, 31 Dec 2024 04:26:14 +0100 Subject: [PATCH] Clarify use of boost::float128_type --- .../multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp | 11 +++++++++++ .../cpp_df_qf/cpp_df_qf_detail_ccmath.hpp | 4 ---- .../cpp_df_qf/cpp_df_qf_detail_ccmath_floor.hpp | 10 +--------- .../cpp_df_qf/cpp_df_qf_detail_ccmath_fma.hpp | 9 +++++---- .../cpp_df_qf/cpp_df_qf_detail_ccmath_fpclassify.hpp | 2 +- .../cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp | 10 +--------- .../cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp | 10 +--------- .../cpp_df_qf/cpp_df_qf_detail_ccmath_log.hpp | 10 +--------- .../cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp | 10 +--------- 9 files changed, 22 insertions(+), 54 deletions(-) diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp index 919d78d2c..9530d4db9 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp @@ -11,7 +11,18 @@ #define BOOST_MP_CPP_DF_QF_DETAIL_2023_01_02_HPP #include + +#ifdef BOOST_HAS_FLOAT128 +# if __has_include() +# include +# ifndef BOOST_MP_HAS_FLOAT128_SUPPORT +# define BOOST_MP_HAS_FLOAT128_SUPPORT +# endif +# endif +#endif + #include +#include #include #include diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath.hpp index b1c5b4454..74f893a1f 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath.hpp @@ -10,10 +10,6 @@ #include -#ifdef BOOST_HAS_FLOAT128 -#include -#endif - #include #include #include diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_floor.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_floor.hpp index ea177c495..6c01d91bd 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_floor.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_floor.hpp @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_ namespace detail { -#if defined(BOOST_HAS_FLOAT128) template -auto floor_impl(T x) -> typename ::std::enable_if<::std::is_same::value, T>::type -{ - return ::floorq(x); -} -#endif - -template -auto floor_impl(T x) -> typename ::std::enable_if<::std::is_floating_point::value, T>::type +auto floor_impl(T x) -> T { // Default to the regular std::floor function. using std::floor; diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fma.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fma.hpp index 33bb164c9..478a45e6f 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fma.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fma.hpp @@ -21,7 +21,7 @@ namespace detail { template auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same::value, T>::type { - return ::fmaq(x); + return ::fmaq(x, y, z); } #endif @@ -45,11 +45,12 @@ auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_sam } #else template -auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_floating_point::value, T>::type +auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same::value || ::std::is_same::value || ::std::is_same::value, T>::type { - // Default to the written-out operations. + // Default to the written-out operations. + using std::fma; - return (x * y) + z; + return fma(x, y, z); } #endif diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fpclassify.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fpclassify.hpp index cb648f40f..a2318788a 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fpclassify.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fpclassify.hpp @@ -18,7 +18,7 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath { template -constexpr auto fpclassify(T x) -> typename std::enable_if::value, int>::type +constexpr auto fpclassify(T x) -> int { if ((::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::isnan)(x)) { diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp index 92d9f8bca..aae8a8d2c 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp @@ -16,16 +16,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_ namespace detail { -#if defined(BOOST_HAS_FLOAT128) template -auto frexp_impl(T arg, int* expptr) -> typename ::std::enable_if<::std::is_same::value, T>::type -{ - return ::frexpq(arg, expptr); -} -#endif - -template -auto frexp_impl(T arg, int* expptr) -> typename ::std::enable_if<::std::is_floating_point::value, T>::type +auto frexp_impl(T arg, int* expptr) -> T { // Default to the regular std::frexp function. using std::frexp; diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp index 317d6a9ea..563393b71 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_ namespace detail { -#if defined(BOOST_HAS_FLOAT128) template -auto ldexp_impl(T arg, int expval) -> typename ::std::enable_if<::std::is_same::value, T>::type -{ - return ::ldexpq(arg, expval); -} -#endif - -template -auto ldexp_impl(T arg, int expval) -> typename ::std::enable_if<::std::is_floating_point::value, T>::type +auto ldexp_impl(T arg, int expval) -> T { // Default to the regular std::ldexp function. using std::ldexp; diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_log.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_log.hpp index 20c5f4c02..da914a085 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_log.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_log.hpp @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_ namespace detail { -#if defined(BOOST_HAS_FLOAT128) template -auto log_impl(T x) -> typename ::std::enable_if<::std::is_same::value, T>::type -{ - return ::logq(x); -} -#endif - -template -auto log_impl(T x) -> typename ::std::enable_if<::std::is_floating_point::value, T>::type +auto log_impl(T x) -> T { // Default to the regular std::log function. using std::log; diff --git a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp index 6e1fd7fb3..7f56f4cf7 100644 --- a/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp +++ b/include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_ namespace detail { -#if defined(BOOST_HAS_FLOAT128) template -auto sqrt_impl(T x) -> typename ::std::enable_if<::std::is_same::value, T>::type -{ - return ::sqrtq(x); -} -#endif - -template -auto sqrt_impl(T x) -> typename ::std::enable_if<::std::is_floating_point::value, T>::type +auto sqrt_impl(T x) -> T { // Default to the regular std::sqrt function. using std::sqrt;