2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Correct some CI test failures.

Stop referencing boost::lexical_cast even in templates which aren't instantiated.
Fix missing macro definition in tr1.hpp.
Correct include order in some tests so we get consistent definitions for BOOST_HAS_FLOAT128.
This commit is contained in:
jzmaddock
2022-01-17 19:37:08 +00:00
parent 192888e732
commit 7850b8c2dd
10 changed files with 37 additions and 23 deletions

View File

@@ -79,7 +79,7 @@ test-suite examples :
#[ # run inverse_chi_squared_find_df_example.cpp ]
#[ run lambert_w_basic_example.cpp ]
[ run lambert_w_basic_example.cpp : : : [ requires cxx11_numeric_limits ] ]
[ run lambert_w_simple_examples.cpp : : : [ requires cxx11_numeric_limits ] ]
[ run lambert_w_simple_examples.cpp : : : [ requires cxx11_numeric_limits ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>-lquadmath ] ]
[ run lambert_w_precision_example.cpp : : : [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : <linkflags>-lquadmath ] [ requires cxx11_numeric_limits cxx11_explicit_conversion_operators ] ]
[ run inverse_gamma_example.cpp ]

View File

@@ -62,6 +62,10 @@ BOOST_MATH_INSTRUMENT_LAMBERT_W_SMALL_Z_SERIES_ITERATIONS // Show evaluation of
#include <boost/math/tools/big_constant.hpp>
#include <boost/math/tools/cxx03_warn.hpp>
#ifndef BOOST_MATH_STANDALONE
#include <boost/lexical_cast.hpp>
#endif
#include <limits>
#include <cmath>
#include <limits>
@@ -179,7 +183,12 @@ inline double must_reduce_to_double(const T& z, const std::true_type&)
template <typename T>
inline double must_reduce_to_double(const T& z, const std::false_type&)
{ // try a lexical_cast and hope for the best:
#ifndef BOOST_MATH_STANDALONE
return boost::lexical_cast<double>(z);
#else
static_assert(sizeof(T) == 0, "Unsupported in standalone mode: don't know how to cast your number type to a double.");
return 0.0;
#endif
}
//! \brief Schroeder method, fifth-order update formula,

View File

@@ -82,13 +82,16 @@ inline T create_test_value(largest_float, const char* str, const std::false_type
{ // Create test value using from lexical cast of decimal digit string const char* str.
// For example, extended precision or other User-Defined types which are NOT constructible from a string
// (NOR constructible from a long double).
// (This is case T1 = false_type and T2 == false_type).
#ifdef BOOST_MATH_INSTRUMENT_CREATE_TEST_VALUE
// (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)
#endif
#if defined(BOOST_MATH_STANDALONE)
static_assert(sizeof(T) == 0, "Can not create a test value using lexical cast of string in standalone mode");
#endif
return T();
#else
return boost::lexical_cast<T>(str);
#endif
}
// T real type, x a decimal digits representation of a floating-point, for example: 12.34.

View File

@@ -20,12 +20,12 @@
namespace boost{ namespace math{ namespace tr1{ extern "C"{
#else
#define BOOST_PREVENT_MACRO_SUBSTITUTION /**/
#endif // __cplusplus
#ifndef BOOST_PREVENT_MACRO_SUBSTITUTION
#define BOOST_PREVENT_MACRO_SUBSTITUTION /**/
#endif
// we need to import/export our code only if the user has specifically
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
// libraries to be dynamically linked, or BOOST_MATH_TR1_DYN_LINK

View File

@@ -1143,7 +1143,6 @@ test-suite misc :
[ compile compile_test/tools_engel_expansion_incl_test.cpp : [ requires cxx17_std_apply cxx17_if_constexpr ] [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]
[ compile compile_test/tools_header_deprecated_incl_test.cpp : [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]
[ compile compile_test/tools_is_detected_incl_test.cpp : [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]
[ compile compile_test/tools_lexical_cast_incl_test.cpp : [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]
[ compile compile_test/tools_luroth_expansion_incl_test.cpp : [ requires cxx17_std_apply cxx17_if_constexpr ] [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]
[ compile compile_test/tools_mp_incl_test.cpp : [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]
[ compile compile_test/tools_norms_incl_test.cpp : [ requires cxx17_std_apply cxx17_if_constexpr ] [ check-target-builds ../config//is_ci_sanitizer_run "Sanitizer CI run" : <build>no ] ]

View File

@@ -8,12 +8,12 @@
#include "math_unit_test.hpp"
#include <boost/math/tools/centered_continued_fraction.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/core/demangle.hpp>
#ifdef BOOST_HAS_FLOAT128
#include <boost/multiprecision/float128.hpp>
using boost::multiprecision::float128;
#endif
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/core/demangle.hpp>
using boost::math::tools::centered_continued_fraction;
using boost::multiprecision::cpp_bin_float_100;

View File

@@ -1,9 +0,0 @@
// 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 <boost/math/tools/lexical_cast.hpp>

View File

@@ -18,6 +18,7 @@
#include <boost/test/tools/floating_point_comparison.hpp>
#include <boost/math/quadrature/gauss.hpp>
#include <boost/math/special_functions/sinc.hpp>
#include <boost/math/tools/test_value.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/cpp_complex.hpp>

View File

@@ -8,11 +8,11 @@
#include "math_unit_test.hpp"
#include <boost/math/tools/luroth_expansion.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
#ifdef BOOST_HAS_FLOAT128
#include <boost/multiprecision/float128.hpp>
using boost::multiprecision::float128;
#endif
#include <boost/multiprecision/cpp_bin_float.hpp>
using boost::math::tools::luroth_expansion;
using boost::multiprecision::cpp_bin_float_100;

View File

@@ -91,6 +91,17 @@ using boost::math::constants::root_two;
using boost::math::constants::root_two_pi;
using boost::math::constants::root_pi;
template <class Real>
inline Real cast_mp_to_real(const cpp_bin_float_100& arg)
{
return static_cast<Real>(arg);
}
template <>
inline boost::math::concepts::real_concept cast_mp_to_real<boost::math::concepts::real_concept>(const cpp_bin_float_100& arg)
{
return static_cast<boost::math::concepts::real_concept>(static_cast<long double>(arg));
}
template <class T>
void print_levels(const T& v, const char* suffix)
{
@@ -567,7 +578,7 @@ void test_crc()
// Casting to cpp_bin_float_100 beforehand fixes most of them.
cpp_bin_float_100 np1 = n + 1;
cpp_bin_float_100 mp1 = m + 1;
Q_expected = static_cast<Real>(tgamma(np1)/pow(mp1, np1));
Q_expected = cast_mp_to_real<Real>(tgamma(np1)/pow(mp1, np1));
BOOST_CHECK_CLOSE_FRACTION(Q, Q_expected, tol);
}
}