Updated boost multiprecision, and disabled deprecated declarations warning

This commit is contained in:
Yousef Khadadeh 2025-10-03 13:44:19 +03:00
parent 9f739ada6a
commit 6bc7069099
31 changed files with 3656 additions and 83 deletions

View file

@ -0,0 +1,169 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright 2021 Fahad Syed.
// Copyright 2021 - 2025 Christopher Kormanyos.
// Copyright 2021 Janek Kozicki.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_2023_01_02_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_2023_01_02_HPP
#include <boost/multiprecision/detail/standalone_config.hpp>
#if defined(BOOST_HAS_FLOAT128)
#if defined(__has_include)
#if __has_include(<quadmath.h>)
#include <quadmath.h>
#if !defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
#define BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128
#endif
#endif // __has_include(<quadmath.h>)
#endif // defined(__has_include)
#endif // defined(BOOST_HAS_FLOAT128)
#include <boost/multiprecision/number.hpp>
#include <boost/multiprecision/detail/float128_functions.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath.hpp>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail {
template <class FloatingPointTypeA, class FloatingPointTypeB>
struct pair
{
static_assert(std::is_same<FloatingPointTypeA, FloatingPointTypeB>::value, "Error: floating point types A and B must be identical");
using float_type = FloatingPointTypeA;
float_type first;
float_type second;
constexpr pair() : first { }, second { } { };
constexpr pair(float_type a, float_type b) : first { a }, second { b } { }
constexpr pair(const pair& other) : first { other.first }, second { other.second } { }
constexpr pair(pair&& other) noexcept : first { other.first }, second { other.second } { }
constexpr auto operator=(const pair& other) -> pair&
{
if (this != &other)
{
first = other.first;
second = other.second;
}
return *this;
}
constexpr auto operator=(pair&& other) noexcept -> pair&
{
first = other.first;
second = other.second;
return *this;
}
};
template <class FloatingPointType>
struct is_floating_point
{
static constexpr auto value = ::std::is_same<FloatingPointType, float>::value
|| ::std::is_same<FloatingPointType, double>::value
|| ::std::is_same<FloatingPointType, long double>::value
#if defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
|| ::std::is_same<FloatingPointType, ::boost::float128_type>::value
#endif
;
};
template <typename FloatType>
struct split_maker
{
private:
using float_type = FloatType;
public:
static constexpr int
n_shl
{
static_cast<int>((ccmath::numeric_limits<float_type>::digits + 1) / 2)
};
static_assert(n_shl < std::numeric_limits<std::uint64_t>::digits,
"Error: Left-shift amount for split does not fin in std::uint64_t");
static constexpr float_type
value
{
static_cast<float_type>
(
std::uint64_t
{
UINT64_C(1)
+ std::uint64_t { UINT64_C(1) << static_cast<unsigned>(n_shl) }
}
)
};
};
template <typename FloatingPointType>
struct exact_arithmetic
{
// The exact_arithmetic<> struct implements a few extended
// precision algorithms that are used in cpp_double_fp_backend.
static_assert(is_floating_point<FloatingPointType>::value, "Error: exact_arithmetic<> invoked with unknown floating-point type");
using float_type = FloatingPointType;
using float_pair = pair<float_type, float_type>;
static constexpr auto two_sum(const float_type a, const float_type b) -> float_pair
{
const float_type hi { a + b };
const float_type a1 { hi - b };
return { hi, float_type { (a - a1) + (b - float_type { hi - a1 }) } };
}
static constexpr auto two_diff(const float_type a, const float_type b) -> float_pair
{
const float_type hi { a - b };
const float_type a1 { hi + b };
return { hi, float_type { (a - a1) - (b + float_type { hi - a1 }) } };
}
static constexpr auto two_hilo_sum(const float_type a, const float_type b) -> float_pair
{
const float_type hi { a + b };
return { hi, float_type { b - (hi - a) } };
}
static constexpr auto normalize(float_type a, float_type b) -> float_pair
{
const float_type u { a + b };
return
{
u,
float_type { a - u } + b
};
}
};
template<typename ArithmeticType>
struct pow2_maker
{
static constexpr auto value(const int power_value) noexcept -> ArithmeticType
{
return ((power_value == 0) ? ArithmeticType { 1 } : ArithmeticType { 2 } * pow2_maker<ArithmeticType>::value(power_value - 1));
}
};
} } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail
#endif // BOOST_MP_CPP_DF_QF_DETAIL_2023_01_02_HPP

