Debian Codegraph @

third-party/boost-math/include/boost/math/tools/config.hpp

raw
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
7 #ifndef BOOST_MATH_TOOLS_CONFIG_HPP
8 #define BOOST_MATH_TOOLS_CONFIG_HPP
9
10 #ifdef _MSC_VER
11 #pragma once
12 #endif
13
14 #ifndef __CUDACC_RTC__
15
16 #include <boost/math/tools/is_standalone.hpp>
17
18 // Minimum language standard transition
19 #ifdef _MSVC_LANG
20 # if _MSVC_LANG < 201402L
21 # pragma message("Boost.Math requires C++14");
22 # endif
23 # if _MSC_VER == 1900
24 # pragma message("MSVC 14.0 has broken C++14 constexpr support. Support for this compiler will be removed in Boost 1.86")
25 # endif
26 #else
27 # if __cplusplus < 201402L
28 # warning "Boost.Math requires C++14"
29 # endif
30 #endif
31
32 #ifndef BOOST_MATH_STANDALONE
33 #include <boost/config.hpp>
34
35
36 // The following are all defined as standalone macros as well
37 // If Boost.Config is available just use those definitions because they are more fine-grained
38
39 // Could be defined in TR1
40 #ifndef BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
41 # define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION BOOST_PREVENT_MACRO_SUBSTITUTION
42 #endif
43
44 #define BOOST_MATH_CXX14_CONSTEXPR BOOST_CXX14_CONSTEXPR
45 #ifdef BOOST_NO_CXX14_CONSTEXPR
46 # define BOOST_MATH_NO_CXX14_CONSTEXPR
47 #endif
48
49 #define BOOST_MATH_IF_CONSTEXPR BOOST_IF_CONSTEXPR
50 #ifdef BOOST_NO_CXX17_IF_CONSTEXPR
51 # define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
52 #endif
53
54 #ifdef BOOST_NO_CXX17_HDR_EXECUTION
55 # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
56 #endif
57
58 #ifdef BOOST_HAS_THREADS
59 # define BOOST_MATH_HAS_THREADS
60 #endif
61 #ifdef BOOST_DISABLE_THREADS
62 # define BOOST_MATH_DISABLE_THREADS
63 #endif
64 #ifdef BOOST_NO_CXX11_THREAD_LOCAL
65 # define BOOST_MATH_NO_CXX11_THREAD_LOCAL
66 #endif
67
68 #ifdef BOOST_NO_EXCEPTIONS
69 # define BOOST_MATH_NO_EXCEPTIONS
70 #endif
71
72 #ifdef BOOST_NO_TYPEID
73 # define BOOST_MATH_NO_TYPEID
74 #endif
75 #ifdef BOOST_NO_RTTI
76 # define BOOST_MATH_NO_RTTI
77 #endif
78
79 #define BOOST_MATH_NOINLINE BOOST_NOINLINE
80 #define BOOST_MATH_FORCEINLINE BOOST_FORCEINLINE
81
82 #define BOOST_MATH_JOIN(X, Y) BOOST_JOIN(X, Y)
83 #define BOOST_MATH_STRINGIZE(X) BOOST_STRINGIZE(X)
84
85 #else // Things from boost/config that are required, and easy to replicate
86
87 #define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
88 #define BOOST_MATH_NO_REAL_CONCEPT_TESTS
89 #define BOOST_MATH_NO_DISTRIBUTION_CONCEPT_TESTS
90 #define BOOST_MATH_NO_LEXICAL_CAST
91
92 // Since Boost.Multiprecision is in active development some tests do not fully cooperate yet.
93 #define BOOST_MATH_NO_MP_TESTS
94
95 #if ((__cplusplus > 201400L) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201400L)))
96 #define BOOST_MATH_CXX14_CONSTEXPR constexpr
97 #else
98 #define BOOST_MATH_CXX14_CONSTEXPR
99 #define BOOST_MATH_NO_CXX14_CONSTEXPR
100 #endif // BOOST_MATH_CXX14_CONSTEXPR
101
102 #if ((__cplusplus > 201700L) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201700L)))
103 #define BOOST_MATH_IF_CONSTEXPR if constexpr
104
105 // Clang on mac provides the execution header with none of the functionality. TODO: Check back on this
106 // https://en.cppreference.com/w/cpp/compiler_support "Standardization of Parallelism TS"
107 # if !__has_include(<execution>) || (defined(__APPLE__) && defined(__clang__))
108 # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
109 # endif
110 #else
111 # define BOOST_MATH_IF_CONSTEXPR if
112 # define BOOST_MATH_NO_CXX17_IF_CONSTEXPR
113 # define BOOST_MATH_NO_CXX17_HDR_EXECUTION
114 #endif
115
116 #if (defined(__cpp_lib_gcd_lcm) && (__cpp_lib_gcd_lcm >= 201606L))
117 #define BOOST_MATH_HAS_CXX17_NUMERIC
118 #endif
119
120 #define BOOST_MATH_JOIN(X, Y) BOOST_MATH_DO_JOIN(X, Y)
121 #define BOOST_MATH_DO_JOIN(X, Y) BOOST_MATH_DO_JOIN2(X,Y)
122 #define BOOST_MATH_DO_JOIN2(X, Y) X##Y
123
124 #define BOOST_MATH_STRINGIZE(X) BOOST_MATH_DO_STRINGIZE(X)
125 #define BOOST_MATH_DO_STRINGIZE(X) #X
126
127 #ifdef BOOST_MATH_DISABLE_THREADS // No threads, do nothing
128 // Detect thread support via STL implementation
129 #elif defined(__has_include)
130 # if !__has_include(<thread>) || !__has_include(<mutex>) || !__has_include(<future>) || !__has_include(<atomic>)
131 # define BOOST_MATH_DISABLE_THREADS
132 # else
133 # define BOOST_MATH_HAS_THREADS
134 # endif
135 #else
136 # define BOOST_MATH_HAS_THREADS // The default assumption is that the machine has threads
137 #endif // Thread Support
138
139 #ifdef BOOST_MATH_DISABLE_THREADS
140 # define BOOST_MATH_NO_CXX11_THREAD_LOCAL
141 #endif // BOOST_MATH_DISABLE_THREADS
142
143 #ifdef __GNUC__
144 # if !defined(__EXCEPTIONS) && !defined(BOOST_MATH_NO_EXCEPTIONS)
145 # define BOOST_MATH_NO_EXCEPTIONS
146 # endif
147 //
148 // Make sure we have some std lib headers included so we can detect __GXX_RTTI:
149 //
150 # include <algorithm> // for min and max
151 # include <limits>
152 # ifndef __GXX_RTTI
153 # ifndef BOOST_MATH_NO_TYPEID
154 # define BOOST_MATH_NO_TYPEID
155 # endif
156 # ifndef BOOST_MATH_NO_RTTI
157 # define BOOST_MATH_NO_RTTI
158 # endif
159 # endif
160 #endif
161
162 #if !defined(BOOST_MATH_NOINLINE)
163 # if defined(_MSC_VER)
164 # define BOOST_MATH_NOINLINE __declspec(noinline)
165 # elif defined(__GNUC__) && __GNUC__ > 3
166 // Clang also defines __GNUC__ (as 4)
167 # if defined(__CUDACC__)
168 // nvcc doesn't always parse __noinline__,
169 // see: https://svn.boost.org/trac/boost/ticket/9392
170 # define BOOST_MATH_NOINLINE __attribute__ ((noinline))
171 # elif defined(__HIP__)
172 // See https://github.com/boostorg/config/issues/392
173 # define BOOST_MATH_NOINLINE __attribute__ ((noinline))
174 # else
175 # define BOOST_MATH_NOINLINE __attribute__ ((__noinline__))
176 # endif
177 # else
178 # define BOOST_MATH_NOINLINE
179 # endif
180 #endif
181
182 #if !defined(BOOST_MATH_FORCEINLINE)
183 # if defined(_MSC_VER)
184 # define BOOST_MATH_FORCEINLINE __forceinline
185 # elif defined(__GNUC__) && __GNUC__ > 3
186 // Clang also defines __GNUC__ (as 4)
187 # define BOOST_MATH_FORCEINLINE inline __attribute__ ((__always_inline__))
188 # else
189 # define BOOST_MATH_FORCEINLINE inline
190 # endif
191 #endif
192
193 #endif // BOOST_MATH_STANDALONE
194
195 // Support compilers with P0024R2 implemented without linking TBB
196 // https://en.cppreference.com/w/cpp/compiler_support
197 #if !defined(BOOST_MATH_NO_CXX17_HDR_EXECUTION) && defined(BOOST_MATH_HAS_THREADS)
198 # define BOOST_MATH_EXEC_COMPATIBLE
199 #endif
200
201 // C++23
202 #if __cplusplus > 202002L || (defined(_MSVC_LANG) &&_MSVC_LANG > 202002L)
203 # if defined(__GNUC__) && __GNUC__ >= 13
204 // libstdc++3 only defines to/from_chars for std::float128_t when one of these defines are set
205 // otherwise we're right out of luck...
206 # if defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) || defined(_GLIBCXX_HAVE_FLOAT128_MATH)
207 # include <cstring> // std::strlen is used with from_chars
208 # include <charconv>
209 # include <stdfloat>
210 # define BOOST_MATH_USE_CHARCONV_FOR_CONVERSION
211 # endif
212 # endif
213 #endif
214
215 #include <algorithm> // for min and max
216 #include <limits>
217 #include <cmath>
218 #include <climits>
219 #include <cfloat>
220
221 #include <boost/math/tools/user.hpp>
222
223 #if (defined(__NetBSD__)\
224 || (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
225 && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
226 //# define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
227 #endif
228
229 #if defined(__EMSCRIPTEN__) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
230 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
231 #endif
232
233 #ifdef __IBMCPP__
234 //
235 // For reasons I don't understand, the tests with IMB's compiler all
236 // pass at long double precision, but fail with real_concept, those tests
237 // are disabled for now. (JM 2012).
238 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
239 # define BOOST_MATH_NO_REAL_CONCEPT_TESTS
240 #endif // BOOST_MATH_NO_REAL_CONCEPT_TESTS
241 #endif
242 #ifdef sun
243 // Any use of __float128 in program startup code causes a segfault (tested JM 2015, Solaris 11).
244 # define BOOST_MATH_DISABLE_FLOAT128
245 #endif
246 #ifdef __HAIKU__
247 //
248 // Not sure what's up with the math detection on Haiku, but linking fails with
249 // float128 code enabled, and we don't have an implementation of __expl, so
250 // disabling long double functions for now as well.
251 # define BOOST_MATH_DISABLE_FLOAT128
252 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
253 #endif
254 #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
255 //
256 // Darwin's rather strange "double double" is rather hard to
257 // support, it should be possible given enough effort though...
258 //
259 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
260 #endif
261 #if !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) && (LDBL_MANT_DIG == 106) && (LDBL_MIN_EXP > DBL_MIN_EXP)
262 //
263 // Generic catch all case for gcc's "double-double" long double type.
264 // We do not support this as it's not even remotely IEEE conforming:
265 //
266 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
267 #endif
268 #if defined(unix) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1000) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
269 //
270 // Intel compiler prior to version 10 has sporadic problems
271 // calling the long double overloads of the std lib math functions:
272 // calling ::powl is OK, but std::pow(long double, long double)
273 // may segfault depending upon the value of the arguments passed
274 // and the specific Linux distribution.
275 //
276 // We'll be conservative and disable long double support for this compiler.
277 //
278 // Comment out this #define and try building the tests to determine whether
279 // your Intel compiler version has this issue or not.
280 //
281 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
282 #endif
283 #if defined(unix) && defined(__INTEL_COMPILER)
284 //
285 // Intel compiler has sporadic issues compiling std::fpclassify depending on
286 // the exact OS version used. Use our own code for this as we know it works
287 // well on Intel processors:
288 //
289 #define BOOST_MATH_DISABLE_STD_FPCLASSIFY
290 #endif
291
292 #if defined(_MSC_VER) && !defined(_WIN32_WCE)
293 // Better safe than sorry, our tests don't support hardware exceptions:
294 # define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
295 #endif
296
297 #ifdef __IBMCPP__
298 # define BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS
299 #endif
300
301 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))
302 # define BOOST_MATH_USE_C99
303 #endif
304
305 #if (defined(__hpux) && !defined(__hppa))
306 # define BOOST_MATH_USE_C99
307 #endif
308
309 #if defined(__GNUC__) && defined(_GLIBCXX_USE_C99)
310 # define BOOST_MATH_USE_C99
311 #endif
312
313 #if defined(_LIBCPP_VERSION) && !defined(_MSC_VER)
314 # define BOOST_MATH_USE_C99
315 #endif
316
317 #if defined(__CYGWIN__) || defined(__HP_aCC) || defined(__INTEL_COMPILER) \
318 || defined(BOOST_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) \
319 || (defined(__GNUC__) && !defined(BOOST_MATH_USE_C99))\
320 || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
321 # define BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY
322 #endif
323
324 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x590)
325
326 namespace boost { namespace math { namespace tools { namespace detail {
327 template <typename T>
328 struct type {};
329
330 template <typename T, T n>
331 struct non_type {};
332 }}}} // Namespace boost, math tools, detail
333
334 # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t) boost::math::tools::detail::type<t>* = 0
335 # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t) boost::math::tools::detail::type<t>*
336 # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v) boost::math::tools::detail::non_type<t, v>* = 0
337 # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) boost::math::tools::detail::non_type<t, v>*
338
339 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t) \
340 , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
341 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t) \
342 , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
343 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v) \
344 , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
345 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v) \
346 , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
347
348 #else
349
350 // no workaround needed: expand to nothing
351
352 # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
353 # define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
354 # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
355 # define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
356
357 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
358 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
359 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
360 # define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
361
362
363 #endif // __SUNPRO_CC
364
365 #if (defined(__SUNPRO_CC) || defined(__hppa) || defined(__GNUC__)) && !defined(BOOST_MATH_SMALL_CONSTANT)
366 // Sun's compiler emits a hard error if a constant underflows,
367 // as does aCC on PA-RISC, while gcc issues a large number of warnings:
368 # define BOOST_MATH_SMALL_CONSTANT(x) 0.0
369 #else
370 # define BOOST_MATH_SMALL_CONSTANT(x) x
371 #endif
372
373 //
374 // Tune performance options for specific compilers,
375 // but check at each step that nothing has been previously defined by the user first
376 //
377 #ifdef _MSC_VER
378 # ifndef BOOST_MATH_POLY_METHOD
379 # define BOOST_MATH_POLY_METHOD 2
380 # endif
381 #if _MSC_VER <= 1900
382 # ifndef BOOST_MATH_POLY_METHOD
383 # define BOOST_MATH_RATIONAL_METHOD 1
384 # endif
385 #else
386 # ifndef BOOST_MATH_RATIONAL_METHOD
387 # define BOOST_MATH_RATIONAL_METHOD 2
388 # endif
389 #endif
390 #if _MSC_VER > 1900
391 # ifndef BOOST_MATH_INT_TABLE_TYPE
392 # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
393 # endif
394 # ifndef BOOST_MATH_INT_VALUE_SUFFIX
395 # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
396 # endif
397 #endif
398
399 #elif defined(__INTEL_COMPILER)
400 # ifndef BOOST_MATH_POLY_METHOD
401 # define BOOST_MATH_POLY_METHOD 2
402 # endif
403 # ifndef BOOST_MATH_RATIONAL_METHOD
404 # define BOOST_MATH_RATIONAL_METHOD 1
405 # endif
406
407 #elif defined(__GNUC__)
408 # ifndef BOOST_MATH_POLY_METHOD
409 # define BOOST_MATH_POLY_METHOD 3
410 # endif
411 # ifndef BOOST_MATH_RATIONAL_METHOD
412 # define BOOST_MATH_RATIONAL_METHOD 3
413 # endif
414
415 #elif defined(__clang__)
416
417 #if __clang__ > 6
418 # ifndef BOOST_MATH_POLY_METHOD
419 # define BOOST_MATH_POLY_METHOD 3
420 # endif
421 # ifndef BOOST_MATH_RATIONAL_METHOD
422 # define BOOST_MATH_RATIONAL_METHOD 3
423 # endif
424 # ifndef BOOST_MATH_INT_TABLE_TYPE
425 # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
426 # endif
427 # ifndef BOOST_MATH_INT_VALUE_SUFFIX
428 # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
429 # endif
430 #endif
431
432 #endif
433
434 //
435 // noexcept support:
436 //
437 #include <type_traits>
438 #define BOOST_MATH_NOEXCEPT(T) noexcept(std::is_floating_point<T>::value)
439 #define BOOST_MATH_IS_FLOAT(T) (std::is_floating_point<T>::value)
440
441 //
442 // The maximum order of polynomial that will be evaluated
443 // via an unrolled specialisation:
444 //
445 #ifndef BOOST_MATH_MAX_POLY_ORDER
446 # define BOOST_MATH_MAX_POLY_ORDER 20
447 #endif
448 //
449 // Set the method used to evaluate polynomials and rationals:
450 //
451 #ifndef BOOST_MATH_POLY_METHOD
452 # define BOOST_MATH_POLY_METHOD 2
453 #endif
454 #ifndef BOOST_MATH_RATIONAL_METHOD
455 # define BOOST_MATH_RATIONAL_METHOD 1
456 #endif
457 //
458 // decide whether to store constants as integers or reals:
459 //
460 #ifndef BOOST_MATH_INT_TABLE_TYPE
461 # define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
462 #endif
463 #ifndef BOOST_MATH_INT_VALUE_SUFFIX
464 # define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF
465 #endif
466 //
467 // And then the actual configuration:
468 //
469 #if defined(BOOST_MATH_STANDALONE) && defined(_GLIBCXX_USE_FLOAT128) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && !defined(__STRICT_ANSI__) \
470 && !defined(BOOST_MATH_DISABLE_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128)
471 # define BOOST_MATH_USE_FLOAT128
472 #elif defined(BOOST_HAS_FLOAT128) && !defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_MATH_DISABLE_FLOAT128)
473 # define BOOST_MATH_USE_FLOAT128
474 #endif
475 #ifdef BOOST_MATH_USE_FLOAT128
476 //
477 // Only enable this when the compiler really is GCC as clang and probably
478 // intel too don't support __float128 yet :-(
479 //
480 # if defined(__INTEL_COMPILER) && defined(__GNUC__)
481 # if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 6))
482 # define BOOST_MATH_FLOAT128_TYPE __float128
483 # endif
484 # elif defined(__GNUC__)
485 # define BOOST_MATH_FLOAT128_TYPE __float128
486 # endif
487
488 # ifndef BOOST_MATH_FLOAT128_TYPE
489 # define BOOST_MATH_FLOAT128_TYPE _Quad
490 # endif
491 #endif
492 //
493 // Check for WinCE with no iostream support:
494 //
495 #if defined(_WIN32_WCE) && !defined(__SGI_STL_PORT)
496 # define BOOST_MATH_NO_LEXICAL_CAST
497 #endif
498
499 //
500 // Helper macro for controlling the FP behaviour:
501 //
502 #ifndef BOOST_MATH_CONTROL_FP
503 # define BOOST_MATH_CONTROL_FP
504 #endif
505 //
506 // Helper macro for using statements:
507 //
508 #define BOOST_MATH_STD_USING_CORE \
509 using std::abs;\
510 using std::acos;\
511 using std::cos;\
512 using std::fmod;\
513 using std::modf;\
514 using std::tan;\
515 using std::asin;\
516 using std::cosh;\
517 using std::frexp;\
518 using std::pow;\
519 using std::tanh;\
520 using std::atan;\
521 using std::exp;\
522 using std::ldexp;\
523 using std::sin;\
524 using std::atan2;\
525 using std::fabs;\
526 using std::log;\
527 using std::sinh;\
528 using std::ceil;\
529 using std::floor;\
530 using std::log10;\
531 using std::sqrt;\
532 using std::log2;\
533 using std::ilogb;
534
535 #define BOOST_MATH_STD_USING BOOST_MATH_STD_USING_CORE
536
537 namespace boost{ namespace math{
538 namespace tools
539 {
540
541 template <class T>
542 inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c) BOOST_MATH_NOEXCEPT(T)
543 {
544 return (std::max)((std::max)(a, b), c);
545 }
546
547 template <class T>
548 inline T max BOOST_MATH_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d) BOOST_MATH_NOEXCEPT(T)
549 {
550 return (std::max)((std::max)(a, b), (std::max)(c, d));
551 }
552
553 } // namespace tools
554
555 template <class T>
556 void suppress_unused_variable_warning(const T&) BOOST_MATH_NOEXCEPT(T)
557 {
558 }
559
560 namespace detail{
561
562 template <class T>
563 struct is_integer_for_rounding
564 {
565 static constexpr bool value = std::is_integral<T>::value || (std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::is_integer);
566 };
567
568 }
569
570 }} // namespace boost namespace math
571
572 #ifdef __GLIBC_PREREQ
573 # if __GLIBC_PREREQ(2,14)
574 # define BOOST_MATH_HAVE_FIXED_GLIBC
575 # endif
576 #endif
577
578 #if ((defined(__linux__) && !defined(__UCLIBC__) && !defined(BOOST_MATH_HAVE_FIXED_GLIBC)) || defined(__QNX__) || defined(__IBMCPP__))
579 //
580 // This code was introduced in response to this glibc bug: http://sourceware.org/bugzilla/show_bug.cgi?id=2445
581 // Basically powl and expl can return garbage when the result is small and certain exception flags are set
582 // on entrance to these functions. This appears to have been fixed in Glibc 2.14 (May 2011).
583 // Much more information in this message thread: https://groups.google.com/forum/#!topic/boost-list/ZT99wtIFlb4
584 //
585
586 #include <cfenv>
587
588 # ifdef FE_ALL_EXCEPT
589
590 namespace boost{ namespace math{
591 namespace detail
592 {
593 struct fpu_guard
594 {
595 fpu_guard()
596 {
597 fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
598 feclearexcept(FE_ALL_EXCEPT);
599 }
600 ~fpu_guard()
601 {
602 fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
603 }
604 private:
605 fexcept_t m_flags;
606 };
607
608 } // namespace detail
609 }} // namespaces
610
611 # define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
612 # define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0);
613
614 # else
615
616 # define BOOST_FPU_EXCEPTION_GUARD
617 # define BOOST_MATH_INSTRUMENT_FPU
618
619 # endif
620
621 #else // All other platforms.
622 # define BOOST_FPU_EXCEPTION_GUARD
623 # define BOOST_MATH_INSTRUMENT_FPU
624 #endif
625
626 #ifdef BOOST_MATH_INSTRUMENT
627
628 # include <iostream>
629 # include <iomanip>
630 # include <typeinfo>
631
632 # define BOOST_MATH_INSTRUMENT_CODE(x) \
633 std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
634 # define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(#name << " = " << name)
635
636 #else
637
638 # define BOOST_MATH_INSTRUMENT_CODE(x)
639 # define BOOST_MATH_INSTRUMENT_VARIABLE(name)
640
641 #endif
642
643 //
644 // Thread local storage:
645 //
646 #ifndef BOOST_MATH_DISABLE_THREADS
647 # define BOOST_MATH_THREAD_LOCAL thread_local
648 #else
649 # define BOOST_MATH_THREAD_LOCAL
650 #endif
651
652 //
653 // Some mingw flavours have issues with thread_local and types with non-trivial destructors
654 // See https://sourceforge.net/p/mingw-w64/bugs/527/
655 //
656 // When running windows-2022 or 2025 we see this issue again with GCC 12 and 14
657 //
658 #if (defined(__MINGW32__) && ((__GNUC__ < 9) || (__GNUC__ >= 12)) && !defined(__clang__))
659 # define BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES
660 #endif
661
662
663 //
664 // Can we have constexpr tables?
665 //
666 #if (!defined(BOOST_MATH_NO_CXX14_CONSTEXPR)) || (defined(_MSC_VER) && _MSC_VER >= 1910)
667 #define BOOST_MATH_HAVE_CONSTEXPR_TABLES
668 #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION constexpr
669 #else
670 #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION
671 #endif
672
673 //
674 // CUDA support:
675 //
676
677 #ifdef __CUDACC__
678
679 // We have to get our include order correct otherwise you get compilation failures
680 #include <cuda.h>
681 #include <cuda_runtime.h>
682 #include <cuda/std/type_traits>
683 #include <cuda/std/utility>
684 #include <cuda/std/cstdint>
685 #include <cuda/std/array>
686 #include <cuda/std/tuple>
687 #include <cuda/std/complex>
688
689 # define BOOST_MATH_CUDA_ENABLED __host__ __device__
690 # define BOOST_MATH_HAS_GPU_SUPPORT
691
692 # ifndef BOOST_MATH_ENABLE_CUDA
693 # define BOOST_MATH_ENABLE_CUDA
694 # endif
695
696 // Device code can not handle exceptions
697 # ifndef BOOST_MATH_NO_EXCEPTIONS
698 # define BOOST_MATH_NO_EXCEPTIONS
699 # endif
700
701 // We want to use force inline from CUDA instead of the host compiler
702 # undef BOOST_MATH_FORCEINLINE
703 # define BOOST_MATH_FORCEINLINE __forceinline__
704
705 #elif defined(SYCL_LANGUAGE_VERSION)
706
707 # define BOOST_MATH_SYCL_ENABLED SYCL_EXTERNAL
708 # define BOOST_MATH_HAS_GPU_SUPPORT
709
710 # ifndef BOOST_MATH_ENABLE_SYCL
711 # define BOOST_MATH_ENABLE_SYCL
712 # endif
713
714 # ifndef BOOST_MATH_NO_EXCEPTIONS
715 # define BOOST_MATH_NO_EXCEPTIONS
716 # endif
717
718 // spir64 does not support long double
719 # define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
720 # define BOOST_MATH_NO_REAL_CONCEPT_TESTS
721
722 # undef BOOST_MATH_FORCEINLINE
723 # define BOOST_MATH_FORCEINLINE inline
724
725 #endif
726
727 #ifndef BOOST_MATH_CUDA_ENABLED
728 # define BOOST_MATH_CUDA_ENABLED
729 #endif
730
731 #ifndef BOOST_MATH_SYCL_ENABLED
732 # define BOOST_MATH_SYCL_ENABLED
733 #endif
734
735 // Not all functions that allow CUDA allow SYCL (e.g. Recursion is disallowed by SYCL)
736 # define BOOST_MATH_GPU_ENABLED BOOST_MATH_CUDA_ENABLED BOOST_MATH_SYCL_ENABLED
737
738 // Additional functions that need replaced/marked up
739 #ifdef BOOST_MATH_HAS_GPU_SUPPORT
740 template <class T>
741 BOOST_MATH_GPU_ENABLED constexpr void gpu_safe_swap(T& a, T& b) { T t(a); a = b; b = t; }
742 template <class T>
743 BOOST_MATH_GPU_ENABLED constexpr T gpu_safe_min(const T& a, const T& b) { return a < b ? a : b; }
744 template <class T>
745 BOOST_MATH_GPU_ENABLED constexpr T gpu_safe_max(const T& a, const T& b) { return a > b ? a : b; }
746
747 #define BOOST_MATH_GPU_SAFE_SWAP(a, b) gpu_safe_swap(a, b)
748 #define BOOST_MATH_GPU_SAFE_MIN(a, b) gpu_safe_min(a, b)
749 #define BOOST_MATH_GPU_SAFE_MAX(a, b) gpu_safe_max(a, b)
750
751 #else
752
753 #define BOOST_MATH_GPU_SAFE_SWAP(a, b) std::swap(a, b)
754 #define BOOST_MATH_GPU_SAFE_MIN(a, b) (std::min)(a, b)
755 #define BOOST_MATH_GPU_SAFE_MAX(a, b) (std::max)(a, b)
756
757 #endif
758
759 // Static variables are not allowed with CUDA or C++20 modules
760 // See if we can inline them instead
761
762 #if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L
763 # define BOOST_MATH_INLINE_CONSTEXPR inline constexpr
764 # define BOOST_MATH_STATIC static
765 # ifndef BOOST_MATH_HAS_GPU_SUPPORT
766 # define BOOST_MATH_STATIC_LOCAL_VARIABLE static
767 # else
768 # define BOOST_MATH_STATIC_LOCAL_VARIABLE
769 # endif
770 #else
771 # ifndef BOOST_MATH_HAS_GPU_SUPPORT
772 # define BOOST_MATH_INLINE_CONSTEXPR static constexpr
773 # define BOOST_MATH_STATIC static
774 # define BOOST_MATH_STATIC_LOCAL_VARIABLE
775 # else
776 # define BOOST_MATH_INLINE_CONSTEXPR constexpr
777 # define BOOST_MATH_STATIC constexpr
778 # define BOOST_MATH_STATIC_LOCAL_VARIABLE static
779 # endif
780 #endif
781
782 #define BOOST_MATH_FP_NAN FP_NAN
783 #define BOOST_MATH_FP_INFINITE FP_INFINITE
784 #define BOOST_MATH_FP_ZERO FP_ZERO
785 #define BOOST_MATH_FP_SUBNORMAL FP_SUBNORMAL
786 #define BOOST_MATH_FP_NORMAL FP_NORMAL
787
788 #else // Special section for CUDA NVRTC to ensure we consume no STL headers
789
790 #ifndef BOOST_MATH_STANDALONE
791 # define BOOST_MATH_STANDALONE
792 #endif
793
794 #define BOOST_MATH_HAS_NVRTC
795 #define BOOST_MATH_ENABLE_CUDA
796 #define BOOST_MATH_HAS_GPU_SUPPORT
797
798 #define BOOST_MATH_GPU_ENABLED __host__ __device__
799 #define BOOST_MATH_CUDA_ENABLED __host__ __device__
800
801 #define BOOST_MATH_STATIC static
802 #define BOOST_MATH_STATIC_LOCAL_VARIABLE
803
804 #define BOOST_MATH_NOEXCEPT(T) noexcept(boost::math::is_floating_point_v<T>)
805 #define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)
806 #define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)
807 #define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T)
808 #define BOOST_MATH_BIG_CONSTANT(T, N, V) static_cast<T>(V)
809 #define BOOST_MATH_FORCEINLINE __forceinline__
810 #define BOOST_MATH_STD_USING
811 #define BOOST_MATH_IF_CONSTEXPR if
812 #define BOOST_MATH_IS_FLOAT(T) (boost::math::is_floating_point<T>::value)
813 #define BOOST_MATH_CONSTEXPR_TABLE_FUNCTION constexpr
814 #define BOOST_MATH_NO_EXCEPTIONS
815 #define BOOST_MATH_PREVENT_MACRO_SUBSTITUTION
816
817 // This should be defined to nothing but since it is not specifically a math macro
818 // we need to undef before proceeding
819 #ifdef BOOST_FPU_EXCEPTION_GUARD
820 # undef BOOST_FPU_EXCEPTION_GUARD
821 #endif
822
823 #define BOOST_FPU_EXCEPTION_GUARD
824
825 template <class T>
826 BOOST_MATH_GPU_ENABLED constexpr void gpu_safe_swap(T& a, T& b) { T t(a); a = b; b = t; }
827
828 #define BOOST_MATH_GPU_SAFE_SWAP(a, b) gpu_safe_swap(a, b)
829 #define BOOST_MATH_GPU_SAFE_MIN(a, b) (::min)(a, b)
830 #define BOOST_MATH_GPU_SAFE_MAX(a, b) (::max)(a, b)
831
832 #define BOOST_MATH_FP_NAN 0
833 #define BOOST_MATH_FP_INFINITE 1
834 #define BOOST_MATH_FP_ZERO 2
835 #define BOOST_MATH_FP_SUBNORMAL 3
836 #define BOOST_MATH_FP_NORMAL 4
837
838 #define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF
839 #define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
840
841 #if defined(__cpp_inline_variables) && __cpp_inline_variables >= 201606L
842 # define BOOST_MATH_INLINE_CONSTEXPR inline constexpr
843 #else
844 # define BOOST_MATH_INLINE_CONSTEXPR constexpr
845 #endif
846
847 #define BOOST_MATH_INSTRUMENT_VARIABLE(x)
848 #define BOOST_MATH_INSTRUMENT_CODE(x)
849
850 #endif // NVRTC
851
852 #endif // BOOST_MATH_TOOLS_CONFIG_HPP
853
854
855
856