From 7a9ea53d28a933710984199d16fc04ecb7b18927 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sun, 28 Mar 2021 14:00:50 +0300 Subject: [PATCH 01/15] Remove boost.integer dependency --- include/boost/math/common_factor.hpp | 8 ++- include/boost/math/common_factor_ct.hpp | 5 +- include/boost/math/common_factor_rt.hpp | 4 ++ include/boost/math/tools/polynomial_gcd.hpp | 60 +++++++++++++++++++-- 4 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/boost/math/common_factor.hpp b/include/boost/math/common_factor.hpp index 0c7cf432a..71a28ae53 100644 --- a/include/boost/math/common_factor.hpp +++ b/include/boost/math/common_factor.hpp @@ -10,10 +10,14 @@ #ifndef BOOST_MATH_COMMON_FACTOR_HPP #define BOOST_MATH_COMMON_FACTOR_HPP +#ifndef BOOST_MATH_STANDALONE #include #include +#include -BOOST_HEADER_DEPRECATED(""); - +BOOST_MATH_HEADER_DEPRECATED(""); +#else +#error Common factor is not available in standalone mode because it requires boost.integer. +#endif // BOOST_MATH_STANDALONE #endif // BOOST_MATH_COMMON_FACTOR_HPP diff --git a/include/boost/math/common_factor_ct.hpp b/include/boost/math/common_factor_ct.hpp index 8d9afcb7e..145d16fdd 100644 --- a/include/boost/math/common_factor_ct.hpp +++ b/include/boost/math/common_factor_ct.hpp @@ -10,6 +10,7 @@ #ifndef BOOST_MATH_COMMON_FACTOR_CT_HPP #define BOOST_MATH_COMMON_FACTOR_CT_HPP +#ifndef BOOST_MATH_STANDALONE #include #include @@ -26,6 +27,8 @@ namespace math } // namespace math } // namespace boost - +#else +#error Common factor is not available in standalone mode because it requires boost.integer. +#endif // BOOST_MATH_STANDALONE #endif // BOOST_MATH_COMMON_FACTOR_CT_HPP diff --git a/include/boost/math/common_factor_rt.hpp b/include/boost/math/common_factor_rt.hpp index 9d23617e4..6cc425437 100644 --- a/include/boost/math/common_factor_rt.hpp +++ b/include/boost/math/common_factor_rt.hpp @@ -7,6 +7,7 @@ #ifndef BOOST_MATH_COMMON_FACTOR_RT_HPP #define BOOST_MATH_COMMON_FACTOR_RT_HPP +#ifndef BOOST_MATH_STANDALONE #include #include @@ -22,5 +23,8 @@ namespace boost { using boost::integer::lcm_evaluator; } } +#else +#error Common factor is not available in standalone mode because it requires boost.integer. +#endif // BOOST_MATH_STANDALONE #endif // BOOST_MATH_COMMON_FACTOR_RT_HPP diff --git a/include/boost/math/tools/polynomial_gcd.hpp b/include/boost/math/tools/polynomial_gcd.hpp index aa131fb00..354a65869 100644 --- a/include/boost/math/tools/polynomial_gcd.hpp +++ b/include/boost/math/tools/polynomial_gcd.hpp @@ -1,5 +1,5 @@ // (C) Copyright Jeremy William Murphy 2016. - +// (C) Copyright Matt Borland 2021. // Use, modification and distribution are subject to 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) @@ -14,8 +14,57 @@ #include #include #include + +#ifndef BOOST_MATH_STANDALONE #include +// std::gcd was introduced in C++17 +#elif (__cplusplus > 201700L || _MSVC_LANG > 201700L) + +#define BOOST_MATH_CXX17_NUMERIC +#include +#include +#include +#include +#include + +namespace boost::integer { + +template ::value_type> +std::pair gcd_range(Iter first, Iter last) noexcept(std::is_arithmetic_v) +{ + using std::gcd; + BOOST_MATH_ASSERT(first != last); + + T d = *first; + ++first; + while (d != T(1) && first != last) + { + d = gcd(d, *first); + ++first; + } + return std::make_pair(d, first); +} + +namespace gcd_detail { + +template +inline EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b) noexcept(std::is_arithmetic_v) +{ + using std::swap; + while (b != EuclideanDomain(0)) + { + a %= b; + swap(a, b); + } + return a; +} + +} // namespace gcd_detail +} // namespace boost::integer +#error polynomial gcd can only be used in standalone mode with C++17 or higher +#endif + namespace boost{ namespace integer { @@ -36,8 +85,6 @@ namespace boost{ } } - - namespace math{ namespace tools{ /* From Knuth, 4.6.1: @@ -88,7 +135,14 @@ namespace detail template T reduce_to_primitive(polynomial &u, polynomial &v) { + #ifndef BOOST_MATH_STANDALONE using boost::integer::gcd; + #elif defined(BOOST_MATH_CXX17_NUMERIC) + using std::gcd; + #else + #error polynomial gcd can only be used in standalone mode with C++17 or higher + #endif + T const u_cont = content(u), v_cont = content(v); u /= u_cont; v /= v_cont; From ea323e6e1b57b6b39c10c1b86bfe00d66303a9ad Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sun, 28 Mar 2021 10:50:39 +0300 Subject: [PATCH 02/15] Remove boost.lexical_cast dependency --- example/big_seventh.cpp | 3 +-- example/handle_test_result.hpp | 2 +- .../math/bindings/detail/big_digamma.hpp | 8 +++++- include/boost/math/bindings/mpfr.hpp | 22 +++++++++++++++- include/boost/math/bindings/mpreal.hpp | 22 +++++++++++++++- .../boost/math/cstdfloat/cstdfloat_cmath.hpp | 6 ++--- .../math/cstdfloat/cstdfloat_iostream.hpp | 15 +++++++---- .../boost/math/cstdfloat/cstdfloat_limits.hpp | 2 +- .../boost/math/cstdfloat/cstdfloat_types.hpp | 2 +- .../detail/barycentric_rational_detail.hpp | 22 +++++++++++----- .../quadrature/detail/tanh_sinh_constants.hpp | 1 - .../special_functions/detail/fp_traits.hpp | 2 +- .../detail/unchecked_factorial.hpp | 6 +---- include/boost/math/tools/big_constant.hpp | 8 +++--- include/boost/math/tools/config.hpp | 1 + .../boost/math/tools/convert_from_string.hpp | 4 +-- include/boost/math/tools/lexical_cast.hpp | 26 +++++++++++++++++++ include/boost/math/tools/test_value.hpp | 4 ++- include/boost/math/tr1.hpp | 2 +- test/handle_test_result.hpp | 2 +- test/test_cstdfloat.cpp | 10 +++---- test/test_sign.cpp | 2 +- tools/hyp_1f1_data.cpp | 4 +-- 23 files changed, 128 insertions(+), 48 deletions(-) create mode 100644 include/boost/math/tools/lexical_cast.hpp diff --git a/example/big_seventh.cpp b/example/big_seventh.cpp index 9d647a25b..bf9835afb 100644 --- a/example/big_seventh.cpp +++ b/example/big_seventh.cpp @@ -179,8 +179,7 @@ As one would expect, the variable can be `const` (but sadly [*not yet `constexpr // constexpr cpp_bin_float_50 seventh_constexpr (cpp_bin_float_50(1) / 7); // std::cout << "seventh_constexpr = " << seventh_constexpr << std::endl; // -// nor use the macro BOOST_CONSTEXPR_OR_CONST unless it returns `const` -// BOOST_CONSTEXPR_OR_CONST cpp_bin_float_50 seventh_constexpr(seventh_const); +// constexpr cpp_bin_float_50 seventh_constexpr(seventh_const); //] [/big_seventh_example_constexpr diff --git a/example/handle_test_result.hpp b/example/handle_test_result.hpp index 64ea9c2e6..88a908c48 100644 --- a/example/handle_test_result.hpp +++ b/example/handle_test_result.hpp @@ -14,7 +14,7 @@ #include #include -#if defined(BOOST_INTEL) +#if defined(__INTEL_COMPILER) # pragma warning(disable:239) # pragma warning(disable:264) #endif diff --git a/include/boost/math/bindings/detail/big_digamma.hpp b/include/boost/math/bindings/detail/big_digamma.hpp index bbddb23f0..e0d9b0558 100644 --- a/include/boost/math/bindings/detail/big_digamma.hpp +++ b/include/boost/math/bindings/detail/big_digamma.hpp @@ -7,9 +7,10 @@ #define BOOST_MATH_NTL_DIGAMMA #include +#include +#include #include #include -#include namespace boost{ namespace math{ namespace detail{ @@ -283,6 +284,11 @@ template T big_digamma(T x) { BOOST_MATH_STD_USING + + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "big_digamma can not be used in standalone mode"); + #endif + if(x < 0) { return big_digamma_helper(static_cast(1-x)) + constants::pi() / tan(constants::pi() * (1-x)); diff --git a/include/boost/math/bindings/mpfr.hpp b/include/boost/math/bindings/mpfr.hpp index 680d1a8f6..406b7d68b 100644 --- a/include/boost/math/bindings/mpfr.hpp +++ b/include/boost/math/bindings/mpfr.hpp @@ -11,7 +11,6 @@ #ifndef BOOST_MATH_MPLFR_BINDINGS_HPP #define BOOST_MATH_MPLFR_BINDINGS_HPP -#include #include #ifdef _MSC_VER @@ -38,6 +37,7 @@ #include #include #include +#include inline mpfr_class fabs(const mpfr_class& v) { @@ -456,6 +456,10 @@ inline mpfr_class skewness(const extreme_value_distribution& // This is 12 * sqrt(6) * zeta(3) / pi^3: // See http://mathworld.wolfram.com/ExtremeValueDistribution.html // + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpfr skewness can not be calculated in standalone mode"); + #endif + return boost::lexical_cast("1.1395470994046486574927930193898461120875997958366"); } @@ -463,6 +467,10 @@ template inline mpfr_class skewness(const rayleigh_distribution& /*dist*/) { // using namespace boost::math::constants; + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpfr skewness can not be calculated in standalone mode"); + #endif + return boost::lexical_cast("0.63111065781893713819189935154422777984404221106391"); // Computed using NTL at 150 bit, about 50 decimal digits. // return 2 * root_pi() * pi_minus_three() / pow23_four_minus_pi(); @@ -472,6 +480,10 @@ template inline mpfr_class kurtosis(const rayleigh_distribution& /*dist*/) { // using namespace boost::math::constants; + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpfr kurtosis can not be calculated in standalone mode"); + #endif + return boost::lexical_cast("3.2450893006876380628486604106197544154170667057995"); // Computed using NTL at 150 bit, about 50 decimal digits. // return 3 - (6 * pi() * pi() - 24 * pi() + 16) / @@ -483,6 +495,10 @@ inline mpfr_class kurtosis_excess(const rayleigh_distribution("0.2450893006876380628486604106197544154170667057995"); // return -(6 * pi() * pi() - 24 * pi() + 16) / // (four_minus_pi() * four_minus_pi()); @@ -792,6 +808,10 @@ inline mpfr_class erf_inv_imp(const mpfr_class& p, const mpfr_class& q, const Po inline mpfr_class bessel_i0(mpfr_class x) { + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpfr bessel_i0 can not be calculated in standalone mode"); + #endif + static const mpfr_class P1[] = { boost::lexical_cast("-2.2335582639474375249e+15"), boost::lexical_cast("-5.5050369673018427753e+14"), diff --git a/include/boost/math/bindings/mpreal.hpp b/include/boost/math/bindings/mpreal.hpp index 2858b8d77..755b2a4a5 100644 --- a/include/boost/math/bindings/mpreal.hpp +++ b/include/boost/math/bindings/mpreal.hpp @@ -11,7 +11,6 @@ #ifndef BOOST_MATH_MPREAL_BINDINGS_HPP #define BOOST_MATH_MPREAL_BINDINGS_HPP -#include #include #ifdef _MSC_VER @@ -37,6 +36,7 @@ #include #include #include +#include namespace mpfr{ @@ -403,6 +403,10 @@ inline mpfr::mpreal skewness(const extreme_value_distribution("1.1395470994046486574927930193898461120875997958366"); } @@ -410,6 +414,10 @@ template inline mpfr::mpreal skewness(const rayleigh_distribution& /*dist*/) { // using namespace boost::math::constants; + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpreal skewness can not be calculated in standalone mode"); + #endif + return boost::lexical_cast("0.63111065781893713819189935154422777984404221106391"); // Computed using NTL at 150 bit, about 50 decimal digits. // return 2 * root_pi() * pi_minus_three() / pow23_four_minus_pi(); @@ -419,6 +427,10 @@ template inline mpfr::mpreal kurtosis(const rayleigh_distribution& /*dist*/) { // using namespace boost::math::constants; + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpreal kurtosis can not be calculated in standalone mode"); + #endif + return boost::lexical_cast("3.2450893006876380628486604106197544154170667057995"); // Computed using NTL at 150 bit, about 50 decimal digits. // return 3 - (6 * pi() * pi() - 24 * pi() + 16) / @@ -430,6 +442,10 @@ inline mpfr::mpreal kurtosis_excess(const rayleigh_distribution("0.2450893006876380628486604106197544154170667057995"); // return -(6 * pi() * pi() - 24 * pi() + 16) / // (four_minus_pi() * four_minus_pi()); @@ -739,6 +755,10 @@ mpfr::mpreal erf_inv_imp(const mpfr::mpreal& p, const mpfr::mpreal& q, const Pol inline mpfr::mpreal bessel_i0(mpfr::mpreal x) { + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "mpreal bessel_i0 can not be calculated in standalone mode"); + #endif + static const mpfr::mpreal P1[] = { boost::lexical_cast("-2.2335582639474375249e+15"), boost::lexical_cast("-5.5050369673018427753e+14"), diff --git a/include/boost/math/cstdfloat/cstdfloat_cmath.hpp b/include/boost/math/cstdfloat/cstdfloat_cmath.hpp index b71bbd828..af9398ee6 100644 --- a/include/boost/math/cstdfloat/cstdfloat_cmath.hpp +++ b/include/boost/math/cstdfloat/cstdfloat_cmath.hpp @@ -118,7 +118,7 @@ namespace boost { } // boost::math::cstdfloat::detail // We will now define preprocessor symbols representing quadruple-precision functions. -#if defined(BOOST_INTEL) +#if defined(__INTEL_COMPILER) #define BOOST_CSTDFLOAT_FLOAT128_LDEXP __ldexpq #define BOOST_CSTDFLOAT_FLOAT128_FREXP __frexpq #define BOOST_CSTDFLOAT_FLOAT128_FABS __fabsq @@ -462,7 +462,7 @@ inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT typedef boost::math::cstdfloat::detail::float_internal128_t float_type; // Scale the argument x to the range (-ln2 < x < ln2). - BOOST_CONSTEXPR_OR_CONST float_type one_over_ln2 = float_type(BOOST_FLOAT128_C(1.44269504088896340735992468100189213742664595415299)); + constexpr float_type one_over_ln2 = float_type(BOOST_FLOAT128_C(1.44269504088896340735992468100189213742664595415299)); const float_type x_over_ln2 = x * one_over_ln2; std::int_fast32_t n; @@ -592,7 +592,7 @@ inline boost::math::cstdfloat::detail::float_internal128_t BOOST_CSTDFLOAT_FLOAT // Take the reflection checks (slightly adapted) from . const bool floor_of_z_is_equal_to_z = (positive_x == ::BOOST_CSTDFLOAT_FLOAT128_FLOOR(positive_x)); - BOOST_CONSTEXPR_OR_CONST float_type my_pi = BOOST_FLOAT128_C(3.14159265358979323846264338327950288419716939937511); + constexpr float_type my_pi = BOOST_FLOAT128_C(3.14159265358979323846264338327950288419716939937511); if (floor_of_z_is_equal_to_z) { diff --git a/include/boost/math/cstdfloat/cstdfloat_iostream.hpp b/include/boost/math/cstdfloat/cstdfloat_iostream.hpp index e05b3b86f..f704aed61 100644 --- a/include/boost/math/cstdfloat/cstdfloat_iostream.hpp +++ b/include/boost/math/cstdfloat/cstdfloat_iostream.hpp @@ -160,7 +160,7 @@ } // #elif defined(__GNUC__) - #elif defined(BOOST_INTEL) + #elif defined(__INTEL_COMPILER) // The section for I/O stream support for the ICC compiler is particularly // long, because these functions must be painstakingly synthesized from @@ -173,7 +173,7 @@ #include #include - #include + #include namespace boost { namespace math { namespace cstdfloat { namespace detail { @@ -331,7 +331,12 @@ } str.append(1U, 'e'); + + #ifdef BOOST_MATH_STANDALONE + static_assert(false, "IO streams for intel compilers using _Quad types can not be used in standalone mode"); + #else string_type e = boost::lexical_cast(std::abs(my_exp)); + #endif if(e.size() < 2U) { @@ -576,12 +581,12 @@ bool is_neg = false; bool is_neg_expon = false; - BOOST_CONSTEXPR_OR_CONST int ten = 10; + constexpr int ten = 10; int expon = 0; int digits_seen = 0; - BOOST_CONSTEXPR_OR_CONST int max_digits = std::numeric_limits::max_digits10 + 1; + constexpr int max_digits = std::numeric_limits::max_digits10 + 1; if(*p == static_cast('+')) { @@ -767,7 +772,7 @@ } } - #endif // Use __GNUC__ or BOOST_INTEL libquadmath + #endif // Use __GNUC__ or __INTEL_COMPILER libquadmath #endif // Not BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT (i.e., the user would like to have libquadmath support) diff --git a/include/boost/math/cstdfloat/cstdfloat_limits.hpp b/include/boost/math/cstdfloat/cstdfloat_limits.hpp index adef5c216..fecdb9a51 100644 --- a/include/boost/math/cstdfloat/cstdfloat_limits.hpp +++ b/include/boost/math/cstdfloat/cstdfloat_limits.hpp @@ -30,7 +30,7 @@ // Define the name of the global quadruple-precision function to be used for // calculating quiet_NaN() in the specialization of std::numeric_limits<>. - #if defined(BOOST_INTEL) + #if defined(__INTEL_COMPILER) #define BOOST_CSTDFLOAT_FLOAT128_SQRT __sqrtq #elif defined(__GNUC__) #define BOOST_CSTDFLOAT_FLOAT128_SQRT sqrtq diff --git a/include/boost/math/cstdfloat/cstdfloat_types.hpp b/include/boost/math/cstdfloat/cstdfloat_types.hpp index 9a7a3bd56..bc32c71fe 100644 --- a/include/boost/math/cstdfloat/cstdfloat_types.hpp +++ b/include/boost/math/cstdfloat/cstdfloat_types.hpp @@ -212,7 +212,7 @@ namespace boost { namespace math { namespace cstdfloat { namespace detail { #if defined(__GNUC__) typedef __float128 float_internal128_t; - #elif defined(BOOST_INTEL) + #elif defined(__INTEL_COMPILER) typedef _Quad float_internal128_t; #else #error "Sorry, the compiler is neither GCC, nor Intel, I don't know how to configure ." diff --git a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp index d58bac0ec..30a875f98 100644 --- a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp +++ b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp @@ -11,11 +11,15 @@ #include #include // for std::move #include // for std::is_sorted -#include +#include #include -#include #include +#ifndef BOOST_MATH_STANDALONE +#include +#endif + + namespace boost{ namespace math{ namespace detail{ template @@ -72,13 +76,13 @@ barycentric_rational_imp::barycentric_rational_imp(InputIterator1 start_x, // But if we're going to do a memcpy, we can do some error checking which is inexpensive relative to the copy: if(boost::math::isnan(*start_x)) { - std::string msg = std::string("x[") + boost::lexical_cast(i) + "] is a NAN"; + std::string msg = std::string("x[") + std::to_string(i) + "] is a NAN"; throw std::domain_error(msg); } if(boost::math::isnan(*start_y)) { - std::string msg = std::string("y[") + boost::lexical_cast(i) + "] is a NAN"; + std::string msg = std::string("y[") + std::to_string(i) + "] is a NAN"; throw std::domain_error(msg); } @@ -128,10 +132,14 @@ void barycentric_rational_imp::calculate_weights(size_t approximation_orde if (abs(diff) < (numeric_limits::min)()) { std::string msg = std::string("Spacing between x[") - + boost::lexical_cast(k) + std::string("] and x[") - + boost::lexical_cast(i) + std::string("] is ") - + boost::lexical_cast(diff) + std::string(", which is smaller than the epsilon of ") + + std::to_string(k) + std::string("] and x[") + + std::to_string(i) + std::string("] is ") + + std::to_string(diff) + std::string(", which is smaller than the epsilon of ") + #ifndef BOOST_MATH_STANDALONE + boost::core::demangle(typeid(Real).name()); + #else + + std::string(typeid(Real).name()); + #endif throw std::logic_error(msg); } inv_product *= diff; diff --git a/include/boost/math/quadrature/detail/tanh_sinh_constants.hpp b/include/boost/math/quadrature/detail/tanh_sinh_constants.hpp index e4269aff0..b27c149aa 100644 --- a/include/boost/math/quadrature/detail/tanh_sinh_constants.hpp +++ b/include/boost/math/quadrature/detail/tanh_sinh_constants.hpp @@ -11,7 +11,6 @@ #include #include #include -#include namespace boost { namespace math { diff --git a/include/boost/math/special_functions/detail/fp_traits.hpp b/include/boost/math/special_functions/detail/fp_traits.hpp index 20eab3a55..3dfef7723 100644 --- a/include/boost/math/special_functions/detail/fp_traits.hpp +++ b/include/boost/math/special_functions/detail/fp_traits.hpp @@ -580,7 +580,7 @@ struct select_native && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)\ && !defined(__FAST_MATH__)\ && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)\ - && !defined(BOOST_INTEL)\ + && !defined(__INTEL_COMPILER)\ && !defined(sun)\ && !defined(__VXWORKS__) # define BOOST_MATH_USE_STD_FPCLASSIFY diff --git a/include/boost/math/special_functions/detail/unchecked_factorial.hpp b/include/boost/math/special_functions/detail/unchecked_factorial.hpp index 0a5ad9f96..8b9ee0947 100644 --- a/include/boost/math/special_functions/detail/unchecked_factorial.hpp +++ b/include/boost/math/special_functions/detail/unchecked_factorial.hpp @@ -14,9 +14,7 @@ #pragma warning(push) // Temporary until lexical cast fixed. #pragma warning(disable: 4127 4701) #endif -#ifndef BOOST_MATH_NO_LEXICAL_CAST -#include -#endif +#include #ifdef _MSC_VER #pragma warning(pop) #endif @@ -26,8 +24,6 @@ #include #include -#include - #if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128) // // This is the only way we can avoid diff --git a/include/boost/math/tools/big_constant.hpp b/include/boost/math/tools/big_constant.hpp index 3bce47fab..789e65462 100644 --- a/include/boost/math/tools/big_constant.hpp +++ b/include/boost/math/tools/big_constant.hpp @@ -8,9 +8,7 @@ #define BOOST_MATH_TOOLS_BIG_CONSTANT_HPP #include -#ifndef BOOST_MATH_NO_LEXICAL_CAST -#include -#endif +#include #include #include @@ -42,12 +40,12 @@ typedef double largest_float; #endif template -inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, std::true_type const&, std::false_type const&) BOOST_MATH_NOEXCEPT(T) +inline constexpr T make_big_value(largest_float v, const char*, std::true_type const&, std::false_type const&) BOOST_MATH_NOEXCEPT(T) { return static_cast(v); } template -inline BOOST_CONSTEXPR_OR_CONST T make_big_value(largest_float v, const char*, std::true_type const&, std::true_type const&) BOOST_MATH_NOEXCEPT(T) +inline constexpr T make_big_value(largest_float v, const char*, std::true_type const&, std::true_type const&) BOOST_MATH_NOEXCEPT(T) { return static_cast(v); } diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index a8b77b113..68d4c5519 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -19,6 +19,7 @@ #define BOOST_PREVENT_MACRO_SUBSTITUTION #define BOOST_MATH_NO_REAL_CONCEPT_TESTS #define BOOST_MATH_NO_DISTRIBUTION_CONCEPT_TESTS +#define BOOST_MATH_NO_LEXICAL_CAST #define TEST_STD #if (__cplusplus > 201400L || _MSVC_LANG > 201400L) diff --git a/include/boost/math/tools/convert_from_string.hpp b/include/boost/math/tools/convert_from_string.hpp index 3dbd7f8ed..13e9dca2b 100644 --- a/include/boost/math/tools/convert_from_string.hpp +++ b/include/boost/math/tools/convert_from_string.hpp @@ -11,7 +11,7 @@ #endif #include -#include +#include namespace boost{ namespace math{ namespace tools{ @@ -26,7 +26,7 @@ namespace boost{ namespace math{ namespace tools{ { #ifdef BOOST_MATH_NO_LEXICAL_CAST // This function should not compile, we don't have the necessary functionality to support it: - static_assert(sizeof(Real) == 0, "sizeof(Real) should be 0"); + static_assert(false, "boost.lexical_cast is not supported in standalone mode."); #else return boost::lexical_cast(p); #endif diff --git a/include/boost/math/tools/lexical_cast.hpp b/include/boost/math/tools/lexical_cast.hpp new file mode 100644 index 000000000..24592854f --- /dev/null +++ b/include/boost/math/tools/lexical_cast.hpp @@ -0,0 +1,26 @@ +// (C) Copyright Matt Borland 2021 +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_MATH_TOOLS_LEXICAL_CAST +#define BOOST_MATH_TOOLS_LEXICAL_CAST + +#ifndef BOOST_MATH_STANDALONE +#include +#else + +#ifndef BOOST_MATH_NO_LEXICAL_CAST +#define BOOST_MATH_NO_LEXICAL_CAST +#endif + +namespace boost { + template + inline T1 lexical_cast(const T2) + { + static_assert(false, "boost.lexical_cast can not be used in standalone mode. Please disable standalone mode and try again"); + return T1(0); + } +} +#endif // BOOST_MATH_STANDALONE +#endif // BOOST_MATH_TOOLS_LEXICAL_CAST diff --git a/include/boost/math/tools/test_value.hpp b/include/boost/math/tools/test_value.hpp index f9948e1eb..608881902 100644 --- a/include/boost/math/tools/test_value.hpp +++ b/include/boost/math/tools/test_value.hpp @@ -27,7 +27,7 @@ // Macro BOOST_MATH_INSTRUMENT_CREATE_TEST_VALUE provides a global diagnostic value for create_type. #include // For float_64_t, float128_t. Must be first include! -#include +#include #include #include @@ -83,6 +83,8 @@ inline T create_test_value(largest_float, const char* str, const std::false_type // (This is case T1 = false_type and T2 == false_type). #ifdef BOOST_MATH_INSTRUMENT_CREATE_TEST_VALUE create_type = 3; + #elif defined(BOOST_MATH_STANDALONE) + static_assert(false, "Can not create a test value using lexical cast of string in standalone mode"); #endif return boost::lexical_cast(str); } diff --git a/include/boost/math/tr1.hpp b/include/boost/math/tr1.hpp index 01054c992..30e43b361 100644 --- a/include/boost/math/tr1.hpp +++ b/include/boost/math/tr1.hpp @@ -109,7 +109,7 @@ namespace boost{ namespace math{ namespace tr1{ extern "C"{ #error Auto linking not supported in standalone mode. #endif // BOOST_MATH_STANDALONE -#if !(defined(BOOST_INTEL) && defined(__APPLE__)) && !(defined(__FLT_EVAL_METHOD__) && !defined(__cplusplus)) +#if !(defined(__INTEL_COMPILER) && defined(__APPLE__)) && !(defined(__FLT_EVAL_METHOD__) && !defined(__cplusplus)) #if !defined(FLT_EVAL_METHOD) typedef float float_t; typedef double double_t; diff --git a/test/handle_test_result.hpp b/test/handle_test_result.hpp index eec314284..e909d6458 100644 --- a/test/handle_test_result.hpp +++ b/test/handle_test_result.hpp @@ -14,7 +14,7 @@ #include #include -#if defined(BOOST_INTEL) +#if defined(__INTEL_COMPILER) # pragma warning(disable:239) # pragma warning(disable:264) #endif diff --git a/test/test_cstdfloat.cpp b/test/test_cstdfloat.cpp index cf80a7f79..2091f9f6d 100644 --- a/test/test_cstdfloat.cpp +++ b/test/test_cstdfloat.cpp @@ -75,10 +75,10 @@ void sanity_check_##the_digits##_func() { \ typedef boost::float##the_digits##_t float_type; \ \ - BOOST_CONSTEXPR_OR_CONST int my_digits10 = std::numeric_limits::digits10; \ + constexpr int my_digits10 = std::numeric_limits::digits10; \ \ { \ - BOOST_CONSTEXPR_OR_CONST float_type x = \ + constexpr float_type x = \ BOOST_FLOAT##the_digits##_C(0.33333333333333333333333333333333333333333); \ std::stringstream ss; \ ss << std::setprecision(my_digits10 - 1) \ @@ -88,7 +88,7 @@ void sanity_check_##the_digits##_func() BOOST_CHECK_EQUAL( ss.str(), str ); \ } \ { \ - BOOST_CONSTEXPR_OR_CONST float_type x = \ + constexpr float_type x = \ BOOST_FLOAT##the_digits##_C(0.66666666666666666666666666666666666666666); \ std::stringstream ss; \ ss << std::setprecision(my_digits10 - 1) \ @@ -499,9 +499,9 @@ namespace test_cstdfloat int minus_one; #if defined(BOOST_FLOATMAX_C) - BOOST_CONSTEXPR_OR_CONST int has_floatmax_t = 1; + constexpr int has_floatmax_t = 1; #else - BOOST_CONSTEXPR_OR_CONST int has_floatmax_t = 0; + constexpr int has_floatmax_t = 0; #endif #if defined(BOOST_FLOAT16_C) diff --git a/test/test_sign.cpp b/test/test_sign.cpp index 27ba7b792..864d2dd12 100644 --- a/test/test_sign.cpp +++ b/test/test_sign.cpp @@ -76,7 +76,7 @@ void test_spots(RealType /*T*/, const char* /*type_name*/) BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1)); BOOST_CHECK_EQUAL((boost::math::changesign)(a), -a); } -#if !defined(__SUNPRO_CC) && !defined(BOOST_INTEL) +#if !defined(__SUNPRO_CC) && !defined(__INTEL_COMPILER) if(std::numeric_limits::has_quiet_NaN) { a = std::numeric_limits::quiet_NaN(); diff --git a/tools/hyp_1f1_data.cpp b/tools/hyp_1f1_data.cpp index b307b4280..12ace4186 100644 --- a/tools/hyp_1f1_data.cpp +++ b/tools/hyp_1f1_data.cpp @@ -22,7 +22,7 @@ struct hypergeometric_1f1_gen { mp_t operator()(mp_t a1, mp_t a2, mp_t z) { - int scaling = 0; + long long scaling = 0; std::cout << a1 << " " << a2 << " " << z << std::endl; mp_t result = boost::math::detail::hypergeometric_1F1_generic_series(a1, a2, z, boost::math::policies::policy<>(), scaling, ""); std::cout << a1 << " " << a2 << " " << z << " " << result << std::endl; @@ -34,7 +34,7 @@ struct hypergeometric_1f1_gen_2 { mp_t operator()(mp_t a1, mp_t a2, mp_t z) { - int scaling = 0; + long long scaling = 0; mp_t result = boost::math::detail::hypergeometric_1F1_generic_series(a1, a2, z, boost::math::policies::policy<>(), scaling, ""); result = ldexp(result, scaling); std::cout << a1 << " " << a2 << " " << z << " " << result << std::endl; From 352580bb9bb7aac19d338b69a276e0030e607e9d Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sun, 28 Mar 2021 14:19:48 +0300 Subject: [PATCH 03/15] Remove --- include/boost/math/tools/centered_continued_fraction.hpp | 7 +++++++ include/boost/math/tools/simple_continued_fraction.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/include/boost/math/tools/centered_continued_fraction.hpp b/include/boost/math/tools/centered_continued_fraction.hpp index 2016ffd20..5f3e9b14f 100644 --- a/include/boost/math/tools/centered_continued_fraction.hpp +++ b/include/boost/math/tools/centered_continued_fraction.hpp @@ -12,7 +12,10 @@ #include #include #include + +#ifndef BOOST_MATH_STANDALONE #include +#endif namespace boost::math::tools { @@ -77,7 +80,11 @@ public: if (b_[i] == 0) { std::ostringstream oss; oss << "Found a zero partial denominator: b[" << i << "] = " << b_[i] << "." + #ifndef BOOST_MATH_STANDALONE << " This means the integer type '" << boost::core::demangle(typeid(Z).name()) + #else + << " This means the integer type '" << typeid(Z).name() + #endif << "' has overflowed and you need to use a wider type," << " or there is a bug."; throw std::overflow_error(oss.str()); diff --git a/include/boost/math/tools/simple_continued_fraction.hpp b/include/boost/math/tools/simple_continued_fraction.hpp index 4120c53b0..391a4ac70 100644 --- a/include/boost/math/tools/simple_continued_fraction.hpp +++ b/include/boost/math/tools/simple_continued_fraction.hpp @@ -12,7 +12,10 @@ #include #include #include + +#ifndef BOOST_MATH_STANDALONE #include +#endif namespace boost::math::tools { @@ -74,7 +77,11 @@ public: if (b_[i] <= 0) { std::ostringstream oss; oss << "Found a negative partial denominator: b[" << i << "] = " << b_[i] << "." + #ifndef BOOST_MATH_STANDALONE << " This means the integer type '" << boost::core::demangle(typeid(Z).name()) + #else + << " This means the integer type '" << typeid(Z).name() + #endif << "' has overflowed and you need to use a wider type," << " or there is a bug."; throw std::overflow_error(oss.str()); From 347227d63ba1077f650fc1cec2d243592c885a90 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 30 Mar 2021 21:37:38 +0300 Subject: [PATCH 04/15] Replace hard include error with static asserts --- include/boost/math/tools/polynomial_gcd.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/boost/math/tools/polynomial_gcd.hpp b/include/boost/math/tools/polynomial_gcd.hpp index 354a65869..fd3b7c1c3 100644 --- a/include/boost/math/tools/polynomial_gcd.hpp +++ b/include/boost/math/tools/polynomial_gcd.hpp @@ -62,7 +62,6 @@ inline EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b) noexcept } // namespace gcd_detail } // namespace boost::integer -#error polynomial gcd can only be used in standalone mode with C++17 or higher #endif namespace boost{ @@ -101,6 +100,10 @@ namespace math{ namespace tools{ template T content(polynomial const &x) { + #if defined(BOOST_MATH_STANDALONE) && !defined(BOOST_MATH_CXX17_NUMERIC) + static_assert(sizeof(T) == 0, "polynomial gcd can only be used in standalone mode with C++17 or higher"); + #endif + return x ? boost::integer::gcd_range(x.data().begin(), x.data().end()).first : T(0); } @@ -140,7 +143,7 @@ namespace detail #elif defined(BOOST_MATH_CXX17_NUMERIC) using std::gcd; #else - #error polynomial gcd can only be used in standalone mode with C++17 or higher + static_assert(sizeof(T) == 0, "polynomial gcd can only be used in standalone mode with C++17 or higher"); #endif T const u_cont = content(u), v_cont = content(v); @@ -239,6 +242,10 @@ template typename std::enable_if::is_integer && (std::numeric_limits::min_exponent != std::numeric_limits::max_exponent) && !std::numeric_limits::is_exact, polynomial >::type gcd(polynomial const &u, polynomial const &v) { + #if defined(BOOST_MATH_STANDALONE) && !defined(BOOST_MATH_CXX17_NUMERIC) + static_assert(sizeof(T) == 0, "polynomial gcd can only be used in standalone mode with C++17 or higher"); + #endif + return boost::integer::gcd_detail::Euclid_gcd(u, v); } From 902fa7a798f2fc9f987015f44ca39cd3d6a9a662 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Tue, 30 Mar 2021 22:04:00 +0300 Subject: [PATCH 05/15] Fix failure for types w/o std::to_string overloads --- .../math/interpolators/detail/barycentric_rational_detail.hpp | 4 +++- include/boost/math/tools/lexical_cast.hpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp index 30a875f98..ae54967eb 100644 --- a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp +++ b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp @@ -16,6 +16,7 @@ #include #ifndef BOOST_MATH_STANDALONE +#include #include #endif @@ -134,10 +135,11 @@ void barycentric_rational_imp::calculate_weights(size_t approximation_orde std::string msg = std::string("Spacing between x[") + std::to_string(k) + std::string("] and x[") + std::to_string(i) + std::string("] is ") - + std::to_string(diff) + std::string(", which is smaller than the epsilon of ") #ifndef BOOST_MATH_STANDALONE + + boost::lexical_cast(diff) + std::string(", which is smaller than the epsilon of ") + boost::core::demangle(typeid(Real).name()); #else + + std::string("smaller than the epsilon of ") + std::string(typeid(Real).name()); #endif throw std::logic_error(msg); diff --git a/include/boost/math/tools/lexical_cast.hpp b/include/boost/math/tools/lexical_cast.hpp index 24592854f..cf86e98d9 100644 --- a/include/boost/math/tools/lexical_cast.hpp +++ b/include/boost/math/tools/lexical_cast.hpp @@ -18,7 +18,7 @@ namespace boost { template inline T1 lexical_cast(const T2) { - static_assert(false, "boost.lexical_cast can not be used in standalone mode. Please disable standalone mode and try again"); + static_assert(sizeof(T1) == 0, "boost.lexical_cast can not be used in standalone mode. Please disable standalone mode and try again"); return T1(0); } } From a9e9acb1a1c1ff8a7a70706899e529ca78e3d0b1 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 31 Mar 2021 19:49:29 +0300 Subject: [PATCH 06/15] Remove standalone workaround --- .../detail/barycentric_rational_detail.hpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp index ae54967eb..cb1c4a3e6 100644 --- a/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp +++ b/include/boost/math/interpolators/detail/barycentric_rational_detail.hpp @@ -15,12 +15,6 @@ #include #include -#ifndef BOOST_MATH_STANDALONE -#include -#include -#endif - - namespace boost{ namespace math{ namespace detail{ template @@ -135,13 +129,8 @@ void barycentric_rational_imp::calculate_weights(size_t approximation_orde std::string msg = std::string("Spacing between x[") + std::to_string(k) + std::string("] and x[") + std::to_string(i) + std::string("] is ") - #ifndef BOOST_MATH_STANDALONE - + boost::lexical_cast(diff) + std::string(", which is smaller than the epsilon of ") - + boost::core::demangle(typeid(Real).name()); - #else + std::string("smaller than the epsilon of ") + std::string(typeid(Real).name()); - #endif throw std::logic_error(msg); } inv_product *= diff; From a189a6ad66be6c380723a13e53896bd69e331724 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 1 Apr 2021 21:36:10 +0300 Subject: [PATCH 07/15] Add standalone mode to CI --- .github/workflows/ci.yml | 53 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7e0f162c..9219b8064 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 with: - commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]' + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE];[standalone];[STANDALONE]' commit-filter-separator: ';' fail-fast: true - name: Set TOOLSET @@ -91,7 +91,7 @@ jobs: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 with: - commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]' + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE];[standalone];[STANDALONE]' commit-filter-separator: ';' fail-fast: true - name: Set TOOLSET @@ -155,7 +155,7 @@ jobs: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 with: - commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]' + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE];[standalone];[STANDALONE]' commit-filter-separator: ';' fail-fast: true - name: Set TOOLSET @@ -219,7 +219,7 @@ jobs: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 with: - commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[linux];[Linux];[LINUX]' + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[linux];[Linux];[LINUX];[standalone];[STANDALONE]' commit-filter-separator: ';' fail-fast: true - name: Checkout main boost @@ -267,7 +267,7 @@ jobs: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 with: - commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]' + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX];[standalone];[STANDALONE]' commit-filter-separator: ';' fail-fast: true - name: Checkout main boost @@ -296,3 +296,46 @@ jobs: - name: Test run: ..\..\..\b2 -j3 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES ${{ matrix.suite }} working-directory: ../boost-root/libs/math/test + standalone: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '0' + - uses: mstachniuk/ci-skip@v1 + with: + commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]' + commit-filter-separator: ';' + fail-fast: true + - name: Add repository + continue-on-error: true + id: addrepo + run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + - name: Retry Add Repo + continue-on-error: true + id: retry1 + if: steps.addrepo.outcome=='failure' + run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + - name: Retry Add Repo 2 + continue-on-error: true + id: retry2 + if: steps.retry1.outcome=='failure' + run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + - name: Install packages + run: sudo apt install g++-10 + - name: Checkout main boost + run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root + - name: Update tools/boostdep + run: git submodule update --init tools/boostdep + working-directory: ../boost-root + - name: Copy files + run: cp -r $GITHUB_WORKSPACE/* libs/math + working-directory: ../boost-root + - name: Run CMake + run: cmake -DBUILD_TESTING=1 . + working-directory: ../boost-root/libs/math + - name: Run Compile Tests + run: make -j3 + working-directory: ../boost-root/libs/math From fe9e0c7efaf036df11d4d3c87a6c1aae5e41ec63 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 1 Apr 2021 22:13:15 +0300 Subject: [PATCH 08/15] Compile tests pass in standalone mode --- .../math/special_functions/detail/bernoulli_details.hpp | 4 ++-- include/boost/math/special_functions/detail/erf_inv.hpp | 6 ++++-- .../boost/math/special_functions/detail/polygamma.hpp | 6 ++++-- .../special_functions/detail/unchecked_bernoulli.hpp | 2 +- include/boost/math/special_functions/gamma.hpp | 2 +- include/boost/math/tools/config.hpp | 3 +++ include/boost/math/tools/convert_from_string.hpp | 3 ++- include/boost/math/tools/polynomial_gcd.hpp | 9 ++++++++- test/compile_test/cubic_spline_concept_test.cpp | 5 +++++ test/compile_test/exp_sinh_concept_test.cpp | 7 ++++++- test/compile_test/gauss_concept_test.cpp | 7 ++++++- test/compile_test/gauss_kronrod_concept_test.cpp | 7 ++++++- test/compile_test/naive_monte_carlo_concept_test.cpp | 2 +- .../numerical_differentiation_concept_test.cpp | 6 +++++- test/compile_test/sf_legendre_stieltjes_concept_test.cpp | 4 ++++ test/compile_test/sinh_sinh_concept_test.cpp | 6 +++++- test/compile_test/tanh_sinh_concept_test.cpp | 6 +++++- test/compile_test/trapezoidal_concept_test.cpp | 6 +++++- 18 files changed, 73 insertions(+), 18 deletions(-) diff --git a/include/boost/math/special_functions/detail/bernoulli_details.hpp b/include/boost/math/special_functions/detail/bernoulli_details.hpp index 9d0426f75..0a742c8d3 100644 --- a/include/boost/math/special_functions/detail/bernoulli_details.hpp +++ b/include/boost/math/special_functions/detail/bernoulli_details.hpp @@ -72,7 +72,7 @@ T t2n_asymptotic(int n) // struct max_bernoulli_root_functor { - max_bernoulli_root_functor(ulong_long_type t) : target(static_cast(t)) {} + max_bernoulli_root_functor(unsigned long long t) : target(static_cast(t)) {} double operator()(double n) { BOOST_MATH_STD_USING @@ -99,7 +99,7 @@ inline std::size_t find_bernoulli_overflow_limit(const std::false_type&) // Set a limit on how large the result can ever be: static const double max_result = static_cast((std::numeric_limits::max)() - 1000u); - ulong_long_type t = lltrunc(boost::math::tools::log_max_value()); + unsigned long long t = lltrunc(boost::math::tools::log_max_value()); max_bernoulli_root_functor fun(t); boost::math::tools::equal_floor tol; std::uintmax_t max_iter = boost::math::policies::get_max_root_iterations(); diff --git a/include/boost/math/special_functions/detail/erf_inv.hpp b/include/boost/math/special_functions/detail/erf_inv.hpp index 092067021..f4a68cf12 100644 --- a/include/boost/math/special_functions/detail/erf_inv.hpp +++ b/include/boost/math/special_functions/detail/erf_inv.hpp @@ -13,6 +13,8 @@ #pragma warning(disable:4702) // Unreachable code: optimization warning #endif +#include + namespace boost{ namespace math{ namespace detail{ @@ -310,11 +312,11 @@ T erf_inv_imp(const T& p, const T& q, const Policy& pol, const std::integral_con std::uintmax_t max_iter = policies::get_max_root_iterations(); if(p <= 0.5) { - result = tools::halley_iterate(detail::erf_roots::type, Policy>(p, 1), guess, static_cast(0), tools::max_value(), (policies::digits() * 2) / 3, max_iter); + result = tools::halley_iterate(detail::erf_roots::type, Policy>(p, 1), guess, static_cast(0), tools::max_value(), (policies::digits() * 2) / 3, max_iter); } else { - result = tools::halley_iterate(detail::erf_roots::type, Policy>(q, -1), guess, static_cast(0), tools::max_value(), (policies::digits() * 2) / 3, max_iter); + result = tools::halley_iterate(detail::erf_roots::type, Policy>(q, -1), guess, static_cast(0), tools::max_value(), (policies::digits() * 2) / 3, max_iter); } policies::check_root_iterations("boost::math::erf_inv<%1%>", max_iter, pol); } diff --git a/include/boost/math/special_functions/detail/polygamma.hpp b/include/boost/math/special_functions/detail/polygamma.hpp index f0fd27be2..5c1dc40b4 100644 --- a/include/boost/math/special_functions/detail/polygamma.hpp +++ b/include/boost/math/special_functions/detail/polygamma.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,8 @@ #include #include #include - #include +#include +#include #ifdef _MSC_VER #pragma once @@ -141,7 +143,7 @@ namespace boost { namespace math { namespace detail{ const int iter = N - itrunc(x); if(iter > (int)policies::get_max_series_iterations()) - return policies::raise_evaluation_error(function, ("Exceeded maximum series evaluations evaluating at n = " + boost::lexical_cast(n) + " and x = %1%").c_str(), x, pol); + return policies::raise_evaluation_error(function, ("Exceeded maximum series evaluations evaluating at n = " + std::to_string(n) + " and x = %1%").c_str(), x, pol); const int minus_m_minus_one = -m - 1; diff --git a/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp b/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp index c7c4b68a4..1599b3642 100644 --- a/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp +++ b/include/boost/math/special_functions/detail/unchecked_bernoulli.hpp @@ -71,7 +71,7 @@ struct bernoulli_imp_variant (std::numeric_limits::max_exponent == 16384) && (std::numeric_limits::radix == 2) && (std::numeric_limits::digits <= std::numeric_limits::digits) - && (std::is_convertible::value) ? 3 : (!is_convertible::value ? 4 : 0) + && (std::is_convertible::value) ? 3 : (!std::is_convertible::value ? 4 : 0) ) ); }; diff --git a/include/boost/math/special_functions/gamma.hpp b/include/boost/math/special_functions/gamma.hpp index 6b96e1898..b94dcbbc3 100644 --- a/include/boost/math/special_functions/gamma.hpp +++ b/include/boost/math/special_functions/gamma.hpp @@ -2007,7 +2007,7 @@ inline typename tools::promote_args::type policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast::type, forwarding_policy>(detail::tgammap1m1_imp(static_cast(z), forwarding_policy(), evaluation_type()), "boost::math::tgamma1pm1<%!%>(%1%)"); + return policies::checked_narrowing_cast::type, forwarding_policy>(detail::tgammap1m1_imp(static_cast(z), forwarding_policy(), evaluation_type()), "boost::math::tgamma1pm1<%!%>(%1%)"); } template diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index a824f1153..2c32c8385 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -40,6 +40,9 @@ #define BOOST_DO_JOIN(X, Y) BOOST_DO_JOIN2(X,Y) #define BOOST_DO_JOIN2(X, Y) X##Y +#define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) +#define BOOST_DO_STRINGIZE(X) #X + #endif // BOOST_MATH_STANDALONE #include // for min and max diff --git a/include/boost/math/tools/convert_from_string.hpp b/include/boost/math/tools/convert_from_string.hpp index 13e9dca2b..eb87bc21a 100644 --- a/include/boost/math/tools/convert_from_string.hpp +++ b/include/boost/math/tools/convert_from_string.hpp @@ -26,7 +26,8 @@ namespace boost{ namespace math{ namespace tools{ { #ifdef BOOST_MATH_NO_LEXICAL_CAST // This function should not compile, we don't have the necessary functionality to support it: - static_assert(false, "boost.lexical_cast is not supported in standalone mode."); + static_assert(sizeof(Real) == 0, "boost.lexical_cast is not supported in standalone mode."); + return Real(0); #else return boost::lexical_cast(p); #endif diff --git a/include/boost/math/tools/polynomial_gcd.hpp b/include/boost/math/tools/polynomial_gcd.hpp index fd3b7c1c3..a91b94170 100644 --- a/include/boost/math/tools/polynomial_gcd.hpp +++ b/include/boost/math/tools/polynomial_gcd.hpp @@ -30,7 +30,7 @@ namespace boost::integer { -template ::value_type> +template ::value_type> std::pair gcd_range(Iter first, Iter last) noexcept(std::is_arithmetic_v) { using std::gcd; @@ -60,6 +60,13 @@ inline EuclideanDomain Euclid_gcd(EuclideanDomain a, EuclideanDomain b) noexcept return a; } +enum method_type +{ + method_euclid = 0, + method_binary = 1, + method_mixed = 2 +}; + } // namespace gcd_detail } // namespace boost::integer #endif diff --git a/test/compile_test/cubic_spline_concept_test.cpp b/test/compile_test/cubic_spline_concept_test.cpp index d004c6517..bc7f21642 100644 --- a/test/compile_test/cubic_spline_concept_test.cpp +++ b/test/compile_test/cubic_spline_concept_test.cpp @@ -3,6 +3,9 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include @@ -13,3 +16,5 @@ void compile_and_link_test() s(1.0); s.prime(1.0); } + +#endif diff --git a/test/compile_test/exp_sinh_concept_test.cpp b/test/compile_test/exp_sinh_concept_test.cpp index 6ee6c24e6..df6b2782f 100644 --- a/test/compile_test/exp_sinh_concept_test.cpp +++ b/test/compile_test/exp_sinh_concept_test.cpp @@ -3,10 +3,13 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +// Test requires the use of lexical cast in tools/big_constant.hpp +#ifndef BOOST_MATH_STANDALONE + #include #include - void compile_and_link_test() { boost::math::concepts::std_real_concept a = 0; @@ -14,3 +17,5 @@ void compile_and_link_test() boost::math::quadrature::exp_sinh integrator; integrator.integrate(f, a); } + +#endif diff --git a/test/compile_test/gauss_concept_test.cpp b/test/compile_test/gauss_concept_test.cpp index 85ad3a67b..fbd758eac 100644 --- a/test/compile_test/gauss_concept_test.cpp +++ b/test/compile_test/gauss_concept_test.cpp @@ -3,10 +3,13 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +// Test requires the use of lexical cast in tools/big_constant.hpp +#ifndef BOOST_MATH_STANDALONE + #include #include - void compile_and_link_test() { boost::math::concepts::std_real_concept a = 0; @@ -15,3 +18,5 @@ void compile_and_link_test() boost::math::quadrature::gauss integrator; integrator.integrate(f, a, b); } + +#endif diff --git a/test/compile_test/gauss_kronrod_concept_test.cpp b/test/compile_test/gauss_kronrod_concept_test.cpp index 6b101285c..ef663d7cd 100644 --- a/test/compile_test/gauss_kronrod_concept_test.cpp +++ b/test/compile_test/gauss_kronrod_concept_test.cpp @@ -3,10 +3,13 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +// Test requires the use of lexical cast in tools/big_constant.hpp +#ifndef BOOST_MATH_STANDALONE + #include #include - void compile_and_link_test() { boost::math::concepts::std_real_concept a = 0; @@ -15,3 +18,5 @@ void compile_and_link_test() boost::math::quadrature::gauss_kronrod integrator; integrator.integrate(f, a, b); } + +#endif diff --git a/test/compile_test/naive_monte_carlo_concept_test.cpp b/test/compile_test/naive_monte_carlo_concept_test.cpp index 963e6338f..0b59d9a4b 100644 --- a/test/compile_test/naive_monte_carlo_concept_test.cpp +++ b/test/compile_test/naive_monte_carlo_concept_test.cpp @@ -5,7 +5,7 @@ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#if !defined(_MSC_VER) || (_MSC_VER >= 1900) +#if !defined(BOOST_MATH_STANDALONE) && (!defined(_MSC_VER) || (_MSC_VER >= 1900)) #include #include diff --git a/test/compile_test/numerical_differentiation_concept_test.cpp b/test/compile_test/numerical_differentiation_concept_test.cpp index 7fcb898b8..1c0d5d1ec 100644 --- a/test/compile_test/numerical_differentiation_concept_test.cpp +++ b/test/compile_test/numerical_differentiation_concept_test.cpp @@ -3,13 +3,17 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include - void compile_and_link_test() { boost::math::concepts::std_real_concept x = 0; auto f = [](boost::math::concepts::std_real_concept x) { return x; }; boost::math::differentiation::finite_difference_derivative(f, x); } + +#endif diff --git a/test/compile_test/sf_legendre_stieltjes_concept_test.cpp b/test/compile_test/sf_legendre_stieltjes_concept_test.cpp index e66a83718..a3da878ca 100644 --- a/test/compile_test/sf_legendre_stieltjes_concept_test.cpp +++ b/test/compile_test/sf_legendre_stieltjes_concept_test.cpp @@ -7,7 +7,11 @@ // #includes all the files that it needs to. // +#ifndef BOOST_MATH_STANDALONE + #include #include template class boost::math::legendre_stieltjes; + +#endif diff --git a/test/compile_test/sinh_sinh_concept_test.cpp b/test/compile_test/sinh_sinh_concept_test.cpp index 2b204dc3a..bab3e709d 100644 --- a/test/compile_test/sinh_sinh_concept_test.cpp +++ b/test/compile_test/sinh_sinh_concept_test.cpp @@ -3,13 +3,17 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include - void compile_and_link_test() { auto f = [](boost::math::concepts::std_real_concept x) { return x; }; boost::math::quadrature::sinh_sinh integrator; integrator.integrate(f); } + +#endif diff --git a/test/compile_test/tanh_sinh_concept_test.cpp b/test/compile_test/tanh_sinh_concept_test.cpp index 239d1fb16..3b02f8bb1 100644 --- a/test/compile_test/tanh_sinh_concept_test.cpp +++ b/test/compile_test/tanh_sinh_concept_test.cpp @@ -3,10 +3,12 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include - void compile_and_link_test() { boost::math::concepts::std_real_concept a = 0; @@ -15,3 +17,5 @@ void compile_and_link_test() boost::math::quadrature::tanh_sinh integrator; integrator.integrate(f, a, b); } + +#endif diff --git a/test/compile_test/trapezoidal_concept_test.cpp b/test/compile_test/trapezoidal_concept_test.cpp index 0a8318f56..2159a74f9 100644 --- a/test/compile_test/trapezoidal_concept_test.cpp +++ b/test/compile_test/trapezoidal_concept_test.cpp @@ -3,10 +3,12 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include - boost::math::concepts::std_real_concept func(boost::math::concepts::std_real_concept x) { return x; @@ -18,3 +20,5 @@ void compile_and_link_test() boost::math::concepts::std_real_concept b = 1; boost::math::quadrature::trapezoidal(func, a, b); } + +#endif From ea63e9c3fe843164513dbb88fa83c8a402035910 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 2 Apr 2021 13:31:30 +0300 Subject: [PATCH 09/15] Remove uses of static_assert(false) --- include/boost/math/bindings/detail/big_digamma.hpp | 2 +- include/boost/math/bindings/mpfr.hpp | 10 +++++----- include/boost/math/bindings/mpreal.hpp | 10 +++++----- include/boost/math/cstdfloat/cstdfloat_iostream.hpp | 2 +- .../boost/math/special_functions/detail/fp_traits.hpp | 8 ++++---- include/boost/math/tools/test_value.hpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/boost/math/bindings/detail/big_digamma.hpp b/include/boost/math/bindings/detail/big_digamma.hpp index e0d9b0558..492423844 100644 --- a/include/boost/math/bindings/detail/big_digamma.hpp +++ b/include/boost/math/bindings/detail/big_digamma.hpp @@ -286,7 +286,7 @@ T big_digamma(T x) BOOST_MATH_STD_USING #ifdef BOOST_MATH_STANDALONE - static_assert(false, "big_digamma can not be used in standalone mode"); + static_assert(sizeof(T) == 0, "big_digamma can not be used in standalone mode"); #endif if(x < 0) diff --git a/include/boost/math/bindings/mpfr.hpp b/include/boost/math/bindings/mpfr.hpp index 406b7d68b..9b40c0515 100644 --- a/include/boost/math/bindings/mpfr.hpp +++ b/include/boost/math/bindings/mpfr.hpp @@ -457,7 +457,7 @@ inline mpfr_class skewness(const extreme_value_distribution& // See http://mathworld.wolfram.com/ExtremeValueDistribution.html // #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpfr skewness can not be calculated in standalone mode"); + static_assert(sizeof(Policy) == 0, "mpfr skewness can not be calculated in standalone mode"); #endif return boost::lexical_cast("1.1395470994046486574927930193898461120875997958366"); @@ -468,7 +468,7 @@ inline mpfr_class skewness(const rayleigh_distribution& /*di { // using namespace boost::math::constants; #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpfr skewness can not be calculated in standalone mode"); + static_assert(sizeof(Policy) == 0, "mpfr skewness can not be calculated in standalone mode"); #endif return boost::lexical_cast("0.63111065781893713819189935154422777984404221106391"); @@ -481,7 +481,7 @@ inline mpfr_class kurtosis(const rayleigh_distribution& /*di { // using namespace boost::math::constants; #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpfr kurtosis can not be calculated in standalone mode"); + static_assert(sizeof(Policy) == 0, "mpfr kurtosis can not be calculated in standalone mode"); #endif return boost::lexical_cast("3.2450893006876380628486604106197544154170667057995"); @@ -496,7 +496,7 @@ inline mpfr_class kurtosis_excess(const rayleigh_distribution("0.2450893006876380628486604106197544154170667057995"); @@ -809,7 +809,7 @@ inline mpfr_class erf_inv_imp(const mpfr_class& p, const mpfr_class& q, const Po inline mpfr_class bessel_i0(mpfr_class x) { #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpfr bessel_i0 can not be calculated in standalone mode"); + static_assert(sizeof(x) == 0, "mpfr bessel_i0 can not be calculated in standalone mode"); #endif static const mpfr_class P1[] = { diff --git a/include/boost/math/bindings/mpreal.hpp b/include/boost/math/bindings/mpreal.hpp index 755b2a4a5..aabd91aba 100644 --- a/include/boost/math/bindings/mpreal.hpp +++ b/include/boost/math/bindings/mpreal.hpp @@ -404,7 +404,7 @@ inline mpfr::mpreal skewness(const extreme_value_distribution("1.1395470994046486574927930193898461120875997958366"); @@ -415,7 +415,7 @@ inline mpfr::mpreal skewness(const rayleigh_distribution& { // using namespace boost::math::constants; #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpreal skewness can not be calculated in standalone mode"); + static_assert(sizeof(Policy) == 0, "mpreal skewness can not be calculated in standalone mode"); #endif return boost::lexical_cast("0.63111065781893713819189935154422777984404221106391"); @@ -428,7 +428,7 @@ inline mpfr::mpreal kurtosis(const rayleigh_distribution& { // using namespace boost::math::constants; #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpreal kurtosis can not be calculated in standalone mode"); + static_assert(sizeof(Policy) == 0, "mpreal kurtosis can not be calculated in standalone mode"); #endif return boost::lexical_cast("3.2450893006876380628486604106197544154170667057995"); @@ -443,7 +443,7 @@ inline mpfr::mpreal kurtosis_excess(const rayleigh_distribution("0.2450893006876380628486604106197544154170667057995"); @@ -756,7 +756,7 @@ mpfr::mpreal erf_inv_imp(const mpfr::mpreal& p, const mpfr::mpreal& q, const Pol inline mpfr::mpreal bessel_i0(mpfr::mpreal x) { #ifdef BOOST_MATH_STANDALONE - static_assert(false, "mpreal bessel_i0 can not be calculated in standalone mode"); + static_assert(sizeof(x) == 0, "mpreal bessel_i0 can not be calculated in standalone mode"); #endif static const mpfr::mpreal P1[] = { diff --git a/include/boost/math/cstdfloat/cstdfloat_iostream.hpp b/include/boost/math/cstdfloat/cstdfloat_iostream.hpp index f704aed61..23d6b8d8a 100644 --- a/include/boost/math/cstdfloat/cstdfloat_iostream.hpp +++ b/include/boost/math/cstdfloat/cstdfloat_iostream.hpp @@ -333,7 +333,7 @@ str.append(1U, 'e'); #ifdef BOOST_MATH_STANDALONE - static_assert(false, "IO streams for intel compilers using _Quad types can not be used in standalone mode"); + static_assert(sizeof(string_type), "IO streams for intel compilers using _Quad types can not be used in standalone mode"); #else string_type e = boost::lexical_cast(std::abs(my_exp)); #endif diff --git a/include/boost/math/special_functions/detail/fp_traits.hpp b/include/boost/math/special_functions/detail/fp_traits.hpp index 3dfef7723..de58d55b0 100644 --- a/include/boost/math/special_functions/detail/fp_traits.hpp +++ b/include/boost/math/special_functions/detail/fp_traits.hpp @@ -246,7 +246,7 @@ private: #elif BOOST_MATH_ENDIAN_LITTLE_BYTE static constexpr int offset_ = 4; #else - static_assert(false, "Endian type could not be identified"); + static_assert(sizeof(double_precision) == 0, "Endian type could not be identified"); #endif }; @@ -306,7 +306,7 @@ private: #elif BOOST_MATH_ENDIAN_LITTLE_BYTE static constexpr int offset_ = 4; #else - static_assert(false, "Endian type could not be identified"); + static_assert(sizeof(double_precision) == 0, "Endian type could not be identified"); #endif }; @@ -420,7 +420,7 @@ private: #elif BOOST_MATH_ENDIAN_LITTLE_BYTE static constexpr int offset_ = 12; #else - static_assert(false, "Endian type could not be identified"); + static_assert(sizeof(extended_double_precision) == 0, "Endian type could not be identified"); #endif }; @@ -501,7 +501,7 @@ private: #elif BOOST_MATH_ENDIAN_LITTLE_BYTE static constexpr int offset_ = 12; #else - static_assert(false, "Endian type could not be identified"); + static_assert(sizeof(extended_double_precision) == 0, "Endian type could not be identified"); #endif }; diff --git a/include/boost/math/tools/test_value.hpp b/include/boost/math/tools/test_value.hpp index 608881902..e6718236f 100644 --- a/include/boost/math/tools/test_value.hpp +++ b/include/boost/math/tools/test_value.hpp @@ -84,7 +84,7 @@ inline T create_test_value(largest_float, const char* str, const std::false_type #ifdef BOOST_MATH_INSTRUMENT_CREATE_TEST_VALUE create_type = 3; #elif defined(BOOST_MATH_STANDALONE) - static_assert(false, "Can not create a test value using lexical cast of string in standalone mode"); + static_assert(sizeof(T) == 0, "Can not create a test value using lexical cast of string in standalone mode"); #endif return boost::lexical_cast(str); } From f8c0c13050416adeb858c5bea3a74b83281ce460 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 2 Apr 2021 13:45:09 +0300 Subject: [PATCH 10/15] autodiff ADL fix and remove concept tests --- CMakeLists.txt | 6 ------ include/boost/math/differentiation/autodiff.hpp | 10 +++++----- .../compile_test/barycentric_rational_concept_test.cpp | 5 +++++ test/compile_test/catmull_rom_concept_test.cpp | 5 +++++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cde38db4..75c7c058a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,9 +40,3 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") add_subdirectory(test) endif() - -if(BUILD_EXAMPLE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/example/CMakeLists.txt") - - add_subdirectory(example) - -endif() diff --git a/include/boost/math/differentiation/autodiff.hpp b/include/boost/math/differentiation/autodiff.hpp index 39e561cbf..1286326c2 100644 --- a/include/boost/math/differentiation/autodiff.hpp +++ b/include/boost/math/differentiation/autodiff.hpp @@ -113,9 +113,9 @@ struct type_at { template struct type_at, Depth> { - using type = typename conditional, - typename type_at::type>::type; + using type = typename std::conditional, + typename type_at::type>::type; }; template @@ -2041,13 +2041,13 @@ template using fvar_t = differentiation::detail::fvar; template struct evaluation, Policy> { - using type = fvar_t::type, Order>; + using type = fvar_t::type, Order>; }; template struct evaluation, Policy> { using type = - fvar_t::type, Order>; + fvar_t::type, Order>; }; } // namespace policies diff --git a/test/compile_test/barycentric_rational_concept_test.cpp b/test/compile_test/barycentric_rational_concept_test.cpp index 2fae9046b..9ae6f00f8 100644 --- a/test/compile_test/barycentric_rational_concept_test.cpp +++ b/test/compile_test/barycentric_rational_concept_test.cpp @@ -3,6 +3,9 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include @@ -13,3 +16,5 @@ void compile_and_link_test() boost::math::barycentric_rational s(x, y, 3, 3); s(1.0); } + +#endif diff --git a/test/compile_test/catmull_rom_concept_test.cpp b/test/compile_test/catmull_rom_concept_test.cpp index 9f7b2b498..2f66cc71d 100644 --- a/test/compile_test/catmull_rom_concept_test.cpp +++ b/test/compile_test/catmull_rom_concept_test.cpp @@ -3,6 +3,9 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // + +#ifndef BOOST_MATH_STANDALONE + #include #include @@ -19,3 +22,5 @@ void compile_and_link_test() cat(0.0); cat.prime(0.0); } + +#endif From 7737659d4012f6fbbadd028f8f559539f455818f Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 2 Apr 2021 14:02:29 +0300 Subject: [PATCH 11/15] Add stats include tests --- test/compile_test/stats_anderson_darling_inc_test.cpp | 9 +++++++++ test/compile_test/stats_bivariate_inc_test.cpp | 9 +++++++++ test/compile_test/stats_linear_regression_inc_test.cpp | 9 +++++++++ test/compile_test/stats_ljung_box_inc_test.cpp | 9 +++++++++ test/compile_test/stats_runs_test_inc_test.cpp | 9 +++++++++ test/compile_test/stats_signal_statistics_inc_test.cpp | 9 +++++++++ test/compile_test/stats_t_test_inc_test.cpp | 9 +++++++++ test/compile_test/stats_univariate_inc_test.cpp | 9 +++++++++ test/compile_test/stats_z_test_inc_test.cpp | 9 +++++++++ test/compile_test/test_compile_result.hpp | 6 +----- 10 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 test/compile_test/stats_anderson_darling_inc_test.cpp create mode 100644 test/compile_test/stats_bivariate_inc_test.cpp create mode 100644 test/compile_test/stats_linear_regression_inc_test.cpp create mode 100644 test/compile_test/stats_ljung_box_inc_test.cpp create mode 100644 test/compile_test/stats_runs_test_inc_test.cpp create mode 100644 test/compile_test/stats_signal_statistics_inc_test.cpp create mode 100644 test/compile_test/stats_t_test_inc_test.cpp create mode 100644 test/compile_test/stats_univariate_inc_test.cpp create mode 100644 test/compile_test/stats_z_test_inc_test.cpp diff --git a/test/compile_test/stats_anderson_darling_inc_test.cpp b/test/compile_test/stats_anderson_darling_inc_test.cpp new file mode 100644 index 000000000..b5c3888fe --- /dev/null +++ b/test/compile_test/stats_anderson_darling_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_bivariate_inc_test.cpp b/test/compile_test/stats_bivariate_inc_test.cpp new file mode 100644 index 000000000..603669f87 --- /dev/null +++ b/test/compile_test/stats_bivariate_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_linear_regression_inc_test.cpp b/test/compile_test/stats_linear_regression_inc_test.cpp new file mode 100644 index 000000000..312d3f3dd --- /dev/null +++ b/test/compile_test/stats_linear_regression_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_ljung_box_inc_test.cpp b/test/compile_test/stats_ljung_box_inc_test.cpp new file mode 100644 index 000000000..fa97f5833 --- /dev/null +++ b/test/compile_test/stats_ljung_box_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_runs_test_inc_test.cpp b/test/compile_test/stats_runs_test_inc_test.cpp new file mode 100644 index 000000000..668815405 --- /dev/null +++ b/test/compile_test/stats_runs_test_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_signal_statistics_inc_test.cpp b/test/compile_test/stats_signal_statistics_inc_test.cpp new file mode 100644 index 000000000..dbcbe8a63 --- /dev/null +++ b/test/compile_test/stats_signal_statistics_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_t_test_inc_test.cpp b/test/compile_test/stats_t_test_inc_test.cpp new file mode 100644 index 000000000..c6b90a262 --- /dev/null +++ b/test/compile_test/stats_t_test_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_univariate_inc_test.cpp b/test/compile_test/stats_univariate_inc_test.cpp new file mode 100644 index 000000000..9cc602acb --- /dev/null +++ b/test/compile_test/stats_univariate_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/stats_z_test_inc_test.cpp b/test/compile_test/stats_z_test_inc_test.cpp new file mode 100644 index 000000000..fe290eac2 --- /dev/null +++ b/test/compile_test/stats_z_test_inc_test.cpp @@ -0,0 +1,9 @@ +// Copyright Matt Borland 2021. +// Use, modification and distribution are subject to 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) +// +// Basic sanity check that header +// #includes all the files that it needs to. +// +#include diff --git a/test/compile_test/test_compile_result.hpp b/test/compile_test/test_compile_result.hpp index 0bb419f2c..477855271 100644 --- a/test/compile_test/test_compile_result.hpp +++ b/test/compile_test/test_compile_result.hpp @@ -23,9 +23,7 @@ inline void check_result_imp(double, double){} inline void check_result_imp(long double, long double){} inline void check_result_imp(int, int){} inline void check_result_imp(long, long){} -#ifdef BOOST_HAS_LONG_LONG -inline void check_result_imp(boost::long_long_type, boost::long_long_type){} -#endif +inline void check_result_imp(long long, long long){} inline void check_result_imp(bool, bool){} // @@ -78,9 +76,7 @@ union max_align_type long l; double d; long double ld; -#ifdef BOOST_HAS_LONG_LONG long long ll; -#endif }; template From 40aa3f2d94657d7b515c415d086e0baea3f30132 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 2 Apr 2021 14:17:49 +0300 Subject: [PATCH 12/15] Increase number of threads used by CI --- .github/workflows/ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9219b8064..0f0e00a87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,7 +75,7 @@ jobs: run: ./config_info_travis working-directory: ../boost-root/libs/config/test - name: Test - run: ../../../b2 -j3 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER + run: ../../../b2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER working-directory: ../boost-root/libs/math/test ubuntu-bionic: runs-on: ubuntu-18.04 @@ -139,7 +139,7 @@ jobs: run: ./config_info_travis working-directory: ../boost-root/libs/config/test - name: Test - run: ../../../b2 -j3 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER + run: ../../../b2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER working-directory: ../boost-root/libs/math/test ubuntu-xenial: runs-on: ubuntu-16.04 @@ -203,7 +203,7 @@ jobs: run: ./config_info_travis working-directory: ../boost-root/libs/config/test - name: Test - run: ../../../b2 -j3 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER + run: ../../../b2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER working-directory: ../boost-root/libs/math/test macos: runs-on: macos-latest @@ -246,7 +246,7 @@ jobs: run: ./config_info_travis working-directory: ../boost-root/libs/config/test - name: Test - run: ../../../b2 -j3 toolset=${{ matrix.toolset }} cxxstd=${{ matrix.standard }} ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER + run: ../../../b2 toolset=${{ matrix.toolset }} cxxstd=${{ matrix.standard }} ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES define=SLOW_COMPILER working-directory: ../boost-root/libs/math/test windows: runs-on: windows-latest @@ -294,7 +294,7 @@ jobs: run: config_info_travis working-directory: ../boost-root/libs/config/test - name: Test - run: ..\..\..\b2 -j3 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES ${{ matrix.suite }} + run: ..\..\..\b2 --hash %ARGS% define=CI_SUPPRESS_KNOWN_ISSUES ${{ matrix.suite }} working-directory: ../boost-root/libs/math/test standalone: runs-on: ubuntu-20.04 @@ -337,5 +337,5 @@ jobs: run: cmake -DBUILD_TESTING=1 . working-directory: ../boost-root/libs/math - name: Run Compile Tests - run: make -j3 + run: make -j$((`nproc`+1)) working-directory: ../boost-root/libs/math From 3c34470682e5209fe727faf700eb255459a4ac28 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 2 Apr 2021 14:51:43 +0300 Subject: [PATCH 13/15] Update README with standalone --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index a4e9749d1..befb84ecf 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ Quaternion and Octonians are class templates similar to std::complex. The full documentation is available on [boost.org](http://www.boost.org/doc/libs/release/libs/math). +### Standalone Mode (Beta) + +Defining BOOST_MATH_STANDALONE allows Boost.Math to be used without any Boost dependencies. Some functionality is reduced in this mode. A static_assert message will alert you if a particular feature has been disabled by standalone mode. + ### Build Status | | Master | Develop | @@ -111,6 +115,7 @@ The default action for a PR or commit to a PR is for CI to run the full compleme * [linux] to test using GCC Versions 5-10 and Clang Versions 5-10 on Ubuntu LTS versions 16.04-20.04. * [apple] to test Apple Clang on the latest version of MacOS. * [windows] to test MSVC-14.0, MSVC-14.2 and mingw on the latest version of Windows. + * [standalone] to run standalone mode commpile tests ### Building documentation ### From 16a91de3b45c55c92b8275e432d5282aea7f36d8 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 3 Apr 2021 16:46:00 +0300 Subject: [PATCH 14/15] Disable standalone tests of cstdfloat concept [standalone] --- include/boost/math/tools/ulps_plot.hpp | 13 ++++++++++++- test/compile_test/cstdfloat_concept_check_1.cpp | 3 +++ test/compile_test/cstdfloat_concept_check_2.cpp | 4 +++- test/compile_test/cstdfloat_concept_check_3.cpp | 3 +++ test/compile_test/cstdfloat_concept_check_4.cpp | 3 +++ test/compile_test/poison.hpp | 11 ++--------- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/include/boost/math/tools/ulps_plot.hpp b/include/boost/math/tools/ulps_plot.hpp index 51f61a96f..61fea4b4b 100644 --- a/include/boost/math/tools/ulps_plot.hpp +++ b/include/boost/math/tools/ulps_plot.hpp @@ -14,10 +14,13 @@ #include #include #include +#include #include #include -#include +#ifndef BOOST_MATH_STANDALONE +#include +#endif // Design of this function comes from: // https://blogs.mathworks.com/cleve/2017/01/23/ulps-plots-reveal-math-function-accurary/ @@ -496,8 +499,16 @@ ulps_plot::ulps_plot(F hi_acc_impl, CoarseReal a, Co std::random_device rd; gen.seed(rd()); } + // Boost's uniform_real_distribution can generate quad and multiprecision random numbers; std's cannot: + #ifndef BOOST_MATH_STANDALONE boost::random::uniform_real_distribution dis(static_cast(a), static_cast(b)); + #else + // Use std::random in standalone mode if it is a type that the standard library can support (float, double, or long double) + static_assert(std::numeric_limits::digits10 <= std::numeric_limits::digits10, "Standalone mode does not support types with precision that exceeds long double"); + std::uniform_real_distribution dis(static_cast(a), static_cast(b)); + #endif + precise_abscissas_.resize(samples); coarse_abscissas_.resize(samples); diff --git a/test/compile_test/cstdfloat_concept_check_1.cpp b/test/compile_test/cstdfloat_concept_check_1.cpp index 66db491d3..6d95ab3b8 100644 --- a/test/compile_test/cstdfloat_concept_check_1.cpp +++ b/test/compile_test/cstdfloat_concept_check_1.cpp @@ -3,6 +3,8 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_MATH_STANDALONE + #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false #include @@ -21,3 +23,4 @@ int main(int #endif } +#endif diff --git a/test/compile_test/cstdfloat_concept_check_2.cpp b/test/compile_test/cstdfloat_concept_check_2.cpp index b3f6509a3..4fbc15889 100644 --- a/test/compile_test/cstdfloat_concept_check_2.cpp +++ b/test/compile_test/cstdfloat_concept_check_2.cpp @@ -3,13 +3,14 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_MATH_STANDALONE + #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false #include #include "poison.hpp" #include "instantiate.hpp" - int main(int #ifdef BOOST_FLOAT80_C argc @@ -22,3 +23,4 @@ int main(int #endif } +#endif diff --git a/test/compile_test/cstdfloat_concept_check_3.cpp b/test/compile_test/cstdfloat_concept_check_3.cpp index f188de51c..ab2903063 100644 --- a/test/compile_test/cstdfloat_concept_check_3.cpp +++ b/test/compile_test/cstdfloat_concept_check_3.cpp @@ -3,6 +3,8 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_MATH_STANDALONE + #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false #include @@ -22,3 +24,4 @@ int main(int #endif } +#endif diff --git a/test/compile_test/cstdfloat_concept_check_4.cpp b/test/compile_test/cstdfloat_concept_check_4.cpp index 4b0e09cfd..640267364 100644 --- a/test/compile_test/cstdfloat_concept_check_4.cpp +++ b/test/compile_test/cstdfloat_concept_check_4.cpp @@ -3,6 +3,8 @@ // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifndef BOOST_MATH_STANDALONE + #define BOOST_MATH_ASSERT_UNDEFINED_POLICY false #include @@ -22,3 +24,4 @@ int main(int #endif } +#endif diff --git a/test/compile_test/poison.hpp b/test/compile_test/poison.hpp index d91a6d8ff..91bf78233 100644 --- a/test/compile_test/poison.hpp +++ b/test/compile_test/poison.hpp @@ -14,7 +14,6 @@ // we basically need to include every std lib header we use, otherwise // our poisoned macros can break legit std lib code. // -#include #include #include #include @@ -39,18 +38,10 @@ #include #include #include -#ifndef BOOST_NO_CXX11_HDR_FUTURE #include -#endif -#ifndef BOOST_NO_CXX11_HDR_THREAD #include -#endif -#ifndef BOOST_NO_CXX11_HDR_RANDOM #include -#endif -#ifndef BOOST_NO_CXX11_HDR_CHRONO #include -#endif #include // @@ -61,7 +52,9 @@ // // lexical_cast uses macro unsafe isinf etc, so we have to include this as well: // +#ifndef BOOST_MATH_STANDALONE #include +#endif // // Poison all the function-like macros in C99 so if we accidentally call them From 0a9d7a152cc292394cb1b334146a383f8ca4bcdf Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sun, 4 Apr 2021 09:54:19 +0300 Subject: [PATCH 15/15] Fix for TBB failure and add license [standalone] --- .github/workflows/ci.yml | 2 +- LICENSE | 23 +++++++++++++++++++ .../special_functions/detail/fp_traits.hpp | 4 +++- .../math/statistics/bivariate_statistics.hpp | 1 + include/boost/math/tools/config.hpp | 4 ++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 LICENSE diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f0e00a87..230b8b0ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -334,7 +334,7 @@ jobs: run: cp -r $GITHUB_WORKSPACE/* libs/math working-directory: ../boost-root - name: Run CMake - run: cmake -DBUILD_TESTING=1 . + run: cmake -DBUILD_TESTING=1 -DCMAKE_CXX_COMPILER=g++-10 . working-directory: ../boost-root/libs/math - name: Run Compile Tests run: make -j$((`nproc`+1)) diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..36b7cd93c --- /dev/null +++ b/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/include/boost/math/special_functions/detail/fp_traits.hpp b/include/boost/math/special_functions/detail/fp_traits.hpp index de58d55b0..cb384bec7 100644 --- a/include/boost/math/special_functions/detail/fp_traits.hpp +++ b/include/boost/math/special_functions/detail/fp_traits.hpp @@ -33,11 +33,13 @@ With these techniques, the code could be simplified. #define BOOST_MATH_ENDIAN_BIG_BYTE BOOST_ENDIAN_BIG_BYTE #define BOOST_MATH_ENDIAN_LITTLE_BYTE BOOST_ENDIAN_LITTLE_BYTE -#elif (__cplusplus > 202000L || _MSVC_LANG > 202000L) && __has_include() +#elif (__cplusplus > 202000L || _MSVC_LANG > 202000L) +#if __has_include() #include #define BOOST_MATH_ENDIAN_BIG_BYTE (std::endian::native == std::endian::big) #define BOOST_MATH_ENDIAN_LITTLE_BYTE (std::endian::native == std::endian::little) +#endif #elif defined(_WIN32) diff --git a/include/boost/math/statistics/bivariate_statistics.hpp b/include/boost/math/statistics/bivariate_statistics.hpp index 2d0e00762..b0bd9d83c 100644 --- a/include/boost/math/statistics/bivariate_statistics.hpp +++ b/include/boost/math/statistics/bivariate_statistics.hpp @@ -18,6 +18,7 @@ #include #include #include +#include // Support compilers with P0024R2 implemented without linking TBB // https://en.cppreference.com/w/cpp/compiler_support diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index 2c32c8385..70b741258 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -31,9 +31,13 @@ #if (__cplusplus > 201700L || _MSVC_LANG > 201700L) #define BOOST_IF_CONSTEXPR if constexpr +#if !__has_include() +#define BOOST_NO_CXX17_HDR_EXECUTION +#endif #else #define BOOST_IF_CONSTEXPR if #define BOOST_NO_CXX17_IF_CONSTEXPR +#define BOOST_NO_CXX17_HDR_EXECUTION #endif #define BOOST_JOIN(X, Y) BOOST_DO_JOIN(X, Y)