View file

@ -0,0 +1,25 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_2023_01_07_HPP
#include <boost/config.hpp>
#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>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fpclassify.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_frexp.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_isinf.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_isnan.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_ldexp.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_limits.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_log.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_sqrt.hpp>
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_2023_01_07_HPP

View file

@ -0,0 +1,27 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FABS_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FABS_2023_01_07_HPP
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_isnan.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_limits.hpp>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
template <class Real>
constexpr auto fabs(Real x) -> Real
{
return (cpp_df_qf_detail::ccmath::isnan(x)) ? cpp_df_qf_detail::ccmath::numeric_limits<Real>::quiet_NaN()
: (x == static_cast<Real>(-0)) ? static_cast<Real>(0)
: (x >= 0) ? x
: -x;
};
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FABS_2023_01_07_HPP

View file

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FLOOR_2024_12_30_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FLOOR_2024_12_30_HPP
#include <cmath>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
namespace detail {
template <class T>
constexpr auto floor_impl(T x) -> T
{
// Default to the regular floor function.
using std::floor;
return floor(x);
}
} // namespace detail
template <typename Real>
constexpr auto floor(Real x) -> Real
{
return cpp_df_qf_detail::ccmath::detail::floor_impl<Real>(x);
}
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FLOOR_2024_12_30_HPP

View file

@ -0,0 +1,61 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FMA_2024_12_17_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FMA_2024_12_17_HPP
#include <cmath>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
namespace unsafe {
namespace detail {
template <class T>
constexpr auto fma_impl(T x, T y, T z) noexcept -> T
{
// Default to the written-out operations ...
// ... and hope the compiler chooses FMA if available).
return (x * y) + z;
}
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
template <>
constexpr auto fma_impl<float>(float x, float y, float z) noexcept -> float
{
return __builtin_fmaf(x, y, z);
}
template <>
constexpr auto fma_impl<double>(double x, double y, double z) noexcept -> double
{
return __builtin_fma(x, y, z);
}
template <>
constexpr auto fma_impl<long double>(long double x, long double y, long double z) noexcept -> long double
{
return __builtin_fmal(x, y, z);
}
#endif
} // namespace detail
template <typename Real>
constexpr auto fma(Real x, Real y, Real z) noexcept -> Real
{
return detail::fma_impl(x, y, z);
}
} // namespace unsafe
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FMA_2024_12_17_HPP

View file

@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FPCLASSIFY_2024_12_26_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FPCLASSIFY_2024_12_26_HPP
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_fabs.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_isinf.hpp>
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_isnan.hpp>
#include <cmath>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
template <typename T>
constexpr auto fpclassify(T x) -> int
{
if ((::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::isnan)(x))
{
return FP_NAN;
}
else if ((::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::isinf)(x))
{
return FP_INFINITE;
}
else
{
const T fabs_x { ::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::fabs(x) };
if (fabs_x == T(0))
{
return FP_ZERO;
}
else if ((fabs_x > 0) && (fabs_x < (::boost::multiprecision::backends::cpp_df_qf_detail::ccmath::numeric_limits<T>::min)()))
{
return FP_SUBNORMAL;
}
else
{
return FP_NORMAL;
}
}
}
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FPCLASSIFY_2024_12_26_HPP

