diff --git a/include/boost/math/special_functions/expm1.hpp b/include/boost/math/special_functions/expm1.hpp index fccf97bc3..94e092128 100644 --- a/include/boost/math/special_functions/expm1.hpp +++ b/include/boost/math/special_functions/expm1.hpp @@ -160,6 +160,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) if(a < tools::epsilon()) return x; + // LCOV_EXCL_START static const float Y = 0.10281276702880859375e1f; static const T n[] = { BOOST_MATH_BIG_CONSTANT(T, 64, -0.281276702880859375e-1), @@ -179,6 +180,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) BOOST_MATH_BIG_CONSTANT(T, 64, -0.387922804997682392562e-4), BOOST_MATH_BIG_CONSTANT(T, 64, 0.807473180049193557294e-6) }; + // LCOV_EXCL_STOP T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x); return result; @@ -207,6 +209,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) if(a < tools::epsilon()) return x; + // LCOV_EXCL_START static const float Y = 0.10281276702880859375e1f; static const T n[] = { BOOST_MATH_BIG_CONSTANT(T, 113, -0.28127670288085937499999999999999999854e-1), @@ -233,6 +236,7 @@ T expm1_imp(T x, const std::integral_constant&, const P& pol) BOOST_MATH_BIG_CONSTANT(T, 113, -0.29477341859111589208776402638429026517e-10), BOOST_MATH_BIG_CONSTANT(T, 113, 0.13222065991022301420255904060628100924e-12) }; + // LCOV_EXCL_STOP T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x); return result; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index cce2a8fcf..42d02caf1 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -164,6 +164,7 @@ test-suite special_fun : [ run ccmath_fma_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : BOOST_MATH_TEST_FLOAT128 "-Bstatic -lquadmath -Bdynamic" ] ] [ run ccmath_signbit_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : BOOST_MATH_TEST_FLOAT128 "-Bstatic -lquadmath -Bdynamic" ] ] [ run log1p_expm1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ] + [ run test_expm1_extra.cpp ../../test/build//boost_unit_test_framework : : : [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : BOOST_MATH_TEST_FLOAT128 "-Bstatic -lquadmath -Bdynamic" ] ] [ run powm1_sqrtp1m1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ] [ run git_issue_705.cpp ../../test/build//boost_unit_test_framework ] [ run git_issue_810.cpp ../../test/build//boost_unit_test_framework ] diff --git a/test/test_expm1_extra.cpp b/test/test_expm1_extra.cpp new file mode 100644 index 000000000..02e1c59ea --- /dev/null +++ b/test/test_expm1_extra.cpp @@ -0,0 +1,67 @@ +// Copyright John Maddock 2024. +// 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) + +#define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error + +#define BOOST_TEST_MAIN +#include +#include +#include +#include + +#define SC_(x) static_cast(BOOST_STRINGIZE(x)) + +#include "log1p_expm1_test.hpp" + +// +// DESCRIPTION: +// ~~~~~~~~~~~~ +// +// This file tests the functions log1p and expm1 for +// simple multiprecision types which are able to utilize +// our own rational approximations. This tests those +// approximations even when float/double/long double +// are not using them. +// + +void expected_results() +{ + // + // Define the max and mean errors expected for + // various compilers and platforms. + // + + // + // Catch all cases come last: + // + add_expected_result( + ".*", // compiler + ".*", // stdlib + ".*", // platform + ".*", // test type(s) + ".*", // test data group + ".*", // test function + 4, // Max Peek error + 3); // Max mean error + + // + // Finish off by printing out the compiler/stdlib/platform names, + // we do this to make it easier to mark up expected error rates. + // + std::cout << "Tests run with " << BOOST_COMPILER << ", " + << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; +} + + +BOOST_AUTO_TEST_CASE( test_main ) +{ + expected_results(); + + test(boost::multiprecision::cpp_bin_float_double(0), "UDT double"); + test(boost::multiprecision::cpp_bin_float_double_extended(0), "UDT 80-bit long double"); + test(boost::multiprecision::cpp_bin_float_quad(0), "UDT quad-float"); + test(boost::multiprecision::number >(0), "UDT 36 digits"); +} +