Files
externals/linux/include/ActivBoost/math/cstdfloat/cstdfloat_cmath.hpp
T
2023-12-15 13:15:08 -05:00

1059 lines
74 KiB
C++

///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2014.
// Copyright John Maddock 2014.
// Copyright Paul Bristow 2014.
// 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)
//
// Implement quadruple-precision <cmath> support.
#ifndef ACTIV_BOOST_MATH_CSTDFLOAT_CMATH_2014_02_15_HPP_
#define ACTIV_BOOST_MATH_CSTDFLOAT_CMATH_2014_02_15_HPP_
#include <ActivBoost/math/cstdfloat/cstdfloat_types.hpp>
#include <ActivBoost/math/cstdfloat/cstdfloat_limits.hpp>
#if defined(ACTIV_BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) && defined(ACTIV_BOOST_MATH_USE_FLOAT128) && !defined(ACTIV_BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT)
#include <cstdint>
#include <cmath>
#include <stdexcept>
#include <iostream>
#include <type_traits>
#include <memory>
#include <ActivBoost/math/tools/assert.hpp>
#include <ActivBoost/math/tools/nothrow.hpp>
#include <ActivBoost/math/tools/throw_exception.hpp>
#if defined(_WIN32) && defined(__GNUC__)
// Several versions of Mingw and probably cygwin too have broken
// libquadmath implementations that segfault as soon as you call
// expq or any function that depends on it.
#define ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
#endif
// Here is a helper function used for raising the value of a given
// floating-point type to the power of n, where n has integral type.
namespace Boost {
namespace math {
namespace cstdfloat {
namespace detail {
template<class float_type, class integer_type>
inline float_type pown(const float_type& x, const integer_type p)
{
const bool isneg = (x < 0);
const bool isnan = (x != x);
const bool isinf = ((!isneg) ? bool(+x > (std::numeric_limits<float_type>::max)())
: bool(-x > (std::numeric_limits<float_type>::max)()));
if (isnan) { return x; }
if (isinf) { return std::numeric_limits<float_type>::quiet_NaN(); }
const bool x_is_neg = (x < 0);
const float_type abs_x = (x_is_neg ? -x : x);
if (p < static_cast<integer_type>(0))
{
if (abs_x < (std::numeric_limits<float_type>::min)())
{
return (x_is_neg ? -std::numeric_limits<float_type>::infinity()
: +std::numeric_limits<float_type>::infinity());
}
else
{
return float_type(1) / pown(x, static_cast<integer_type>(-p));
}
}
if (p == static_cast<integer_type>(0))
{
return float_type(1);
}
else
{
if (p == static_cast<integer_type>(1)) { return x; }
if (abs_x > (std::numeric_limits<float_type>::max)())
{
return (x_is_neg ? -std::numeric_limits<float_type>::infinity()
: +std::numeric_limits<float_type>::infinity());
}
if (p == static_cast<integer_type>(2)) { return (x * x); }
else if (p == static_cast<integer_type>(3)) { return ((x * x) * x); }
else if (p == static_cast<integer_type>(4)) { const float_type x2 = (x * x); return (x2 * x2); }
else
{
// The variable xn stores the binary powers of x.
float_type result(((p % integer_type(2)) != integer_type(0)) ? x : float_type(1));
float_type xn(x);
integer_type p2 = p;
while (integer_type(p2 /= 2) != integer_type(0))
{
// Square xn for each binary power.
xn *= xn;
const bool has_binary_power = (integer_type(p2 % integer_type(2)) != integer_type(0));
if (has_binary_power)
{
// Multiply the result with each binary power contained in the exponent.
result *= xn;
}
}
return result;
}
}
}
}
}
}
} // Boost::math::cstdfloat::detail
// We will now define preprocessor symbols representing quadruple-precision <cmath> functions.
#if defined(__INTEL_COMPILER)
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LDEXP __ldexpq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FREXP __frexpq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS __fabsq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR __floorq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_CEIL __ceilq
#if !defined(ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT)
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT __sqrtq
#endif
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TRUNC __truncq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP __expq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1 __expm1q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW __powq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG __logq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG10 __log10q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIN __sinq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COS __cosq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TAN __tanq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASIN __asinq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOS __acosq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN __atanq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH __sinhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH __coshq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH __tanhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH __asinhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH __acoshq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH __atanhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMOD __fmodq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN2 __atan2q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LGAMMA __lgammaq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA __tgammaq
// begin more functions
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMAINDER __remainderq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMQUO __remquoq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMA __fmaq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX __fmaxq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN __fminq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FDIM __fdimq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NAN __nanq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP2 __exp2q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG2 __log2q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG1P __log1pq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_CBRT __cbrtq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT __hypotq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERF __erfq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERFC __erfcq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLROUND __llroundq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LROUND __lroundq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ROUND __roundq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEARBYINT __nearbyintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLRINT __llrintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LRINT __lrintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_RINT __rintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_MODF __modfq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBLN __scalblnq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBN __scalbnq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ILOGB __ilogbq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOGB __logbq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER __nextafterq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD __nexttowardq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COPYSIGN __copysignq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIGNBIT __signbitq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY __fpclassifyq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISFINITE __isfiniteq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF __isinfq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN __isnanq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNORMAL __isnormalq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATER __isgreaterq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL __isgreaterequalq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESS __islessq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL __islessequalq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER __islessgreaterq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED __isunorderedq
// end more functions
#elif defined(__GNUC__)
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LDEXP ldexpq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FREXP frexpq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS fabsq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR floorq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_CEIL ceilq
#if !defined(ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT)
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT sqrtq
#endif
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TRUNC truncq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW powq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG logq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG10 log10q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIN sinq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COS cosq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TAN tanq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASIN asinq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOS acosq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN atanq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMOD fmodq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN2 atan2q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LGAMMA lgammaq
#if !defined(ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS)
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP expq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1 expm1q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH sinhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH coshq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH tanhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH asinhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH acoshq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH atanhq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA tgammaq
#else // ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP expq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH sinhq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH coshq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH tanhq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH asinhq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH acoshq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH atanhq_patch
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA tgammaq_patch
#endif // ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
// begin more functions
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMAINDER remainderq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMQUO remquoq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMA fmaq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX fmaxq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN fminq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FDIM fdimq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NAN nanq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP2 exp2q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG2 log2q
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG1P log1pq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_CBRT cbrtq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT hypotq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERF erfq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERFC erfcq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLROUND llroundq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LROUND lroundq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ROUND roundq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEARBYINT nearbyintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLRINT llrintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LRINT lrintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_RINT rintq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_MODF modfq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBLN scalblnq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBN scalbnq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ILOGB ilogbq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOGB logbq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER nextafterq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD nexttowardq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_COPYSIGN copysignq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIGNBIT signbitq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY fpclassifyq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISFINITE isfiniteq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF isinfq
#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN isnanq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNORMAL isnormalq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATER isgreaterq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL isgreaterequalq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESS islessq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL islessequalq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER islessgreaterq
//#define ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED isunorderedq
// end more functions
#endif
// Implement quadruple-precision <cmath> functions in the namespace
// Boost::math::cstdfloat::detail. Subsequently inject these into the
// std namespace via *using* directive.
// Begin with some forward function declarations. Also implement patches
// for compilers that have broken float128 exponential functions.
extern "C" int quadmath_snprintf(char*, std::size_t, const char*, ...) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LDEXP(Boost::math::cstdfloat::detail::float_internal128_t, int) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FREXP(Boost::math::cstdfloat::detail::float_internal128_t, int*) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_CEIL(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_TRUNC(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG10(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIN(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_COS(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_TAN(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASIN(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOS(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMOD(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN2(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LGAMMA(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
// begin more functions
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMAINDER(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMQUO(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t, int*) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMA(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_FDIM(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_NAN(const char*) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP2 (Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG2(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG1P(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_CBRT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERF(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERFC(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" long long int ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLROUND(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" long int ACTIV_BOOST_CSTDFLOAT_FLOAT128_LROUND(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ROUND(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEARBYINT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" long long int ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLRINT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" long int ACTIV_BOOST_CSTDFLOAT_FLOAT128_LRINT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_RINT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_MODF(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t*) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBLN(Boost::math::cstdfloat::detail::float_internal128_t, long int) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBN(Boost::math::cstdfloat::detail::float_internal128_t, int) ACTIV_BOOST_MATH_NOTHROW;
extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ILOGB(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOGB(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD (Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_COPYSIGN(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIGNBIT(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY (Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISFINITE (Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN(Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNORMAL (Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATER (Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESS (Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL (Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER(Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
//extern "C" int ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED (Boost::math::cstdfloat::detail::float_internal128_t, Boost::math::cstdfloat::detail::float_internal128_t) ACTIV_BOOST_MATH_NOTHROW;
// end more functions
#if !defined(ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS)
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
extern "C" Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW;
#else // ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
// Forward declaration of the patched exponent function, exp(x).
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(Boost::math::cstdfloat::detail::float_internal128_t x);
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1(Boost::math::cstdfloat::detail::float_internal128_t x)
{
// Compute exp(x) - 1 for x small.
// Use an order-12 Pade approximation of the exponential function.
// PadeApproximant[Exp[x] - 1, {x, 0, 12, 12}].
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
float_type sum;
if (x > ACTIV_BOOST_FLOAT128_C(0.693147180559945309417232121458176568075500134360255))
{
sum = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(x) - float_type(1);
}
else
{
const float_type x2 = (x * x);
const float_type top = ((((( float_type(ACTIV_BOOST_FLOAT128_C(2.4087176110456818621091195109360728010934088788572E-13)) * x2
+ float_type(ACTIV_BOOST_FLOAT128_C(9.2735628025258751691201101171038802842096241836000E-10))) * x2
+ float_type(ACTIV_BOOST_FLOAT128_C(9.0806726962333369656024118266681195742980640005812E-07))) * x2
+ float_type(ACTIV_BOOST_FLOAT128_C(3.1055900621118012422360248447204968944099378881988E-04))) * x2
+ float_type(ACTIV_BOOST_FLOAT128_C(3.6231884057971014492753623188405797101449275362319E-02))) * x2
+ float_type(ACTIV_BOOST_FLOAT128_C(1.00000000000000000000000000000000000000000000000000000)))
;
const float_type bot = (((((((((((( float_type(ACTIV_BOOST_FLOAT128_C(+7.7202487533515444298369215094104897470942592271063E-16)) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(-1.2043588055228409310545597554680364005467044394286E-13))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(+9.2735628025258751691201101171038802842096241836000E-12))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(-4.6367814012629375845600550585519401421048120918000E-10))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(+1.6692413044546575304416198210786984511577323530480E-08))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(-4.5403363481166684828012059133340597871490320002906E-07))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(+9.5347063310450038138825324180015255530129672006102E-06))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(-1.5527950310559006211180124223602484472049689440994E-04))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(+1.9409937888198757763975155279503105590062111801242E-03))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(-1.8115942028985507246376811594202898550724637681159E-02))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(+1.1956521739130434782608695652173913043478260869565E-01))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(-0.50000000000000000000000000000000000000000000000000000))) * x
+ float_type(ACTIV_BOOST_FLOAT128_C(+1.00000000000000000000000000000000000000000000000000000)))
;
sum = (x * top) / bot;
}
return sum;
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(Boost::math::cstdfloat::detail::float_internal128_t x)
{
// Patch the expq() function for a subset of broken GCC compilers
// like GCC 4.7, 4.8 on MinGW.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
// Scale the argument x to the range (-ln2 < x < ln2).
constexpr float_type one_over_ln2 = float_type(ACTIV_BOOST_FLOAT128_C(1.44269504088896340735992468100189213742664595415299));
const float_type x_over_ln2 = x * one_over_ln2;
int n;
if (x != x)
{
// The argument is NaN.
return std::numeric_limits<float_type>::quiet_NaN();
}
else if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x) > ACTIV_BOOST_FLOAT128_C(+0.693147180559945309417232121458176568075500134360255))
{
// The absolute value of the argument exceeds ln2.
n = static_cast<int>(::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR(x_over_ln2));
}
else if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x) < ACTIV_BOOST_FLOAT128_C(+0.693147180559945309417232121458176568075500134360255))
{
// The absolute value of the argument is less than ln2.
n = 0;
}
else
{
// The absolute value of the argument is exactly equal to ln2 (in the sense of floating-point equality).
return float_type(2);
}
// Check if the argument is very near an integer.
const float_type floor_of_x = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR(x);
if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x - floor_of_x) < float_type(ACTIV_BOOST_CSTDFLOAT_FLOAT128_EPS))
{
// Return e^n for arguments very near an integer.
return Boost::math::cstdfloat::detail::pown(ACTIV_BOOST_FLOAT128_C(2.71828182845904523536028747135266249775724709369996), static_cast<std::int_fast32_t>(floor_of_x));
}
// Compute the scaled argument alpha.
const float_type alpha = x - (n * ACTIV_BOOST_FLOAT128_C(0.693147180559945309417232121458176568075500134360255));
// Compute the polynomial approximation of expm1(alpha) and add to it
// in order to obtain the scaled result.
const float_type scaled_result = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1(alpha) + float_type(1);
// Rescale the result and return it.
return scaled_result * Boost::math::cstdfloat::detail::pown(float_type(2), n);
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH(Boost::math::cstdfloat::detail::float_internal128_t x)
{
// Patch the sinhq() function for a subset of broken GCC compilers
// like GCC 4.7, 4.8 on MinGW.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
// Here, we use the following:
// Set: ex = exp(x)
// Set: em1 = expm1(x)
// Then
// sinh(x) = (ex - 1/ex) / 2 ; for |x| >= 1
// sinh(x) = (2em1 + em1^2) / (2ex) ; for |x| < 1
const float_type ex = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(x);
if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x) < float_type(+1))
{
const float_type em1 = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1(x);
return ((em1 * 2) + (em1 * em1)) / (ex * 2);
}
else
{
return (ex - (float_type(1) / ex)) / 2;
}
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH(Boost::math::cstdfloat::detail::float_internal128_t x)
{
// Patch the coshq() function for a subset of broken GCC compilers
// like GCC 4.7, 4.8 on MinGW.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
const float_type ex = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(x);
return (ex + (float_type(1) / ex)) / 2;
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH(Boost::math::cstdfloat::detail::float_internal128_t x)
{
// Patch the tanhq() function for a subset of broken GCC compilers
// like GCC 4.7, 4.8 on MinGW.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
const float_type ex_plus = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(x);
const float_type ex_minus = (float_type(1) / ex_plus);
return (ex_plus - ex_minus) / (ex_plus + ex_minus);
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW
{
// Patch the asinh() function since quadmath does not have it.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG(x + ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT((x * x) + float_type(1)));
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW
{
// Patch the acosh() function since quadmath does not have it.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
const float_type zp(x + float_type(1));
const float_type zm(x - float_type(1));
return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG(x + (zp * ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT(zm / zp)));
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW
{
// Patch the atanh() function since quadmath does not have it.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
return (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG(float_type(1) + x)
- ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG(float_type(1) - x)) / 2;
}
inline Boost::math::cstdfloat::detail::float_internal128_t ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA(Boost::math::cstdfloat::detail::float_internal128_t x) ACTIV_BOOST_MATH_NOTHROW
{
// Patch the tgammaq() function for a subset of broken GCC compilers
// like GCC 4.7, 4.8 on MinGW.
typedef Boost::math::cstdfloat::detail::float_internal128_t float_type;
if (x > float_type(0))
{
return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LGAMMA(x));
}
else if (x < float_type(0))
{
// For x < 0, compute tgamma(-x) and use the reflection formula.
const float_type positive_x = -x;
float_type gamma_value = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA(positive_x);
const float_type floor_of_positive_x = ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR(positive_x);
// Take the reflection checks (slightly adapted) from <ActivBoost/math/gamma.hpp>.
const bool floor_of_z_is_equal_to_z = (positive_x == ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR(positive_x));
constexpr float_type my_pi = ACTIV_BOOST_FLOAT128_C(3.14159265358979323846264338327950288419716939937511);
if (floor_of_z_is_equal_to_z)
{
const bool is_odd = ((std::int32_t(floor_of_positive_x) % std::int32_t(2)) != std::int32_t(0));
return (is_odd ? -std::numeric_limits<float_type>::infinity()
: +std::numeric_limits<float_type>::infinity());
}
const float_type sinpx_value = x * ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIN(my_pi * x);
gamma_value *= sinpx_value;
const bool result_is_too_large_to_represent = ((::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(gamma_value) < float_type(1))
&& (((std::numeric_limits<float_type>::max)() * ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(gamma_value)) < my_pi));
if (result_is_too_large_to_represent)
{
const bool is_odd = ((std::int32_t(floor_of_positive_x) % std::int32_t(2)) != std::int32_t(0));
return (is_odd ? -std::numeric_limits<float_type>::infinity()
: +std::numeric_limits<float_type>::infinity());
}
gamma_value = -my_pi / gamma_value;
if ((gamma_value > float_type(0)) || (gamma_value < float_type(0)))
{
return gamma_value;
}
else
{
// The value of gamma is too small to represent. Return 0.0 here.
return float_type(0);
}
}
else
{
// Gamma of zero is complex infinity. Return NaN here.
return std::numeric_limits<float_type>::quiet_NaN();
}
}
#endif // ACTIV_BOOST_CSTDFLOAT_BROKEN_FLOAT128_MATH_FUNCTIONS
// Define the quadruple-precision <cmath> functions in the namespace Boost::math::cstdfloat::detail.
namespace Boost {
namespace math {
namespace cstdfloat {
namespace detail {
inline Boost::math::cstdfloat::detail::float_internal128_t ldexp(Boost::math::cstdfloat::detail::float_internal128_t x, int n) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LDEXP(x, n); }
inline Boost::math::cstdfloat::detail::float_internal128_t frexp(Boost::math::cstdfloat::detail::float_internal128_t x, int* pn) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FREXP(x, pn); }
inline Boost::math::cstdfloat::detail::float_internal128_t fabs(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t abs(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t floor(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t ceil(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_CEIL(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t sqrt(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t trunc(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_TRUNC(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t exp(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t expm1(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t pow(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t a) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW(x, a); }
inline Boost::math::cstdfloat::detail::float_internal128_t pow(Boost::math::cstdfloat::detail::float_internal128_t x, int a) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW(x, Boost::math::cstdfloat::detail::float_internal128_t(a)); }
inline Boost::math::cstdfloat::detail::float_internal128_t log(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t log10(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG10(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t sin(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIN(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t cos(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_COS(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t tan(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_TAN(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t asin(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASIN(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t acos(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOS(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t atan(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t sinh(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t cosh(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t tanh(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t asinh(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t acosh(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t atanh(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t fmod(Boost::math::cstdfloat::detail::float_internal128_t a, Boost::math::cstdfloat::detail::float_internal128_t b) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMOD(a, b); }
inline Boost::math::cstdfloat::detail::float_internal128_t atan2(Boost::math::cstdfloat::detail::float_internal128_t y, Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN2(y, x); }
inline Boost::math::cstdfloat::detail::float_internal128_t lgamma(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LGAMMA(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t tgamma(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA(x); }
// begin more functions
inline Boost::math::cstdfloat::detail::float_internal128_t remainder(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMAINDER(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t remquo(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y, int* z) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMQUO(x, y, z); }
inline Boost::math::cstdfloat::detail::float_internal128_t fma(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y, Boost::math::cstdfloat::detail::float_internal128_t z) { return ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMA(x, y, z); }
inline Boost::math::cstdfloat::detail::float_internal128_t fmax(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX(x, y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
fmax(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX(x, y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
fmax(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t fmin(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN(x, y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
fmin(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN(x, y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
fmin(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t fdim(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FDIM(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t nanq(const char* x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_NAN(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t exp2(Boost::math::cstdfloat::detail::float_internal128_t x)
{
return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW(Boost::math::cstdfloat::detail::float_internal128_t(2), x);
}
inline Boost::math::cstdfloat::detail::float_internal128_t log2(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG2(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t log1p(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG1P(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t cbrt(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_CBRT(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t hypot(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y, Boost::math::cstdfloat::detail::float_internal128_t z) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT(x*x + y * y + z * z); }
inline Boost::math::cstdfloat::detail::float_internal128_t hypot(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT(x, y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
hypot(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT(x, y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
hypot(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t erf(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERF(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t erfc(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERFC(x); }
inline long long int llround(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLROUND(x); }
inline long int lround(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LROUND(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t round(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ROUND(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t nearbyint(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEARBYINT(x); }
inline long long int llrint(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLRINT(x); }
inline long int lrint(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LRINT(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t rint(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_RINT(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t modf(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t* y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_MODF(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t scalbln(Boost::math::cstdfloat::detail::float_internal128_t x, long int y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBLN(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t scalbn(Boost::math::cstdfloat::detail::float_internal128_t x, int y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBN(x, y); }
inline int ilogb(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ILOGB(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t logb(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOGB(x); }
inline Boost::math::cstdfloat::detail::float_internal128_t nextafter(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER(x, y); }
inline Boost::math::cstdfloat::detail::float_internal128_t nexttoward(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return -(::ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER(-x, -y)); }
inline Boost::math::cstdfloat::detail::float_internal128_t copysign ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_COPYSIGN(x, y); }
inline bool signbit ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIGNBIT(x); }
inline int fpclassify ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x)
{
if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN(x))
return FP_NAN;
else if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF(x))
return FP_INFINITE;
else if (x == ACTIV_BOOST_FLOAT128_C(0.0))
return FP_ZERO;
if (::ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS(x) < ACTIV_BOOST_CSTDFLOAT_FLOAT128_MIN)
return FP_SUBNORMAL;
else
return FP_NORMAL;
}
inline bool isfinite ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x)
{
return !::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN(x) && !::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF(x);
}
inline bool isinf ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF(x); }
inline bool isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN(x); }
inline bool isnormal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x) { return Boost::math::cstdfloat::detail::fpclassify ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x) == FP_NORMAL; }
inline bool isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y)
{
if (isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(y))
return false;
return x > y;
}
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x, (Boost::math::cstdfloat::detail::float_internal128_t)y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return isgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION((Boost::math::cstdfloat::detail::float_internal128_t)x, y); }
inline bool isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y)
{
if (isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(y))
return false;
return x >= y;
}
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x, (Boost::math::cstdfloat::detail::float_internal128_t)y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return isgreaterequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION((Boost::math::cstdfloat::detail::float_internal128_t)x, y); }
inline bool isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y)
{
if (isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(y))
return false;
return x < y;
}
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x, (Boost::math::cstdfloat::detail::float_internal128_t)y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return isless ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION((Boost::math::cstdfloat::detail::float_internal128_t)x, y); }
inline bool islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y)
{
if (isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(y))
return false;
return x <= y;
}
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x, (Boost::math::cstdfloat::detail::float_internal128_t)y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return islessequal ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION((Boost::math::cstdfloat::detail::float_internal128_t)x, y); }
inline bool islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y)
{
if (isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x) || isnan ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(y))
return false;
return (x < y) || (x > y);
}
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x, (Boost::math::cstdfloat::detail::float_internal128_t)y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return islessgreater ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION((Boost::math::cstdfloat::detail::float_internal128_t)x, y); }
inline bool isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, Boost::math::cstdfloat::detail::float_internal128_t y) { return ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN(x) || ::ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN(y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(Boost::math::cstdfloat::detail::float_internal128_t x, T y) { return isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(x, (Boost::math::cstdfloat::detail::float_internal128_t)y); }
template <class T>
inline typename std::enable_if<
std::is_convertible<T, Boost::math::cstdfloat::detail::float_internal128_t>::value
&& !std::is_same<T, Boost::math::cstdfloat::detail::float_internal128_t>::value, Boost::math::cstdfloat::detail::float_internal128_t>::type
isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION(T x, Boost::math::cstdfloat::detail::float_internal128_t y) { return isunordered ACTIV_BOOST_PREVENT_MACRO_SUBSTITUTION((Boost::math::cstdfloat::detail::float_internal128_t)x, y); }
// end more functions
}
}
}
} // Boost::math::cstdfloat::detail
// We will now inject the quadruple-precision <cmath> functions
// into the std namespace. This is done via *using* directive.
namespace std
{
using Boost::math::cstdfloat::detail::ldexp;
using Boost::math::cstdfloat::detail::frexp;
using Boost::math::cstdfloat::detail::fabs;
#if !(defined(_GLIBCXX_USE_FLOAT128) && defined(__GNUC__) && (__GNUC__ >= 7))
#if (defined(__clang__) && !(!defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128))) || (__GNUC__ <= 6 && !defined(__clang__))
// workaround for clang using libstdc++ and old GCC
using Boost::math::cstdfloat::detail::abs;
#endif
#endif
using Boost::math::cstdfloat::detail::floor;
using Boost::math::cstdfloat::detail::ceil;
using Boost::math::cstdfloat::detail::sqrt;
using Boost::math::cstdfloat::detail::trunc;
using Boost::math::cstdfloat::detail::exp;
using Boost::math::cstdfloat::detail::expm1;
using Boost::math::cstdfloat::detail::pow;
using Boost::math::cstdfloat::detail::log;
using Boost::math::cstdfloat::detail::log10;
using Boost::math::cstdfloat::detail::sin;
using Boost::math::cstdfloat::detail::cos;
using Boost::math::cstdfloat::detail::tan;
using Boost::math::cstdfloat::detail::asin;
using Boost::math::cstdfloat::detail::acos;
using Boost::math::cstdfloat::detail::atan;
using Boost::math::cstdfloat::detail::sinh;
using Boost::math::cstdfloat::detail::cosh;
using Boost::math::cstdfloat::detail::tanh;
using Boost::math::cstdfloat::detail::asinh;
using Boost::math::cstdfloat::detail::acosh;
using Boost::math::cstdfloat::detail::atanh;
using Boost::math::cstdfloat::detail::fmod;
using Boost::math::cstdfloat::detail::atan2;
using Boost::math::cstdfloat::detail::lgamma;
using Boost::math::cstdfloat::detail::tgamma;
// begin more functions
using Boost::math::cstdfloat::detail::remainder;
using Boost::math::cstdfloat::detail::remquo;
using Boost::math::cstdfloat::detail::fma;
using Boost::math::cstdfloat::detail::fmax;
using Boost::math::cstdfloat::detail::fmin;
using Boost::math::cstdfloat::detail::fdim;
using Boost::math::cstdfloat::detail::nanq;
using Boost::math::cstdfloat::detail::exp2;
using Boost::math::cstdfloat::detail::log2;
using Boost::math::cstdfloat::detail::log1p;
using Boost::math::cstdfloat::detail::cbrt;
using Boost::math::cstdfloat::detail::hypot;
using Boost::math::cstdfloat::detail::erf;
using Boost::math::cstdfloat::detail::erfc;
using Boost::math::cstdfloat::detail::llround;
using Boost::math::cstdfloat::detail::lround;
using Boost::math::cstdfloat::detail::round;
using Boost::math::cstdfloat::detail::nearbyint;
using Boost::math::cstdfloat::detail::llrint;
using Boost::math::cstdfloat::detail::lrint;
using Boost::math::cstdfloat::detail::rint;
using Boost::math::cstdfloat::detail::modf;
using Boost::math::cstdfloat::detail::scalbln;
using Boost::math::cstdfloat::detail::scalbn;
using Boost::math::cstdfloat::detail::ilogb;
using Boost::math::cstdfloat::detail::logb;
using Boost::math::cstdfloat::detail::nextafter;
using Boost::math::cstdfloat::detail::nexttoward;
using Boost::math::cstdfloat::detail::copysign;
using Boost::math::cstdfloat::detail::signbit;
using Boost::math::cstdfloat::detail::fpclassify;
using Boost::math::cstdfloat::detail::isfinite;
using Boost::math::cstdfloat::detail::isinf;
using Boost::math::cstdfloat::detail::isnan;
using Boost::math::cstdfloat::detail::isnormal;
using Boost::math::cstdfloat::detail::isgreater;
using Boost::math::cstdfloat::detail::isgreaterequal;
using Boost::math::cstdfloat::detail::isless;
using Boost::math::cstdfloat::detail::islessequal;
using Boost::math::cstdfloat::detail::islessgreater;
using Boost::math::cstdfloat::detail::isunordered;
// end more functions
//
// Very basic iostream operator:
//
inline std::ostream& operator << (std::ostream& os, __float128 m_value)
{
std::streamsize digits = os.precision();
std::ios_base::fmtflags f = os.flags();
std::string s;
char buf[100];
std::unique_ptr<char[]> buf2;
std::string format = "%";
if (f & std::ios_base::showpos)
format += "+";
if (f & std::ios_base::showpoint)
format += "#";
format += ".*";
if (digits == 0)
digits = 36;
format += "Q";
if (f & std::ios_base::scientific)
format += "e";
else if (f & std::ios_base::fixed)
format += "f";
else
format += "g";
int v = quadmath_snprintf(buf, 100, format.c_str(), digits, m_value);
if ((v < 0) || (v >= 99))
{
int v_max = v;
buf2.reset(new char[v + 3]);
v = quadmath_snprintf(&buf2[0], v_max + 3, format.c_str(), digits, m_value);
if (v >= v_max + 3)
{
ACTIV_BOOST_MATH_THROW_EXCEPTION(std::runtime_error("Formatting of float128_type failed."));
}
s = &buf2[0];
}
else
s = buf;
std::streamsize ss = os.width();
if (ss > static_cast<std::streamsize>(s.size()))
{
char fill = os.fill();
if ((os.flags() & std::ios_base::left) == std::ios_base::left)
s.append(static_cast<std::string::size_type>(ss - s.size()), fill);
else
s.insert(static_cast<std::string::size_type>(0), static_cast<std::string::size_type>(ss - s.size()), fill);
}
return os << s;
}
} // namespace std
// We will now remove the preprocessor symbols representing quadruple-precision <cmath>
// functions from the preprocessor.
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LDEXP
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FREXP
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FABS
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FLOOR
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_CEIL
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_SQRT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_TRUNC
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXPM1
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_POW
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG10
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_COS
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_TAN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASIN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOS
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_SINH
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_COSH
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_TANH
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ASINH
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ACOSH
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATANH
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMOD
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ATAN2
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LGAMMA
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_TGAMMA
// begin more functions
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMAINDER
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_REMQUO
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMA
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMAX
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FMIN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FDIM
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_NAN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_EXP2
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG2
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOG1P
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_CBRT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_HYPOT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERF
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ERFC
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLROUND
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LROUND
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ROUND
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEARBYINT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LLRINT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LRINT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_RINT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_MODF
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBLN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_SCALBN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ILOGB
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_LOGB
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTAFTER
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_NEXTTOWARD
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_COPYSIGN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_SIGNBIT
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_FPCLASSIFY
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISFINITE
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISINF
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNAN
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISNORMAL
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATER
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISGREATEREQUAL
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESS
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSEQUAL
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISLESSGREATER
#undef ACTIV_BOOST_CSTDFLOAT_FLOAT128_ISUNORDERED
// end more functions
#endif // Not ACTIV_BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT (i.e., the user would like to have libquadmath support)
#endif // ACTIV_BOOST_MATH_CSTDFLOAT_CMATH_2014_02_15_HPP_