Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:15:53

0001 //  Copyright (c) 2006-7 John Maddock
0002 //  Copyright (c) 2021 Matt Borland
0003 //  Use, modification and distribution are subject to the
0004 //  Boost Software License, Version 1.0. (See accompanying file
0005 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_MATH_TOOLS_CONFIG_HPP
0008 #define BOOST_MATH_TOOLS_CONFIG_HPP
0009 
0010 #ifdef _MSC_VER
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/math/tools/is_standalone.hpp>
0015 
0016 // Minimum language standard transition
0017 #ifdef _MSVC_LANG
0018 #  if _MSVC_LANG < 201402L
0019 #    pragma message("Boost.Math requires C++14");
0020 #  endif
0021 #  if _MSC_VER == 1900
0022 #    pragma message("MSVC 14.0 has broken C++14 constexpr support. Support for this compiler will be removed in Boost 1.86")
0023 #  endif
0024 #else
0025 #  if __cplusplus < 201402L
0026 #    warning "Boost.Math requires C++14"
0027 #  endif
0028 #endif
0029 
0030 #ifndef BOOST_MATH_STANDALONE
0031 #include <boost/config.hpp>
0032 
0033 
0034 // The following are all defined as standalone macros as well
0035 // If Boost.Config is available just use those definitions because they are more fine-grained
0036 
0037 // Could be defined in TR1
0038 #ifndef BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
0039 #  define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION BOOST_PREVENT_MACRO_SUBSTITUTION
0040 #endif
0041 
0042 #define BOOST_MATH_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
0043 #ifdef BOOST_NO_CXX14_CONSTEXPR
0044 #  define BOOST_MATH_NO_CXX14_CONSTEXPR
0045 #endif
0046 
0047 #define BOOST_MATH_IF_CONSTEXPR BOOST_IF_CONSTEXPR
0048 #ifdef BOOST_NO_CXX17_IF_CONSTEXPR
0049 #  define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
0050 #endif
0051 
0052 #ifdef BOOST_NO_CXX17_HDR_EXECUTION
0053 #  define BOOST_MATH_NO_CXX17_HDR_EXECUTION
0054 #endif
0055 
0056 #ifdef BOOST_HAS_THREADS
0057 #  define BOOST_MATH_HAS_THREADS
0058 #endif
0059 #ifdef BOOST_DISABLE_THREADS
0060 #  define BOOST_MATH_DISABLE_THREADS
0061 #endif
0062 #ifdef BOOST_NO_CXX11_THREAD_LOCAL
0063 #  define BOOST_MATH_NO_CXX11_THREAD_LOCAL
0064 #endif
0065 
0066 #ifdef BOOST_NO_EXCEPTIONS
0067 #  define BOOST_MATH_NO_EXCEPTIONS
0068 #endif
0069 
0070 #ifdef BOOST_NO_TYPEID
0071 #  define BOOST_MATH_NO_TYPEID
0072 #endif
0073 #ifdef BOOST_NO_RTTI
0074 #  define BOOST_MATH_NO_RTTI
0075 #endif
0076 
0077 #define BOOST_MATH_NOINLINE BOOST_NOINLINE
0078 #define BOOST_MATH_FORCEINLINE BOOST_FORCEINLINE
0079 
0080 #define BOOST_MATH_JOIN(X, Y) BOOST_JOIN(X, Y)
0081 #define BOOST_MATH_STRINGIZE(X) BOOST_STRINGIZE(X)
0082 
0083 #else // Things from boost/config that are required, and easy to replicate
0084 
0085 #define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
0086 #define BOOST_MATH_NO_REAL_CONCEPT_TESTS
0087 #define BOOST_MATH_NO_DISTRIBUTION_CONCEPT_TESTS
0088 #define BOOST_MATH_NO_LEXICAL_CAST
0089 
0090 // Since Boost.Multiprecision is in active development some tests do not fully cooperate yet.
0091 #define BOOST_MATH_NO_MP_TESTS
0092 
0093 #if (__cplusplus > 201400L || _MSVC_LANG > 201400L)
0094 #define BOOST_MATH_CXX14_CONSTEXPR constexpr
0095 #else
0096 #define BOOST_MATH_CXX14_CONSTEXPR
0097 #define BOOST_MATH_NO_CXX14_CONSTEXPR
0098 #endif // BOOST_MATH_CXX14_CONSTEXPR
0099 
0100 #if (__cplusplus > 201700L || _MSVC_LANG > 201700L)
0101 #define BOOST_MATH_IF_CONSTEXPR if constexpr
0102 
0103 // Clang on mac provides the execution header with none of the functionality. TODO: Check back on this
0104 // https://en.cppreference.com/w/cpp/compiler_support "Standardization of Parallelism TS"
0105 #  if !__has_include(<execution>) || (defined(__APPLE__) && defined(__clang__))
0106 #  define BOOST_MATH_NO_CXX17_HDR_EXECUTION
0107 #  endif
0108 #else
0109 #  define BOOST_MATH_IF_CONSTEXPR if
0110 #  define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
0111 #  define BOOST_MATH_NO_CXX17_HDR_EXECUTION
0112 #endif
0113 
0114 #if __cpp_lib_gcd_lcm >= 201606L
0115 #define BOOST_MATH_HAS_CXX17_NUMERIC
0116 #endif
0117 
0118 #define BOOST_MATH_JOIN(X, Y) BOOST_MATH_DO_JOIN(X, Y)
0119 #define BOOST_MATH_DO_JOIN(X, Y) BOOST_MATH_DO_JOIN2(X,Y)
0120 #define BOOST_MATH_DO_JOIN2(X, Y) X##Y
0121 
0122 #define BOOST_MATH_STRINGIZE(X) BOOST_MATH_DO_STRINGIZE(X)
0123 #define BOOST_MATH_DO_STRINGIZE(X) #X
0124 
0125 #ifdef BOOST_MATH_DISABLE_THREADS // No threads, do nothing
0126 // Detect thread support via STL implementation
0127 #elif defined(__has_include)
0128 #  if !__has_include(<thread>) || !__has_include(<mutex>) || !__has_include(<future>) || !__has_include(<atomic>)
0129 #     define BOOST_MATH_DISABLE_THREADS
0130 #  else
0131 #     define BOOST_MATH_HAS_THREADS
0132 #  endif 
0133 #else
0134 #  define BOOST_MATH_HAS_THREADS // The default assumption is that the machine has threads
0135 #endif // Thread Support
0136 
0137 #ifdef BOOST_MATH_DISABLE_THREADS
0138 #  define BOOST_MATH_NO_CXX11_THREAD_LOCAL
0139 #endif // BOOST_MATH_DISABLE_THREADS
0140 
0141 #ifdef __GNUC__
0142 #  if !defined(__EXCEPTIONS) && !defined(BOOST_MATH_NO_EXCEPTIONS)
0143 #     define BOOST_MATH_NO_EXCEPTIONS
0144 #  endif
0145    //
0146    // Make sure we have some std lib headers included so we can detect __GXX_RTTI:
0147    //
0148 #  include <algorithm>  // for min and max
0149 #  include <limits>
0150 #  ifndef __GXX_RTTI
0151 #     ifndef BOOST_MATH_NO_TYPEID
0152 #        define BOOST_MATH_NO_TYPEID
0153 #     endif
0154 #     ifndef BOOST_MATH_NO_RTTI
0155 #        define BOOST_MATH_NO_RTTI
0156 #     endif
0157 #  endif
0158 #endif
0159 
0160 #if !defined(BOOST_MATH_NOINLINE)
0161 #  if defined(_MSC_VER)
0162 #    define BOOST_MATH_NOINLINE __declspec(noinline)
0163 #  elif defined(__GNUC__) && __GNUC__ > 3
0164      // Clang also defines __GNUC__ (as 4)
0165 #    if defined(__CUDACC__)
0166        // nvcc doesn't always parse __noinline__,
0167        // see: https://svn.boost.org/trac/boost/ticket/9392
0168 #      define BOOST_MATH_NOINLINE __attribute__ ((noinline))
0169 #    elif defined(__HIP__)
0170        // See https://github.com/boostorg/config/issues/392
0171 #      define BOOST_MATH_NOINLINE __attribute__ ((noinline))
0172 #    else
0173 #      define BOOST_MATH_NOINLINE __attribute__ ((__noinline__))
0174 #    endif
0175 #  else
0176 #    define BOOST_MATH_NOINLINE
0177 #  endif
0178 #endif
0179 
0180 #if !defined(BOOST_MATH_FORCEINLINE)
0181 #  if defined(_MSC_VER)
0182 #    define BOOST_MATH_FORCEINLINE __forceinline
0183 #  elif defined(__GNUC__) && __GNUC__ > 3
0184      // Clang also defines __GNUC__ (as 4)
0185 #    define BOOST_MATH_FORCEINLINE inline __attribute__ ((__always_inline__))
0186 #  else
0187 #    define BOOST_MATH_FORCEINLINE inline
0188 #  endif
0189 #endif
0190 
0191 #endif // BOOST_MATH_STANDALONE
0192 
0193 // Support compilers with P0024R2 implemented without linking TBB
0194 // https://en.cppreference.com/w/cpp/compiler_support
0195 #if !defined(BOOST_MATH_NO_CXX17_HDR_EXECUTION) && defined(BOOST_MATH_HAS_THREADS)
0196 #  define BOOST_MATH_EXEC_COMPATIBLE
0197 #endif
0198 
0199 // C++23
0200 #if __cplusplus > 202002L || (defined(_MSVC_LANG) &&_MSVC_LANG > 202002L)
0201 #  if __GNUC__ >= 13
0202      // libstdc++3 only defines to/from_chars for std::float128_t when one of these defines are set
0203      // otherwise we're right out of luck...
0204 #    if defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) || defined(_GLIBCXX_HAVE_FLOAT128_MATH)
0205 #      include <cstring> // std::strlen is used with from_chars
0206 #      include <charconv>
0207 #      include <stdfloat>
0208 #      define BOOST_MATH_USE_CHARCONV_FOR_CONVERSION
0209 #    endif
0210 #  endif
0211 #endif
0212 
0213 #include <algorithm>  // for min and max
0214 #include <limits>
0215 #include <cmath>
0216 #include <climits>
0217 #include <cfloat>
0218 
0219 #include <boost/math/tools/user.hpp>
0220 
0221 #if (defined(__NetBSD__) || defined(__EMSCRIPTEN__)\
0222    || (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
0223    && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
0224 //#  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0225 #endif
0226 
0227 #ifdef __IBMCPP__
0228 //
0229 // For reasons I don't understand, the tests with IMB's compiler all
0230 // pass at long double precision, but fail with real_concept, those tests
0231 // are disabled for now.  (JM 2012).
0232 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
0233 #  define BOOST_MATH_NO_REAL_CONCEPT_TESTS
0234 #endif // BOOST_MATH_NO_REAL_CONCEPT_TESTS
0235 #endif
0236 #ifdef sun
0237 // Any use of __float128 in program startup code causes a segfault  (tested JM 2015, Solaris 11).
0238 #  define BOOST_MATH_DISABLE_FLOAT128
0239 #endif
0240 #ifdef __HAIKU__
0241 //
0242 // Not sure what's up with the math detection on Haiku, but linking fails with
0243 // float128 code enabled, and we don't have an implementation of __expl, so
0244 // disabling long double functions for now as well.
0245 #  define BOOST_MATH_DISABLE_FLOAT128
0246 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0247 #endif
0248 #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
0249 //
0250 // Darwin's rather strange "double double" is rather hard to
0251 // support, it should be possible given enough effort though...
0252 //
0253 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0254 #endif
0255 #if !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) && (LDBL_MANT_DIG == 106) && (LDBL_MIN_EXP > DBL_MIN_EXP)
0256 //
0257 // Generic catch all case for gcc's "double-double" long double type.
0258 // We do not support this as it's not even remotely IEEE conforming:
0259 //
0260 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0261 #endif
0262 #if defined(unix) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1000) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
0263 //
0264 // Intel compiler prior to version 10 has sporadic problems
0265 // calling the long double overloads of the std lib math functions:
0266 // calling ::powl is OK, but std::pow(long double, long double) 
0267 // may segfault depending upon the value of the arguments passed 
0268 // and the specific Linux distribution.
0269 //
0270 // We'll be conservative and disable long double support for this compiler.
0271 //
0272 // Comment out this #define and try building the tests to determine whether
0273 // your Intel compiler version has this issue or not.
0274 //
0275 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0276 #endif
0277 #if defined(unix) && defined(__INTEL_COMPILER)
0278 //
0279 // Intel compiler has sporadic issues compiling std::fpclassify depending on
0280 // the exact OS version used.  Use our own code for this as we know it works
0281 // well on Intel processors:
0282 //
0283 #define BOOST_MATH_DISABLE_STD_FPCLASSIFY
0284 #endif
0285 
0286 #if defined(_MSC_VER) && !defined(_WIN32_WCE)
0287    // Better safe than sorry, our tests don't support hardware exceptions:
0288 #  define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
0289 #endif
0290 
0291 #ifdef __IBMCPP__
0292 #  define BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS
0293 #endif
0294 
0295 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))
0296 #  define BOOST_MATH_USE_C99
0297 #endif
0298 
0299 #if (defined(__hpux) && !defined(__hppa))
0300 #  define BOOST_MATH_USE_C99
0301 #endif
0302 
0303 #if defined(__GNUC__) && defined(_GLIBCXX_USE_C99)
0304 #  define BOOST_MATH_USE_C99
0305 #endif
0306 
0307 #if defined(_LIBCPP_VERSION) && !defined(_MSC_VER)
0308 #  define BOOST_MATH_USE_C99
0309 #endif
0310 
0311 #if defined(__CYGWIN__) || defined(__HP_aCC) || defined(__INTEL_COMPILER) \
0312   || defined(BOOST_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) \
0313   || (defined(__GNUC__) && !defined(BOOST_MATH_USE_C99))\
0314   || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
0315 #  define BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY
0316 #endif
0317 
0318 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x590)
0319 
0320 namespace boost { namespace math { namespace tools { namespace detail {
0321 template <typename T>
0322 struct type {};
0323 
0324 template <typename T, T n>
0325 struct non_type {};
0326 }}}} // Namespace boost, math tools, detail
0327 
0328 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)              boost::math::tools::detail::type<t>* = 0
0329 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)         boost::math::tools::detail::type<t>*
0330 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)       boost::math::tools::detail::non_type<t, v>* = 0
0331 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)  boost::math::tools::detail::non_type<t, v>*
0332 
0333 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)         \
0334              , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
0335 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)    \
0336              , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
0337 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)  \
0338              , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
0339 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)  \
0340              , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
0341 
0342 #else
0343 
0344 // no workaround needed: expand to nothing
0345 
0346 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
0347 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
0348 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
0349 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
0350 
0351 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
0352 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
0353 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
0354 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
0355 
0356 
0357 #endif // __SUNPRO_CC
0358 
0359 #if (defined(__SUNPRO_CC) || defined(__hppa) || defined(__GNUC__)) && !defined(BOOST_MATH_SMALL_CONSTANT)
0360 // Sun's compiler emits a hard error if a constant underflows,
0361 // as does aCC on PA-RISC, while gcc issues a large number of warnings:
0362 #  define BOOST_MATH_SMALL_CONSTANT(x) 0.0
0363 #else
0364 #  define BOOST_MATH_SMALL_CONSTANT(x) x
0365 #endif
0366 
0367 //
0368 // Tune performance options for specific compilers,
0369 // but check at each step that nothing has been previously defined by the user first
0370 //
0371 #ifdef _MSC_VER
0372 #  ifndef BOOST_MATH_POLY_METHOD
0373 #    define BOOST_MATH_POLY_METHOD 2
0374 #  endif
0375 #if _MSC_VER <= 1900
0376 #  ifndef BOOST_MATH_POLY_METHOD
0377 #    define BOOST_MATH_RATIONAL_METHOD 1
0378 #  endif
0379 #else
0380 #  ifndef BOOST_MATH_RATIONAL_METHOD
0381 #    define BOOST_MATH_RATIONAL_METHOD 2
0382 #  endif
0383 #endif
0384 #if _MSC_VER > 1900
0385 #  ifndef BOOST_MATH_INT_TABLE_TYPE
0386 #    define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
0387 #  endif
0388 #  ifndef BOOST_MATH_INT_VALUE_SUFFIX
0389 #    define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
0390 #  endif
0391 #endif
0392 
0393 #elif defined(__INTEL_COMPILER)
0394 #  ifndef BOOST_MATH_POLY_METHOD
0395 #    define BOOST_MATH_POLY_METHOD 2
0396 #  endif
0397 #  ifndef BOOST_MATH_RATIONAL_METHOD
0398 #    define BOOST_MATH_RATIONAL_METHOD 1
0399 #  endif
0400 
0401 #elif defined(__GNUC__)
0402 #  ifndef BOOST_MATH_POLY_METHOD
0403 #    define BOOST_MATH_POLY_METHOD 3
0404 #  endif
0405 #  ifndef BOOST_MATH_RATIONAL_METHOD
0406 #    define BOOST_MATH_RATIONAL_METHOD 3
0407 #  endif
0408 
0409 #elif defined(__clang__)
0410 
0411 #if __clang__ > 6
0412 #  ifndef BOOST_MATH_POLY_METHOD
0413 #    define BOOST_MATH_POLY_METHOD 3
0414 #  endif
0415 #  ifndef BOOST_MATH_RATIONAL_METHOD
0416 #    define BOOST_MATH_RATIONAL_METHOD 3
0417 #  endif
0418 #  ifndef BOOST_MATH_INT_TABLE_TYPE
0419 #    define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
0420 #  endif
0421 #  ifndef BOOST_MATH_INT_VALUE_SUFFIX
0422 #    define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
0423 #  endif
0424 #endif
0425 
0426 #endif
0427 
0428 //
0429 // noexcept support:
0430 //
0431 #include <type_traits>
0432 #define BOOST_MATH_NOEXCEPT(T) noexcept(std::is_floating_point<T>::value)
0433 #define BOOST_MATH_IS_FLOAT(T) (std::is_floating_point<T>::value)
0434 
0435 //
0436 // The maximum order of polynomial that will be evaluated 
0437 // via an unrolled specialisation:
0438 //
0439 #ifndef BOOST_MATH_MAX_POLY_ORDER
0440 #  define BOOST_MATH_MAX_POLY_ORDER 20
0441 #endif 
0442 //
0443 // Set the method used to evaluate polynomials and rationals:
0444 //
0445 #ifndef BOOST_MATH_POLY_METHOD
0446 #  define BOOST_MATH_POLY_METHOD 2
0447 #endif 
0448 #ifndef BOOST_MATH_RATIONAL_METHOD
0449 #  define BOOST_MATH_RATIONAL_METHOD 1
0450 #endif 
0451 //
0452 // decide whether to store constants as integers or reals:
0453 //
0454 #ifndef BOOST_MATH_INT_TABLE_TYPE
0455 #  define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
0456 #endif
0457 #ifndef BOOST_MATH_INT_VALUE_SUFFIX
0458 #  define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF
0459 #endif
0460 //
0461 // And then the actual configuration:
0462 //
0463 #if defined(BOOST_MATH_STANDALONE) && defined(_GLIBCXX_USE_FLOAT128) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && !defined(__STRICT_ANSI__) \
0464    && !defined(BOOST_MATH_DISABLE_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
0465 #  define BOOST_MATH_USE_FLOAT128
0466 #elif defined(BOOST_HAS_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
0467 #  define BOOST_MATH_USE_FLOAT128
0468 #endif
0469 #ifdef BOOST_MATH_USE_FLOAT128
0470 //
0471 // Only enable this when the compiler really is GCC as clang and probably 
0472 // intel too don't support __float128 yet :-(
0473 //
0474 #  if defined(__INTEL_COMPILER) && defined(__GNUC__)
0475 #    if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
0476 #      define BOOST_MATH_FLOAT128_TYPE __float128
0477 #    endif
0478 #  elif defined(__GNUC__)
0479 #      define BOOST_MATH_FLOAT128_TYPE __float128
0480 #  endif
0481 
0482 #  ifndef BOOST_MATH_FLOAT128_TYPE
0483 #      define BOOST_MATH_FLOAT128_TYPE _Quad
0484 #  endif
0485 #endif
0486 //
0487 // Check for WinCE with no iostream support:
0488 //
0489 #if defined(_WIN32_WCE) && !defined(__SGI_STL_PORT)
0490 #  define BOOST_MATH_NO_LEXICAL_CAST
0491 #endif
0492 
0493 //
0494 // Helper macro for controlling the FP behaviour:
0495 //
0496 #ifndef BOOST_MATH_CONTROL_FP
0497 #  define BOOST_MATH_CONTROL_FP
0498 #endif
0499 //
0500 // Helper macro for using statements:
0501 //
0502 #define BOOST_MATH_STD_USING_CORE \
0503    using std::abs;\
0504    using std::acos;\
0505    using std::cos;\
0506    using std::fmod;\
0507    using std::modf;\
0508    using std::tan;\
0509    using std::asin;\
0510    using std::cosh;\
0511    using std::frexp;\
0512    using std::pow;\
0513    using std::tanh;\
0514    using std::atan;\
0515    using std::exp;\
0516    using std::ldexp;\
0517    using std::sin;\
0518    using std::atan2;\
0519    using std::fabs;\
0520    using std::log;\
0521    using std::sinh;\
0522    using std::ceil;\
0523    using std::floor;\
0524    using std::log10;\
0525    using std::sqrt;
0526 
0527 #define BOOST_MATH_STD_USING BOOST_MATH_STD_USING_CORE
0528 
0529 namespace boost{ namespace math{
0530 namespace tools
0531 {
0532 
0533 template <class T>
0534 inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) BOOST_MATH_NOEXCEPT(T)
0535 {
0536    return (std::max)((std::max)(a, b), c);
0537 }
0538 
0539 template <class T>
0540 inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) BOOST_MATH_NOEXCEPT(T)
0541 {
0542    return (std::max)((std::max)(a, b), (std::max)(c, d));
0543 }
0544 
0545 } // namespace tools
0546 
0547 template <class T>
0548 void suppress_unused_variable_warning(const T&) BOOST_MATH_NOEXCEPT(T)
0549 {
0550 }
0551 
0552 namespace detail{
0553 
0554 template <class T>
0555 struct is_integer_for_rounding
0556 {
0557    static constexpr bool value = std::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer);
0558 };
0559 
0560 }
0561 
0562 }} // namespace boost namespace math
0563 
0564 #ifdef __GLIBC_PREREQ
0565 #  if __GLIBC_PREREQ(2,14)
0566 #     define BOOST_MATH_HAVE_FIXED_GLIBC
0567 #  endif
0568 #endif
0569 
0570 #if ((defined(__linux__) && !defined(__UCLIBC__) && !defined(BOOST_MATH_HAVE_FIXED_GLIBC)) || defined(__QNX__) || defined(__IBMCPP__))
0571 //
0572 // This code was introduced in response to this glibc bug: http://sourceware.org/bugzilla/show_bug.cgi?id=2445
0573 // Basically powl and expl can return garbage when the result is small and certain exception flags are set
0574 // on entrance to these functions.  This appears to have been fixed in Glibc 2.14 (May 2011).
0575 // Much more information in this message thread: https://groups.google.com/forum/#!topic/boost-list/ZT99wtIFlb4
0576 //
0577 
0578 #include <cfenv>
0579 
0580 #  ifdef FE_ALL_EXCEPT
0581 
0582 namespace boost{ namespace math{
0583    namespace detail
0584    {
0585    struct fpu_guard
0586    {
0587       fpu_guard()
0588       {
0589          fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
0590          feclearexcept(FE_ALL_EXCEPT);
0591       }
0592       ~fpu_guard()
0593       {
0594          fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
0595       }
0596    private:
0597       fexcept_t m_flags;
0598    };
0599 
0600    } // namespace detail
0601    }} // namespaces
0602 
0603 #    define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
0604 #    define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0); 
0605 
0606 #  else
0607 
0608 #    define BOOST_FPU_EXCEPTION_GUARD
0609 #    define BOOST_MATH_INSTRUMENT_FPU
0610 
0611 #  endif
0612 
0613 #else // All other platforms.
0614 #  define BOOST_FPU_EXCEPTION_GUARD
0615 #  define BOOST_MATH_INSTRUMENT_FPU
0616 #endif
0617 
0618 #ifdef BOOST_MATH_INSTRUMENT
0619 
0620 #  include <iostream>
0621 #  include <iomanip>
0622 #  include <typeinfo>
0623 
0624 #  define BOOST_MATH_INSTRUMENT_CODE(x) \
0625       std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
0626 #  define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(#name << " = " << name)
0627 
0628 #else
0629 
0630 #  define BOOST_MATH_INSTRUMENT_CODE(x)
0631 #  define BOOST_MATH_INSTRUMENT_VARIABLE(name)
0632 
0633 #endif
0634 
0635 //
0636 // Thread local storage:
0637 //
0638 #ifndef BOOST_MATH_DISABLE_THREADS
0639 #  define BOOST_MATH_THREAD_LOCAL thread_local
0640 #else
0641 #  define BOOST_MATH_THREAD_LOCAL 
0642 #endif
0643 
0644 //
0645 // Some mingw flavours have issues with thread_local and types with non-trivial destructors
0646 // See https://sourceforge.net/p/mingw-w64/bugs/527/
0647 //
0648 #if (defined(__MINGW32__) && (__GNUC__ < 9) && !defined(__clang__))
0649 #  define BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES
0650 #endif
0651 
0652 
0653 //
0654 // Can we have constexpr tables?
0655 //
0656 #if (!defined(BOOST_MATH_NO_CXX14_CONSTEXPR)) || (defined(_MSC_VER) && _MSC_VER >= 1910)
0657 #define BOOST_MATH_HAVE_CONSTEXPR_TABLES
0658 #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION constexpr
0659 #else
0660 #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION
0661 #endif
0662 
0663 
0664 #endif // BOOST_MATH_TOOLS_CONFIG_HPP
0665 
0666 
0667 
0668