Skip to content

Commit

Permalink
Clarify use of boost::float128_type
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed Dec 31, 2024
1 parent d241147 commit 1891aaf
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 54 deletions.
11 changes: 11 additions & 0 deletions include/boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
#define BOOST_MP_CPP_DF_QF_DETAIL_2023_01_02_HPP

#include <boost/config.hpp>

#ifdef BOOST_HAS_FLOAT128
# if __has_include(<quadmath.h>)
# include <quadmath.h>
# ifndef BOOST_MP_HAS_FLOAT128_SUPPORT
# define BOOST_MP_HAS_FLOAT128_SUPPORT
# endif
# endif
#endif

#include <boost/multiprecision/number.hpp>
#include <boost/multiprecision/detail/float128_functions.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath.hpp>

#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#include <boost/config.hpp>

#ifdef BOOST_HAS_FLOAT128
#include <quadmath.h>
#endif

#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fabs.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_floor.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fma.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_

namespace detail {

#if defined(BOOST_HAS_FLOAT128)
template <class T>
auto floor_impl(T x) -> typename ::std::enable_if<::std::is_same<T, ::boost::float128_type>::value, T>::type
{
return ::floorq(x);
}
#endif

template <class T>
auto floor_impl(T x) -> typename ::std::enable_if<::std::is_floating_point<T>::value, T>::type
auto floor_impl(T x) -> T
{
// Default to the regular std::floor function.
using std::floor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace detail {
template <class T>
auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same<T, ::boost::float128_type>::value, T>::type
{
return ::fmaq(x);
return ::fmaq(x, y, z);
}
#endif

Expand All @@ -45,11 +45,12 @@ auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_sam
}
#else
template <class T>
auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_floating_point<T>::value, T>::type
auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same<T, float>::value || ::std::is_same<T, double>::value || ::std::is_same<T, long double>::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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {

template <typename T>
constexpr auto fpclassify(T x) -> typename std::enable_if<!std::is_integral<T>::value, int>::type
constexpr auto fpclassify(T x) -> int
{
if ((::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::isnan)(x))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_
namespace detail
{

#if defined(BOOST_HAS_FLOAT128)
template <class T>
auto frexp_impl(T arg, int* expptr) -> typename ::std::enable_if<::std::is_same<T, ::boost::float128_type>::value, T>::type
{
return ::frexpq(arg, expptr);
}
#endif

template <class T>
auto frexp_impl(T arg, int* expptr) -> typename ::std::enable_if<::std::is_floating_point<T>::value, T>::type
auto frexp_impl(T arg, int* expptr) -> T
{
// Default to the regular std::frexp function.
using std::frexp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_

namespace detail {

#if defined(BOOST_HAS_FLOAT128)
template <class T>
auto ldexp_impl(T arg, int expval) -> typename ::std::enable_if<::std::is_same<T, ::boost::float128_type>::value, T>::type
{
return ::ldexpq(arg, expval);
}
#endif

template <class T>
auto ldexp_impl(T arg, int expval) -> typename ::std::enable_if<::std::is_floating_point<T>::value, T>::type
auto ldexp_impl(T arg, int expval) -> T
{
// Default to the regular std::ldexp function.
using std::ldexp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_

namespace detail {

#if defined(BOOST_HAS_FLOAT128)
template <class T>
auto log_impl(T x) -> typename ::std::enable_if<::std::is_same<T, ::boost::float128_type>::value, T>::type
{
return ::logq(x);
}
#endif

template <class T>
auto log_impl(T x) -> typename ::std::enable_if<::std::is_floating_point<T>::value, T>::type
auto log_impl(T x) -> T
{
// Default to the regular std::log function.
using std::log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@ namespace boost { namespace multiprecision { namespace backends { namespace cpp_

namespace detail {

#if defined(BOOST_HAS_FLOAT128)
template <class T>
auto sqrt_impl(T x) -> typename ::std::enable_if<::std::is_same<T, ::boost::float128_type>::value, T>::type
{
return ::sqrtq(x);
}
#endif

template <class T>
auto sqrt_impl(T x) -> typename ::std::enable_if<::std::is_floating_point<T>::value, T>::type
auto sqrt_impl(T x) -> T
{
// Default to the regular std::sqrt function.
using std::sqrt;
Expand Down

0 comments on commit 1891aaf

Please sign in to comment.