Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify use of boost::float128_type #170

Merged
merged 4 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023.
// Copyright Christopher Kormanyos 2023 - 2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ 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
auto floor_impl(T x) -> T
{
return ::floorq(x);
}
#endif

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

return floor(x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,32 @@ namespace unsafe {

namespace detail {

#if defined(BOOST_HAS_FLOAT128)
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
inline auto fma_impl(T x, T y, T z) noexcept -> T
{
return ::fmaq(x);
// Default to the written-out operations.

return (x * y) + z;
}
#endif

#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
template <class T>
auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same<T, float>::value, T>::type
template <>
inline auto fma_impl<float>(float x, float y, float z) noexcept -> float
{
return __builtin_fmaf(x, y, z);
}

template <class T>
auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same<T, double>::value, T>::type
template <>
inline auto fma_impl<double>(double x, double y, double z) noexcept -> double
{
return __builtin_fma(x, y, z);
}

template <class T>
auto fma_impl(T x, T y, T z) noexcept -> typename ::std::enable_if<::std::is_same<T, long double>::value, T>::type
template <>
inline auto fma_impl<long double>(long double x, long double y, long double z) noexcept -> long double
{
return __builtin_fmal(x, y, z);
}
#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
{
// Default to the written-out operations.

return (x * y) + z;
}
#endif

} // namespace detail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_isnan.hpp>

#include <cmath>
#include <type_traits>

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 All @@ -36,7 +35,7 @@ constexpr auto fpclassify(T x) -> typename std::enable_if<!std::is_integral<T>::
{
return FP_ZERO;
}
else if ((fabs_x > 0) && (fabs_x < (boost::multiprecision::backends::cpp_df_qf_detail::ccmath::numeric_limits<T>::min)()))
else if ((fabs_x > 0) && (fabs_x < (::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::numeric_limits<T>::min)()))
{
return FP_SUBNORMAL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@ 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
auto frexp_impl(T arg, int* expptr) -> T
{
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
{
// Default to the regular std::frexp function.
// Default to the regular frexp function.
using std::frexp;

return frexp(arg, expptr);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023.
// Copyright Christopher Kormanyos 2023 - 2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023.
// Copyright Christopher Kormanyos 2023 - 2024.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ 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
auto ldexp_impl(T arg, int expval) -> T
{
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
{
// Default to the regular std::ldexp function.
// Default to the regular ldexp function.
using std::ldexp;

return ldexp(arg, expval);
Expand Down
Loading