View file

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FREXP_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FREXP_2023_01_07_HPP
#include <cmath>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
namespace detail
{
template <class T>
constexpr auto frexp_impl(T arg, int* expptr) -> T
{
// Default to the regular frexp function.
using std::frexp;
return frexp(arg, expptr);
}
} // namespace detail
template <typename Real>
constexpr auto frexp(Real arg, int* expptr) -> Real
{
return detail::frexp_impl(arg, expptr);
}
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_FREXP_2023_01_07_HPP

View file

@ -0,0 +1,24 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_ISINF_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_ISINF_2023_01_07_HPP
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail_ccmath_limits.hpp>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
template <typename FloatingPointType>
constexpr auto isinf(FloatingPointType x) noexcept -> bool
{
return ( ( x == cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::infinity())
|| (-x == cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::infinity()));
}
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_ISINF_2023_01_07_HPP

View file

@ -0,0 +1,21 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_ISNAN_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_ISNAN_2023_01_07_HPP
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
template <class FloatingPointType>
constexpr auto isnan(FloatingPointType x) -> bool
{
return (x != x);
}
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_ISNAN_2023_01_07_HPP

View file

@ -0,0 +1,58 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LDEXP_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LDEXP_2023_01_07_HPP
#include <cmath>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
namespace detail {
template <class T>
constexpr auto ldexp_impl(T arg, int expval) -> T
{
// Default to the regular ldexp function.
using std::ldexp;
return ldexp(arg, expval);
}
} // Namespace detail
template <typename Real>
constexpr auto ldexp(Real arg, int expval) -> Real
{
return detail::ldexp_impl(arg, expval);
}
namespace unsafe {
template <typename Real>
constexpr auto ldexp(Real arg, int exp) noexcept -> Real
{
while(exp > 0)
{
arg *= 2;
--exp;
}
while(exp < 0)
{
arg /= 2;
++exp;
}
return arg;
}
} // namespace unsafe
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LDEXP_2023_01_07_HPP

View file

