config.hpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. // Copyright (c) 2006-7 John Maddock
  2. // Copyright (c) 2021 Matt Borland
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #ifndef BOOST_MATH_TOOLS_CONFIG_HPP
  7. #define BOOST_MATH_TOOLS_CONFIG_HPP
  8. #ifdef _MSC_VER
  9. #pragma once
  10. #endif
  11. #include <boost/math/tools/is_standalone.hpp>
  12. // Minimum language standard transition
  13. #ifdef _MSVC_LANG
  14. # if _MSVC_LANG < 201402L
  15. # pragma message("Boost.Math requires C++14");
  16. # endif
  17. # if _MSC_VER == 1900
  18. # pragma message("MSVC 14.0 has broken C++14 constexpr support. Support for this compiler will be removed in Boost 1.86")
  19. # endif
  20. #else
  21. # if __cplusplus < 201402L
  22. # warning "Boost.Math requires C++14"
  23. # endif
  24. #endif
  25. #ifndef BOOST_MATH_STANDALONE
  26. #include <boost/config.hpp>
  27. // The following are all defined as standalone macros as well
  28. // If Boost.Config is available just use those definitions because they are more fine-grained
  29. // Could be defined in TR1
  30. #ifndef BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
  31. # define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION BOOST_PREVENT_MACRO_SUBSTITUTION
  32. #endif
  33. #define BOOST_MATH_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
  34. #ifdef BOOST_NO_CXX14_CONSTEXPR
  35. # define BOOST_MATH_NO_CXX14_CONSTEXPR
  36. #endif
  37. #define BOOST_MATH_IF_CONSTEXPR BOOST_IF_CONSTEXPR
  38. #ifdef BOOST_NO_CXX17_IF_CONSTEXPR
  39. # define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
  40. #endif
  41. #ifdef BOOST_NO_CXX17_HDR_EXECUTION
  42. # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
  43. #endif
  44. #ifdef BOOST_HAS_THREADS
  45. # define BOOST_MATH_HAS_THREADS
  46. #endif
  47. #ifdef BOOST_DISABLE_THREADS
  48. # define BOOST_MATH_DISABLE_THREADS
  49. #endif
  50. #ifdef BOOST_NO_CXX11_THREAD_LOCAL
  51. # define BOOST_MATH_NO_CXX11_THREAD_LOCAL
  52. #endif
  53. #ifdef BOOST_NO_EXCEPTIONS
  54. # define BOOST_MATH_NO_EXCEPTIONS
  55. #endif
  56. #ifdef BOOST_NO_TYPEID
  57. # define BOOST_MATH_NO_TYPEID
  58. #endif
  59. #ifdef BOOST_NO_RTTI
  60. # define BOOST_MATH_NO_RTTI
  61. #endif
  62. #define BOOST_MATH_NOINLINE BOOST_NOINLINE
  63. #define BOOST_MATH_FORCEINLINE BOOST_FORCEINLINE
  64. #define BOOST_MATH_JOIN(X, Y) BOOST_JOIN(X, Y)
  65. #define BOOST_MATH_STRINGIZE(X) BOOST_STRINGIZE(X)
  66. #else // Things from boost/config that are required, and easy to replicate
  67. #define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
  68. #define BOOST_MATH_NO_REAL_CONCEPT_TESTS
  69. #define BOOST_MATH_NO_DISTRIBUTION_CONCEPT_TESTS
  70. #define BOOST_MATH_NO_LEXICAL_CAST
  71. // Since Boost.Multiprecision is in active development some tests do not fully cooperate yet.
  72. #define BOOST_MATH_NO_MP_TESTS
  73. #if (__cplusplus > 201400L || _MSVC_LANG > 201400L)
  74. #define BOOST_MATH_CXX14_CONSTEXPR constexpr
  75. #else
  76. #define BOOST_MATH_CXX14_CONSTEXPR
  77. #define BOOST_MATH_NO_CXX14_CONSTEXPR
  78. #endif // BOOST_MATH_CXX14_CONSTEXPR
  79. #if (__cplusplus > 201700L || _MSVC_LANG > 201700L)
  80. #define BOOST_MATH_IF_CONSTEXPR if constexpr
  81. // Clang on mac provides the execution header with none of the functionality. TODO: Check back on this
  82. // https://en.cppreference.com/w/cpp/compiler_support "Standardization of Parallelism TS"
  83. # if !__has_include(<execution>) || (defined(__APPLE__) && defined(__clang__))
  84. # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
  85. # endif
  86. #else
  87. # define BOOST_MATH_IF_CONSTEXPR if
  88. # define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
  89. # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
  90. #endif
  91. #if __cpp_lib_gcd_lcm >= 201606L
  92. #define BOOST_MATH_HAS_CXX17_NUMERIC
  93. #endif
  94. #define BOOST_MATH_JOIN(X, Y) BOOST_MATH_DO_JOIN(X, Y)
  95. #define BOOST_MATH_DO_JOIN(X, Y) BOOST_MATH_DO_JOIN2(X,Y)
  96. #define BOOST_MATH_DO_JOIN2(X, Y) X##Y
  97. #define BOOST_MATH_STRINGIZE(X) BOOST_MATH_DO_STRINGIZE(X)
  98. #define BOOST_MATH_DO_STRINGIZE(X) #X
  99. #ifdef BOOST_MATH_DISABLE_THREADS // No threads, do nothing
  100. // Detect thread support via STL implementation
  101. #elif defined(__has_include)
  102. # if !__has_include(<thread>) || !__has_include(<mutex>) || !__has_include(<future>) || !__has_include(<atomic>)
  103. # define BOOST_MATH_DISABLE_THREADS
  104. # else
  105. # define BOOST_MATH_HAS_THREADS
  106. # endif
  107. #else
  108. # define BOOST_MATH_HAS_THREADS // The default assumption is that the machine has threads
  109. #endif // Thread Support
  110. #ifdef BOOST_MATH_DISABLE_THREADS
  111. # define BOOST_MATH_NO_CXX11_THREAD_LOCAL
  112. #endif // BOOST_MATH_DISABLE_THREADS
  113. #ifdef __GNUC__
  114. # if !defined(__EXCEPTIONS) && !defined(BOOST_MATH_NO_EXCEPTIONS)
  115. # define BOOST_MATH_NO_EXCEPTIONS
  116. # endif
  117. //
  118. // Make sure we have some std lib headers included so we can detect __GXX_RTTI:
  119. //
  120. # include <algorithm> // for min and max
  121. # include <limits>
  122. # ifndef __GXX_RTTI
  123. # ifndef BOOST_MATH_NO_TYPEID
  124. # define BOOST_MATH_NO_TYPEID
  125. # endif
  126. # ifndef BOOST_MATH_NO_RTTI
  127. # define BOOST_MATH_NO_RTTI
  128. # endif
  129. # endif
  130. #endif
  131. #if !defined(BOOST_MATH_NOINLINE)
  132. # if defined(_MSC_VER)
  133. # define BOOST_MATH_NOINLINE __declspec(noinline)
  134. # elif defined(__GNUC__) && __GNUC__ > 3
  135. // Clang also defines __GNUC__ (as 4)
  136. # if defined(__CUDACC__)
  137. // nvcc doesn't always parse __noinline__,
  138. // see: https://svn.boost.org/trac/boost/ticket/9392
  139. # define BOOST_MATH_NOINLINE __attribute__ ((noinline))
  140. # elif defined(__HIP__)
  141. // See https://github.com/boostorg/config/issues/392
  142. # define BOOST_MATH_NOINLINE __attribute__ ((noinline))
  143. # else
  144. # define BOOST_MATH_NOINLINE __attribute__ ((__noinline__))
  145. # endif
  146. # else
  147. # define BOOST_MATH_NOINLINE
  148. # endif
  149. #endif
  150. #if !defined(BOOST_MATH_FORCEINLINE)
  151. # if defined(_MSC_VER)
  152. # define BOOST_MATH_FORCEINLINE __forceinline
  153. # elif defined(__GNUC__) && __GNUC__ > 3
  154. // Clang also defines __GNUC__ (as 4)
  155. # define BOOST_MATH_FORCEINLINE inline __attribute__ ((__always_inline__))
  156. # else
  157. # define BOOST_MATH_FORCEINLINE inline
  158. # endif
  159. #endif
  160. #endif // BOOST_MATH_STANDALONE
  161. // Support compilers with P0024R2 implemented without linking TBB
  162. // https://en.cppreference.com/w/cpp/compiler_support
  163. #if !defined(BOOST_MATH_NO_CXX17_HDR_EXECUTION) && defined(BOOST_MATH_HAS_THREADS)
  164. # define BOOST_MATH_EXEC_COMPATIBLE
  165. #endif
  166. // C++23
  167. #if __cplusplus > 202002L || (defined(_MSVC_LANG) &&_MSVC_LANG > 202002L)
  168. # if __GNUC__ >= 13
  169. // libstdc++3 only defines to/from_chars for std::float128_t when one of these defines are set
  170. // otherwise we're right out of luck...
  171. # if defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) || defined(_GLIBCXX_HAVE_FLOAT128_MATH)
  172. # include <cstring> // std::strlen is used with from_chars
  173. # include <charconv>
  174. # include <stdfloat>
  175. # define BOOST_MATH_USE_CHARCONV_FOR_CONVERSION
  176. # endif
  177. # endif
  178. #endif
  179. #include <algorithm> // for min and max
  180. #include <limits>
  181. #include <cmath>
  182. #include <climits>
  183. #include <cfloat>
  184. #include <boost/math/tools/user.hpp>
  185. #if (defined(__NetBSD__) || defined(__EMSCRIPTEN__)\
  186. || (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
  187. && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  188. //# define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  189. #endif
  190. #ifdef __IBMCPP__
  191. //
  192. // For reasons I don't understand, the tests with IMB's compiler all
  193. // pass at long double precision, but fail with real_concept, those tests
  194. // are disabled for now. (JM 2012).
  195. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  196. # define BOOST_MATH_NO_REAL_CONCEPT_TESTS
  197. #endif // BOOST_MATH_NO_REAL_CONCEPT_TESTS
  198. #endif
  199. #ifdef sun
  200. // Any use of __float128 in program startup code causes a segfault (tested JM 2015, Solaris 11).
  201. # define BOOST_MATH_DISABLE_FLOAT128
  202. #endif
  203. #ifdef __HAIKU__
  204. //
  205. // Not sure what's up with the math detection on Haiku, but linking fails with
  206. // float128 code enabled, and we don't have an implementation of __expl, so
  207. // disabling long double functions for now as well.
  208. # define BOOST_MATH_DISABLE_FLOAT128
  209. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  210. #endif
  211. #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  212. //
  213. // Darwin's rather strange "double double" is rather hard to
  214. // support, it should be possible given enough effort though...
  215. //
  216. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  217. #endif
  218. #if !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) && (LDBL_MANT_DIG == 106) && (LDBL_MIN_EXP > DBL_MIN_EXP)
  219. //
  220. // Generic catch all case for gcc's "double-double" long double type.
  221. // We do not support this as it's not even remotely IEEE conforming:
  222. //
  223. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  224. #endif
  225. #if defined(unix) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1000) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  226. //
  227. // Intel compiler prior to version 10 has sporadic problems
  228. // calling the long double overloads of the std lib math functions:
  229. // calling ::powl is OK, but std::pow(long double, long double)
  230. // may segfault depending upon the value of the arguments passed
  231. // and the specific Linux distribution.
  232. //
  233. // We'll be conservative and disable long double support for this compiler.
  234. //
  235. // Comment out this #define and try building the tests to determine whether
  236. // your Intel compiler version has this issue or not.
  237. //
  238. # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  239. #endif
  240. #if defined(unix) && defined(__INTEL_COMPILER)
  241. //
  242. // Intel compiler has sporadic issues compiling std::fpclassify depending on
  243. // the exact OS version used. Use our own code for this as we know it works
  244. // well on Intel processors:
  245. //
  246. #define BOOST_MATH_DISABLE_STD_FPCLASSIFY
  247. #endif
  248. #if defined(_MSC_VER) && !defined(_WIN32_WCE)
  249. // Better safe than sorry, our tests don't support hardware exceptions:
  250. # define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
  251. #endif
  252. #ifdef __IBMCPP__
  253. # define BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS
  254. #endif
  255. #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))
  256. # define BOOST_MATH_USE_C99
  257. #endif
  258. #if (defined(__hpux) && !defined(__hppa))
  259. # define BOOST_MATH_USE_C99
  260. #endif
  261. #if defined(__GNUC__) && defined(_GLIBCXX_USE_C99)
  262. # define BOOST_MATH_USE_C99
  263. #endif
  264. #if defined(_LIBCPP_VERSION) && !defined(_MSC_VER)
  265. # define BOOST_MATH_USE_C99
  266. #endif
  267. #if defined(__CYGWIN__) || defined(__HP_aCC) || defined(__INTEL_COMPILER) \
  268. || defined(BOOST_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) \
  269. || (defined(__GNUC__) && !defined(BOOST_MATH_USE_C99))\
  270. || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  271. # define BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY
  272. #endif
  273. #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x590)
  274. namespace boost { namespace math { namespace tools { namespace detail {
  275. template <typename T>
  276. struct type {};
  277. template <typename T, T n>
  278. struct non_type {};
  279. }}}} // Namespace boost, math tools, detail
  280. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) boost::math::tools::detail::type<t>* = 0
  281. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::math::tools::detail::type<t>*
  282. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::math::tools::detail::non_type<t, v>* = 0
  283. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::math::tools::detail::non_type<t, v>*
  284. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \
  285. , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
  286. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \
  287. , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
  288. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \
  289. , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
  290. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \
  291. , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
  292. #else
  293. // no workaround needed: expand to nothing
  294. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
  295. # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
  296. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
  297. # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
  298. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
  299. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
  300. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
  301. # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
  302. #endif // __SUNPRO_CC
  303. #if (defined(__SUNPRO_CC) || defined(__hppa) || defined(__GNUC__)) && !defined(BOOST_MATH_SMALL_CONSTANT)
  304. // Sun's compiler emits a hard error if a constant underflows,
  305. // as does aCC on PA-RISC, while gcc issues a large number of warnings:
  306. # define BOOST_MATH_SMALL_CONSTANT(x) 0.0
  307. #else
  308. # define BOOST_MATH_SMALL_CONSTANT(x) x
  309. #endif
  310. //
  311. // Tune performance options for specific compilers,
  312. // but check at each step that nothing has been previously defined by the user first
  313. //
  314. #ifdef _MSC_VER
  315. # ifndef BOOST_MATH_POLY_METHOD
  316. # define BOOST_MATH_POLY_METHOD 2
  317. # endif
  318. #if _MSC_VER <= 1900
  319. # ifndef BOOST_MATH_POLY_METHOD
  320. # define BOOST_MATH_RATIONAL_METHOD 1
  321. # endif
  322. #else
  323. # ifndef BOOST_MATH_RATIONAL_METHOD
  324. # define BOOST_MATH_RATIONAL_METHOD 2
  325. # endif
  326. #endif
  327. #if _MSC_VER > 1900
  328. # ifndef BOOST_MATH_INT_TABLE_TYPE
  329. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
  330. # endif
  331. # ifndef BOOST_MATH_INT_VALUE_SUFFIX
  332. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
  333. # endif
  334. #endif
  335. #elif defined(__INTEL_COMPILER)
  336. # ifndef BOOST_MATH_POLY_METHOD
  337. # define BOOST_MATH_POLY_METHOD 2
  338. # endif
  339. # ifndef BOOST_MATH_RATIONAL_METHOD
  340. # define BOOST_MATH_RATIONAL_METHOD 1
  341. # endif
  342. #elif defined(__GNUC__)
  343. # ifndef BOOST_MATH_POLY_METHOD
  344. # define BOOST_MATH_POLY_METHOD 3
  345. # endif
  346. # ifndef BOOST_MATH_RATIONAL_METHOD
  347. # define BOOST_MATH_RATIONAL_METHOD 3
  348. # endif
  349. #elif defined(__clang__)
  350. #if __clang__ > 6
  351. # ifndef BOOST_MATH_POLY_METHOD
  352. # define BOOST_MATH_POLY_METHOD 3
  353. # endif
  354. # ifndef BOOST_MATH_RATIONAL_METHOD
  355. # define BOOST_MATH_RATIONAL_METHOD 3
  356. # endif
  357. # ifndef BOOST_MATH_INT_TABLE_TYPE
  358. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
  359. # endif
  360. # ifndef BOOST_MATH_INT_VALUE_SUFFIX
  361. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
  362. # endif
  363. #endif
  364. #endif
  365. //
  366. // noexcept support:
  367. //
  368. #include <type_traits>
  369. #define BOOST_MATH_NOEXCEPT(T) noexcept(std::is_floating_point<T>::value)
  370. #define BOOST_MATH_IS_FLOAT(T) (std::is_floating_point<T>::value)
  371. //
  372. // The maximum order of polynomial that will be evaluated
  373. // via an unrolled specialisation:
  374. //
  375. #ifndef BOOST_MATH_MAX_POLY_ORDER
  376. # define BOOST_MATH_MAX_POLY_ORDER 20
  377. #endif
  378. //
  379. // Set the method used to evaluate polynomials and rationals:
  380. //
  381. #ifndef BOOST_MATH_POLY_METHOD
  382. # define BOOST_MATH_POLY_METHOD 2
  383. #endif
  384. #ifndef BOOST_MATH_RATIONAL_METHOD
  385. # define BOOST_MATH_RATIONAL_METHOD 1
  386. #endif
  387. //
  388. // decide whether to store constants as integers or reals:
  389. //
  390. #ifndef BOOST_MATH_INT_TABLE_TYPE
  391. # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
  392. #endif
  393. #ifndef BOOST_MATH_INT_VALUE_SUFFIX
  394. # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF
  395. #endif
  396. //
  397. // And then the actual configuration:
  398. //
  399. #if defined(BOOST_MATH_STANDALONE) && defined(_GLIBCXX_USE_FLOAT128) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && !defined(__STRICT_ANSI__) \
  400. && !defined(BOOST_MATH_DISABLE_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
  401. # define BOOST_MATH_USE_FLOAT128
  402. #elif defined(BOOST_HAS_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
  403. # define BOOST_MATH_USE_FLOAT128
  404. #endif
  405. #ifdef BOOST_MATH_USE_FLOAT128
  406. //
  407. // Only enable this when the compiler really is GCC as clang and probably
  408. // intel too don't support __float128 yet :-(
  409. //
  410. # if defined(__INTEL_COMPILER) && defined(__GNUC__)
  411. # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
  412. # define BOOST_MATH_FLOAT128_TYPE __float128
  413. # endif
  414. # elif defined(__GNUC__)
  415. # define BOOST_MATH_FLOAT128_TYPE __float128
  416. # endif
  417. # ifndef BOOST_MATH_FLOAT128_TYPE
  418. # define BOOST_MATH_FLOAT128_TYPE _Quad
  419. # endif
  420. #endif
  421. //
  422. // Check for WinCE with no iostream support:
  423. //
  424. #if defined(_WIN32_WCE) && !defined(__SGI_STL_PORT)
  425. # define BOOST_MATH_NO_LEXICAL_CAST
  426. #endif
  427. //
  428. // Helper macro for controlling the FP behaviour:
  429. //
  430. #ifndef BOOST_MATH_CONTROL_FP
  431. # define BOOST_MATH_CONTROL_FP
  432. #endif
  433. //
  434. // Helper macro for using statements:
  435. //
  436. #define BOOST_MATH_STD_USING_CORE \
  437. using std::abs;\
  438. using std::acos;\
  439. using std::cos;\
  440. using std::fmod;\
  441. using std::modf;\
  442. using std::tan;\
  443. using std::asin;\
  444. using std::cosh;\
  445. using std::frexp;\
  446. using std::pow;\
  447. using std::tanh;\
  448. using std::atan;\
  449. using std::exp;\
  450. using std::ldexp;\
  451. using std::sin;\
  452. using std::atan2;\
  453. using std::fabs;\
  454. using std::log;\
  455. using std::sinh;\
  456. using std::ceil;\
  457. using std::floor;\
  458. using std::log10;\
  459. using std::sqrt;
  460. #define BOOST_MATH_STD_USING BOOST_MATH_STD_USING_CORE
  461. namespace boost{ namespace math{
  462. namespace tools
  463. {
  464. template <class T>
  465. inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) BOOST_MATH_NOEXCEPT(T)
  466. {
  467. return (std::max)((std::max)(a, b), c);
  468. }
  469. template <class T>
  470. inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) BOOST_MATH_NOEXCEPT(T)
  471. {
  472. return (std::max)((std::max)(a, b), (std::max)(c, d));
  473. }
  474. } // namespace tools
  475. template <class T>
  476. void suppress_unused_variable_warning(const T&) BOOST_MATH_NOEXCEPT(T)
  477. {
  478. }
  479. namespace detail{
  480. template <class T>
  481. struct is_integer_for_rounding
  482. {
  483. static constexpr bool value = std::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer);
  484. };
  485. }
  486. }} // namespace boost namespace math
  487. #ifdef __GLIBC_PREREQ
  488. # if __GLIBC_PREREQ(2,14)
  489. # define BOOST_MATH_HAVE_FIXED_GLIBC
  490. # endif
  491. #endif
  492. #if ((defined(__linux__) && !defined(__UCLIBC__) && !defined(BOOST_MATH_HAVE_FIXED_GLIBC)) || defined(__QNX__) || defined(__IBMCPP__))
  493. //
  494. // This code was introduced in response to this glibc bug: http://sourceware.org/bugzilla/show_bug.cgi?id=2445
  495. // Basically powl and expl can return garbage when the result is small and certain exception flags are set
  496. // on entrance to these functions. This appears to have been fixed in Glibc 2.14 (May 2011).
  497. // Much more information in this message thread: https://groups.google.com/forum/#!topic/boost-list/ZT99wtIFlb4
  498. //
  499. #include <cfenv>
  500. # ifdef FE_ALL_EXCEPT
  501. namespace boost{ namespace math{
  502. namespace detail
  503. {
  504. struct fpu_guard
  505. {
  506. fpu_guard()
  507. {
  508. fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
  509. feclearexcept(FE_ALL_EXCEPT);
  510. }
  511. ~fpu_guard()
  512. {
  513. fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
  514. }
  515. private:
  516. fexcept_t m_flags;
  517. };
  518. } // namespace detail
  519. }} // namespaces
  520. # define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
  521. # define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0);
  522. # else
  523. # define BOOST_FPU_EXCEPTION_GUARD
  524. # define BOOST_MATH_INSTRUMENT_FPU
  525. # endif
  526. #else // All other platforms.
  527. # define BOOST_FPU_EXCEPTION_GUARD
  528. # define BOOST_MATH_INSTRUMENT_FPU
  529. #endif
  530. #ifdef BOOST_MATH_INSTRUMENT
  531. # include <iostream>
  532. # include <iomanip>
  533. # include <typeinfo>
  534. # define BOOST_MATH_INSTRUMENT_CODE(x) \
  535. std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
  536. # define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(#name << " = " << name)
  537. #else
  538. # define BOOST_MATH_INSTRUMENT_CODE(x)
  539. # define BOOST_MATH_INSTRUMENT_VARIABLE(name)
  540. #endif
  541. //
  542. // Thread local storage:
  543. //
  544. #ifndef BOOST_MATH_DISABLE_THREADS
  545. # define BOOST_MATH_THREAD_LOCAL thread_local
  546. #else
  547. # define BOOST_MATH_THREAD_LOCAL
  548. #endif
  549. //
  550. // Some mingw flavours have issues with thread_local and types with non-trivial destructors
  551. // See https://sourceforge.net/p/mingw-w64/bugs/527/
  552. //
  553. #if (defined(__MINGW32__) && (__GNUC__ < 9) && !defined(__clang__))
  554. # define BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES
  555. #endif
  556. //
  557. // Can we have constexpr tables?
  558. //
  559. #if (!defined(BOOST_MATH_NO_CXX14_CONSTEXPR)) || (defined(_MSC_VER) && _MSC_VER >= 1910)
  560. #define BOOST_MATH_HAVE_CONSTEXPR_TABLES
  561. #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION constexpr
  562. #else
  563. #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION
  564. #endif
  565. #endif // BOOST_MATH_TOOLS_CONFIG_HPP