From 16a91de3b45c55c92b8275e432d5282aea7f36d8 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sat, 3 Apr 2021 16:46:00 +0300 Subject: [PATCH] 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