@ -0,0 +1,194 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LIMITS_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LIMITS_2023_01_07_HPP
#include <cfloat>
#include <cmath>
#include <limits>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
template <class FloatingPointType,
class EnableType = void>
struct numeric_limits
{
static constexpr bool is_specialized = false;
};
template <class FloatingPointType>
struct numeric_limits<FloatingPointType,
typename std::enable_if<( std::is_same<FloatingPointType, float>::value
|| std::is_same<FloatingPointType, double>::value
|| std::is_same<FloatingPointType, long double>::value)>::type>
{
private:
using float_type = FloatingPointType;
public:
static constexpr bool is_specialized = std::numeric_limits<float_type>::is_specialized;
static constexpr bool is_signed = std::numeric_limits<float_type>::is_signed;
static constexpr bool is_integer = std::numeric_limits<float_type>::is_integer;
static constexpr bool is_exact = std::numeric_limits<float_type>::is_exact;
static constexpr bool is_bounded = std::numeric_limits<float_type>::is_bounded;
static constexpr bool is_modulo = std::numeric_limits<float_type>::is_modulo;
static constexpr bool is_iec559 = std::numeric_limits<float_type>::is_iec559;
static constexpr std::float_denorm_style has_denorm = std::numeric_limits<float_type>::has_denorm;
static constexpr bool has_infinity = std::numeric_limits<float_type>::has_infinity;
static constexpr bool has_quiet_NaN = std::numeric_limits<float_type>::has_quiet_NaN;
static constexpr bool has_signaling_NaN = std::numeric_limits<float_type>::has_signaling_NaN;
static constexpr bool has_denorm_loss = std::numeric_limits<float_type>::has_denorm_loss;
static constexpr bool traps = std::numeric_limits<float_type>::traps;
static constexpr bool tinyness_before = std::numeric_limits<float_type>::tinyness_before;
static constexpr std::float_round_style round_style = std::numeric_limits<float_type>::round_style;
static constexpr int radix = std::numeric_limits<float_type>::radix;
static constexpr int digits = std::numeric_limits<float_type>::digits;
static constexpr int digits10 = std::numeric_limits<float_type>::digits10;
static constexpr int max_digits10 = std::numeric_limits<float_type>::max_digits10;
static constexpr int max_exponent = std::numeric_limits<float_type>::max_exponent;
static constexpr int min_exponent = std::numeric_limits<float_type>::min_exponent;
static constexpr int max_exponent10 = std::numeric_limits<float_type>::max_exponent10;
static constexpr int min_exponent10 = std::numeric_limits<float_type>::min_exponent10;
// LCOV_EXCL_START
static constexpr auto (min) () noexcept -> float_type { return (std::numeric_limits<float_type>::min) (); }
static constexpr auto (max) () noexcept -> float_type { return (std::numeric_limits<float_type>::max) (); }
static constexpr auto lowest () noexcept -> float_type { return std::numeric_limits<float_type>::lowest (); }
static constexpr auto epsilon () noexcept -> float_type { return std::numeric_limits<float_type>::epsilon (); }
static constexpr auto round_error () noexcept -> float_type { return std::numeric_limits<float_type>::round_error (); }
static constexpr auto denorm_min () noexcept -> float_type { return std::numeric_limits<float_type>::denorm_min (); }
static constexpr auto infinity () noexcept -> float_type { return std::numeric_limits<float_type>::infinity (); }
static constexpr auto quiet_NaN () noexcept -> float_type { return std::numeric_limits<float_type>::quiet_NaN (); }
static constexpr auto signaling_NaN() noexcept -> float_type { return std::numeric_limits<float_type>::signaling_NaN(); }
// LCOV_EXCL_STOP
};
#if defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
template <class FloatingPointType>
struct numeric_limits<FloatingPointType,
typename std::enable_if<std::is_same<FloatingPointType, ::boost::float128_type>::value>::type>
{
private:
using self_type = ::boost::float128_type;
public:
static constexpr bool is_specialized = true;
static constexpr bool is_signed = true;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr bool is_bounded = true;
static constexpr bool is_modulo = false;
static constexpr bool is_iec559 = true;
static constexpr std::float_denorm_style has_denorm = std::denorm_present;
static constexpr bool has_infinity = true;
static constexpr bool has_quiet_NaN = true;
static constexpr bool has_signaling_NaN = false;
static constexpr bool has_denorm_loss = true;
static constexpr bool traps = false;
static constexpr bool tinyness_before = false;
static constexpr std::float_round_style round_style = std::round_to_nearest;
static constexpr int radix = 2;
static constexpr int digits = 113;
static constexpr int digits10 = 33;
static constexpr int max_digits10 = 36;
static constexpr int max_exponent = 16384;
static constexpr int min_exponent = -16381;
static constexpr int max_exponent10 = static_cast<int>(static_cast<long long>(static_cast<long long>(max_exponent) * 301LL) / 1000LL);
static constexpr int min_exponent10 = static_cast<int>(static_cast<long long>(static_cast<long long>(min_exponent) * 301LL) / 1000LL);
static constexpr auto (min)() noexcept -> self_type
{
return static_cast<self_type>(1)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN) / 1073741824;
}
static constexpr auto (max)() noexcept -> self_type
{
// This has one bit set only.
constexpr double dbl_mult = 8.9884656743115795386e+307;
return (static_cast<self_type>(1) - 9.62964972193617926527988971292463659e-35) // This now has all bits sets to 1
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult)
* static_cast<self_type>(dbl_mult) * 65536;
}
static constexpr auto lowest() noexcept -> self_type { return -(max)(); }
static constexpr auto epsilon() -> self_type
{
// This double value has only one bit set and so is exact.
return 1.92592994438723585305597794258492732e-34;
}
static constexpr auto round_error() noexcept -> self_type { return static_cast<self_type>(0.5F); }
static constexpr auto denorm_min() noexcept -> self_type
{
return static_cast<self_type>(1)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
* static_cast<self_type>(DBL_MIN)
/ 5.5751862996326557854e+42;
}
static constexpr auto infinity () noexcept -> self_type { return HUGE_VAL; }
static constexpr auto quiet_NaN () noexcept -> self_type { return NAN; }
static constexpr auto signaling_NaN() noexcept -> self_type { return 0; }
};
#endif
} } } } } // namespace boost::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LIMITS_2023_01_07_HPP

View file

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2024 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LOG_2024_12_30_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LOG_2024_12_30_HPP
#include <cmath>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
namespace detail {
template <class T>
constexpr auto log_impl(T x) -> T
{
// Default to the regular log function.
using std::log;
return log(x);
}
} // namespace detail
template <typename Real>
constexpr auto log(Real x) -> Real
{
return cpp_df_qf_detail::ccmath::detail::log_impl<Real>(x);
}
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_LOG_2024_12_30_HPP

View file

@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2023 - 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_SQRT_2023_01_07_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_SQRT_2023_01_07_HPP
#include <cmath>
#include <type_traits>
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail { namespace ccmath {
namespace detail {
template <class T>
constexpr auto sqrt_impl(T x) -> T
{
// Default to the regular sqrt function.
using std::sqrt;
return sqrt(x);
}
} // namespace detail
template <typename Real>
constexpr auto sqrt(Real x) -> Real
{
return cpp_df_qf_detail::ccmath::detail::sqrt_impl<Real>(x);
}
namespace unsafe {
namespace detail {
template <typename Real>
constexpr auto sqrt_impl_2(Real x, Real s, Real s2) noexcept -> Real
{
return !(s < s2) ? s2 : sqrt_impl_2(x, (x / s + s) / 2, s);
}
template <typename Real>
constexpr auto sqrt_impl_1(Real x, Real s) noexcept -> Real
{
return sqrt_impl_2(x, (x / s + s) / 2, s);
}
template <typename Real>
constexpr auto sqrt_impl(Real x) noexcept -> Real
{
return sqrt_impl_1(x, x > 1 ? x : Real(1));
}
} // namespace detail
template <typename Real>
constexpr auto sqrt(Real x) noexcept -> Real
{
return detail::sqrt_impl<Real>(x);
}
} // namespace unsafe
} } } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail::ccmath
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CCMATH_SQRT_2023_01_07_HPP

View file

@ -0,0 +1,80 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2025.
// 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)
//
#ifndef BOOST_MP_CPP_DF_QF_DETAIL_CONSTANTS_2025_06_23_HPP
#define BOOST_MP_CPP_DF_QF_DETAIL_CONSTANTS_2025_06_23_HPP
#include <boost/multiprecision/cpp_df_qf/cpp_df_qf_detail.hpp>
#include <type_traits>
#if (defined(__GNUC__) && defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128))
//
// This is the only way we can avoid
// warning: non-standard suffix on floating constant [-Wpedantic]
// when building with -Wall -pedantic. Neither __extension__
// nor #pragma diagnostic ignored work :(
//
#pragma GCC system_header
#endif
namespace boost { namespace multiprecision { namespace backends { namespace cpp_df_qf_detail {
// N[Pi, 101]
// 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170680
// 3.14159250259, 1.50995788317e-07
// 3.141592653589793116, 1.2246467991473529607e-16
// 3.14159265358979323851281, -5.01655761266833202345176e-20
// 3.14159265358979323846264338327950279748, 8.67181013012378102479704402604335225411e-35
template <typename FloatingPointType> constexpr auto constant_df_pi() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 24)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(3.14159250259L), static_cast<FloatingPointType>(1.50995788317e-07L) }; }
template <typename FloatingPointType> constexpr auto constant_df_pi() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 53)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(3.141592653589793116L), static_cast<FloatingPointType>(1.2246467991473529607e-16L) }; }
template <typename FloatingPointType> constexpr auto constant_df_pi() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 64)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(3.14159265358979323851281L), static_cast<FloatingPointType>(-5.01655761266833202345176e-20L) }; }
#if defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
template <typename FloatingPointType> constexpr auto constant_df_pi() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 113)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(3.14159265358979323846264338327950279748Q), static_cast<FloatingPointType>(8.67181013012378102479704402604335225411e-35Q) }; }
#else
template <typename FloatingPointType> constexpr auto constant_df_pi() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 113)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(3.14159265358979323846264338327950279748L), static_cast<FloatingPointType>(8.67181013012378102479704402604335225411e-35L) }; }
#endif
// N[Log[2], 101]
// 0.69314718055994530941723212145817656807550013436025525412068000949339362196969471560586332699641868754
// 0.69314712286, 5.76999887869e-08
// 0.6931471805599451752, 1.3421277060097865271e-16
// 0.69314718055994530942869, -1.14583527267987328094768e-20
// 0.693147180559945309417232121458176575084, -7.00813947454958516341266200877162272784e-36
template <typename FloatingPointType> constexpr auto constant_df_ln_two() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 24)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(0.69314712286L), static_cast<FloatingPointType>(5.76999887869e-08L) }; }
template <typename FloatingPointType> constexpr auto constant_df_ln_two() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 53)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(0.6931471805599451752L), static_cast<FloatingPointType>(1.3421277060097865271e-16L) }; }
template <typename FloatingPointType> constexpr auto constant_df_ln_two() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 64)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(0.69314718055994530942869L), static_cast<FloatingPointType>(-1.14583527267987328094768e-20L) }; }
#if defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
template <typename FloatingPointType> constexpr auto constant_df_ln_two() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 113)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(0.693147180559945309417232121458176575084Q), static_cast<FloatingPointType>(-7.00813947454958516341266200877162272784e-36Q) }; }
#else
template <typename FloatingPointType> constexpr auto constant_df_ln_two() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 113)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(0.693147180559945309417232121458176575084L), static_cast<FloatingPointType>(-7.00813947454958516341266200877162272784e-36L) }; }
#endif
// N[Exp[1], 101]
// 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274
// 2.71828174591, 8.25483965627e-08
// 2.7182818284590450908, 1.4456468917292501578e-16
// 2.71828182845904523521133, 1.4895979785582304563159e-19
// 2.71828182845904523536028747135266231436, 1.83398825226506410712297736767396397644e-34
template <typename FloatingPointType> constexpr auto constant_df_exp1() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 24)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(2.71828174591L), static_cast<FloatingPointType>(8.25483965627e-08L) }; }
template <typename FloatingPointType> constexpr auto constant_df_exp1() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 53)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(2.7182818284590450908L), static_cast<FloatingPointType>(1.4456468917292501578e-16L) }; }
template <typename FloatingPointType> constexpr auto constant_df_exp1() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 64)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(2.71828182845904523521133L), static_cast<FloatingPointType>(1.4895979785582304563159e-19L) }; }
#if defined(BOOST_MP_CPP_DOUBLE_FP_HAS_FLOAT128)
template <typename FloatingPointType> constexpr auto constant_df_exp1() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 113)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(2.71828182845904523536028747135266231436Q), static_cast<FloatingPointType>(1.83398825226506410712297736767396397644e-34Q) }; }
#else
template <typename FloatingPointType> constexpr auto constant_df_exp1() -> typename ::std::enable_if<(cpp_df_qf_detail::is_floating_point<FloatingPointType>::value && (cpp_df_qf_detail::ccmath::numeric_limits<FloatingPointType>::digits == 113)), cpp_double_fp_backend<FloatingPointType>>::type { return { static_cast<FloatingPointType>(2.71828182845904523536028747135266231436L), static_cast<FloatingPointType>(1.83398825226506410712297736767396397644e-34L) }; }
#endif
} } } } // namespace boost::multiprecision::backends::cpp_df_qf_detail
#endif // BOOST_MP_CPP_DF_QF_DETAIL_CONSTANTS_2025_06_23_HPP