From a9bc5d65c7ebf868cb98c646c87769085b255714 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 09:29:03 +0100 Subject: [PATCH 1/7] First batch changes double-fp-backend --- reporting/performance/test_kn.cpp | 4 +++- test/test_bessel_i.hpp | 2 +- test/test_bessel_j.hpp | 5 ++++- test/test_bessel_k.hpp | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/reporting/performance/test_kn.cpp b/reporting/performance/test_kn.cpp index bf2c8cda19..f56ba0b17f 100644 --- a/reporting/performance/test_kn.cpp +++ b/reporting/performance/test_kn.cpp @@ -48,7 +48,9 @@ static const std::array, 9> kn_data = { { { { SC_(-10.0), SC_(1.0), SC_(1.80713289901029454691597861302340015908245782948536080022119e8) } }, { { SC_(100.0), SC_(5.0), SC_(7.03986019306167654653386616796116726248616158936088056952477e115) } }, { { SC_(100.0), SC_(80.0), SC_(8.39287107246490782848985384895907681748152272748337807033319e-12) } }, - { { SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) } }, + (std::numeric_limits::is_specialized && (std::numeric_limits::min_exponent10 > -300)) + ? { { SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) } } + : { { SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) } }, } }; int main() diff --git a/test/test_bessel_i.hpp b/test/test_bessel_i.hpp index aa4f6a4ea3..ca021fa8c5 100644 --- a/test/test_bessel_i.hpp +++ b/test/test_bessel_i.hpp @@ -214,7 +214,7 @@ void test_bessel(T, const char* name) BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_i(T(0.5), T(11357)), SC_(7.173138695269929329584326974917488634629578339622112563648e4929), tolerance * mul); } #endif - BOOST_IF_CONSTEXPR (std::numeric_limits::max_exponent > 1000) + BOOST_IF_CONSTEXPR (std::numeric_limits::max_exponent10 > 304) { BOOST_IF_CONSTEXPR(std::is_floating_point::value == false) tolerance *= 4; // multiprecision type. diff --git a/test/test_bessel_j.hpp b/test/test_bessel_j.hpp index c0b719ad89..1e48d4550a 100644 --- a/test/test_bessel_j.hpp +++ b/test/test_bessel_j.hpp @@ -281,7 +281,10 @@ void test_bessel(T, const char* name) BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(0), T(2.5)), boost::math::cyl_bessel_j(T(0), T(-2.5))); BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(1), T(2.5)), -boost::math::cyl_bessel_j(T(1), T(-2.5))); #ifndef SYCL_LANGUAGE_VERSION - BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_j(364, T(38.5)), SC_(1.793940496519190500748409872348034004417458734118663909894e-309), tolerance); + BOOST_IF_CONSTEXPR (std::numeric_limits::min_exponent10 < -314) + { + BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_j(364, T(38.5)), SC_(1.793940496519190500748409872348034004417458734118663909894e-309), tolerance); + } #endif // // Special cases at infinity: diff --git a/test/test_bessel_k.hpp b/test/test_bessel_k.hpp index 6a2a8179d9..732c68f477 100644 --- a/test/test_bessel_k.hpp +++ b/test/test_bessel_k.hpp @@ -133,7 +133,9 @@ void test_bessel(T, const char* name) {{ SC_(-10.0), SC_(1.0), SC_(1.80713289901029454691597861302340015908245782948536080022119e8) }}, {{ SC_(100.0), SC_(5.0), SC_(7.03986019306167654653386616796116726248616158936088056952477e115) }}, {{ SC_(100.0), SC_(80.0), SC_(8.39287107246490782848985384895907681748152272748337807033319e-12) }}, - {{ SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) }}, + (std::numeric_limits::is_specialized && (std::numeric_limits::min_exponent10 > -300)) + ? {{ SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) }} + : {{ SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) }}, }}; static const std::array::type, 3>, 11> kv_data = {{ {{ SC_(0.5), SC_(0.875), SC_(0.558532231646608646115729767013630967055657943463362504577189) }}, From 8a45d187c7a6082e127553c776a850671cf3436e Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 10:16:30 +0100 Subject: [PATCH 2/7] Try repairing table syntax errors --- reporting/performance/test_kn.cpp | 4 ++-- test/test_bessel_k.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reporting/performance/test_kn.cpp b/reporting/performance/test_kn.cpp index f56ba0b17f..73798ce0e0 100644 --- a/reporting/performance/test_kn.cpp +++ b/reporting/performance/test_kn.cpp @@ -49,8 +49,8 @@ static const std::array, 9> kn_data = { { { { SC_(100.0), SC_(5.0), SC_(7.03986019306167654653386616796116726248616158936088056952477e115) } }, { { SC_(100.0), SC_(80.0), SC_(8.39287107246490782848985384895907681748152272748337807033319e-12) } }, (std::numeric_limits::is_specialized && (std::numeric_limits::min_exponent10 > -300)) - ? { { SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) } } - : { { SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) } }, + ? std::array { { SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) } } + : std::array { { SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) } }, } }; int main() diff --git a/test/test_bessel_k.hpp b/test/test_bessel_k.hpp index 732c68f477..a1163f1d85 100644 --- a/test/test_bessel_k.hpp +++ b/test/test_bessel_k.hpp @@ -134,8 +134,8 @@ void test_bessel(T, const char* name) {{ SC_(100.0), SC_(5.0), SC_(7.03986019306167654653386616796116726248616158936088056952477e115) }}, {{ SC_(100.0), SC_(80.0), SC_(8.39287107246490782848985384895907681748152272748337807033319e-12) }}, (std::numeric_limits::is_specialized && (std::numeric_limits::min_exponent10 > -300)) - ? {{ SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) }} - : {{ SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) }}, + ? std::array::type, 3> {{ SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) }} + : std::array::type, 3> {{ SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) }}, }}; static const std::array::type, 3>, 11> kv_data = {{ {{ SC_(0.5), SC_(0.875), SC_(0.558532231646608646115729767013630967055657943463362504577189) }}, From 464922e136e7431258567ec65681e91dc1a79db0 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 13:13:30 +0100 Subject: [PATCH 3/7] Attempt to restore 3 missing cover lines --- test/test_bessel_j.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_bessel_j.hpp b/test/test_bessel_j.hpp index 1e48d4550a..8a21a13800 100644 --- a/test/test_bessel_j.hpp +++ b/test/test_bessel_j.hpp @@ -281,8 +281,9 @@ void test_bessel(T, const char* name) BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(0), T(2.5)), boost::math::cyl_bessel_j(T(0), T(-2.5))); BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(1), T(2.5)), -boost::math::cyl_bessel_j(T(1), T(-2.5))); #ifndef SYCL_LANGUAGE_VERSION - BOOST_IF_CONSTEXPR (std::numeric_limits::min_exponent10 < -314) + BOOST_IF_CONSTEXPR (std::numeric_limits::min_exponent10 <= -308) { + // TODO: ckormanyos Ask jzmaddock and mborland about DEN-value. BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_j(364, T(38.5)), SC_(1.793940496519190500748409872348034004417458734118663909894e-309), tolerance); } #endif From dbc9e72b70e0a515bcbf59539cb9d49e1713feb0 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 13:25:47 +0100 Subject: [PATCH 4/7] Repair typo on double min_exponent10 --- test/test_bessel_j.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_bessel_j.hpp b/test/test_bessel_j.hpp index 8a21a13800..6b41b5cd5b 100644 --- a/test/test_bessel_j.hpp +++ b/test/test_bessel_j.hpp @@ -281,9 +281,8 @@ void test_bessel(T, const char* name) BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(0), T(2.5)), boost::math::cyl_bessel_j(T(0), T(-2.5))); BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(1), T(2.5)), -boost::math::cyl_bessel_j(T(1), T(-2.5))); #ifndef SYCL_LANGUAGE_VERSION - BOOST_IF_CONSTEXPR (std::numeric_limits::min_exponent10 <= -308) + BOOST_IF_CONSTEXPR (std::numeric_limits::min_exponent10 <= -307) { - // TODO: ckormanyos Ask jzmaddock and mborland about DEN-value. BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_j(364, T(38.5)), SC_(1.793940496519190500748409872348034004417458734118663909894e-309), tolerance); } #endif From 03085568a972f5616b2bff3c3f3747cbd977b74b Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 15:38:12 +0100 Subject: [PATCH 5/7] Increase tols for some updated MSVC runners --- test/cubic_roots_test.cpp | 6 +++--- test/linear_regression_test.cpp | 4 ++-- test/quartic_roots_test.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/cubic_roots_test.cpp b/test/cubic_roots_test.cpp index c4e9031296..b6ee44af2a 100644 --- a/test/cubic_roots_test.cpp +++ b/test/cubic_roots_test.cpp @@ -99,7 +99,7 @@ template void test_zero_coefficients() { auto roots = cubic_roots(a, b, c, d); // I could check the condition number here, but this is fine right? - if (!CHECK_ULP_CLOSE(r[0], roots[0], (std::numeric_limits::digits > 100 ? 120 : 25))) { + if (!CHECK_ULP_CLOSE(r[0], roots[0], (std::numeric_limits::digits > 100 ? 120 : 60))) { std::cerr << " Polynomial x^3 + " << b << "x^2 + " << c << "x + " << d << " has roots {"; std::cerr << r[0] << ", " << r[1] << ", " << r[2] @@ -107,8 +107,8 @@ template void test_zero_coefficients() { std::cerr << roots[0] << ", " << roots[1] << ", " << roots[2] << "}\n"; } - CHECK_ULP_CLOSE(r[1], roots[1], 25); - CHECK_ULP_CLOSE(r[2], roots[2], (std::numeric_limits::digits > 100 ? 120 : 25)); + CHECK_ULP_CLOSE(r[1], roots[1], 80); + CHECK_ULP_CLOSE(r[2], roots[2], (std::numeric_limits::digits > 100 ? 120 : 80)); for (auto root : roots) { auto res = cubic_root_residual(a, b, c, d, root); CHECK_LE(abs(res[0]), res[1]); diff --git a/test/linear_regression_test.cpp b/test/linear_regression_test.cpp index 27317ea144..03570c53ac 100644 --- a/test/linear_regression_test.cpp +++ b/test/linear_regression_test.cpp @@ -223,7 +223,7 @@ void test_scaling_relations() Real c1_lambda = std::get<1>(temp); Real Rsquared_lambda = std::get<2>(temp); - CHECK_ULP_CLOSE(lambda*c0, c0_lambda, 50); + CHECK_ULP_CLOSE(lambda*c0, c0_lambda, 70); CHECK_ULP_CLOSE(lambda*c1, c1_lambda, 30); CHECK_ULP_CLOSE(Rsquared, Rsquared_lambda, 3); @@ -241,7 +241,7 @@ void test_scaling_relations() Real c1_ = std::get<1>(temp); Real Rsquared_ = std::get<2>(temp); - CHECK_ULP_CLOSE(c0, c0_, 70); + CHECK_ULP_CLOSE(c0, c0_, 100); CHECK_ULP_CLOSE(c1, c1_*lambda, 50); CHECK_ULP_CLOSE(Rsquared, Rsquared_, 50); diff --git a/test/quartic_roots_test.cpp b/test/quartic_roots_test.cpp index 173e86ee9d..f46330e3d1 100644 --- a/test/quartic_roots_test.cpp +++ b/test/quartic_roots_test.cpp @@ -117,8 +117,8 @@ void test_zero_coefficients() roots = quartic_roots(a, b, c, d, e); // I could check the condition number here, but this is fine right? - CHECK_ULP_CLOSE(r[0], roots[0], 160); - CHECK_ULP_CLOSE(r[1], roots[1], 260); + CHECK_ULP_CLOSE(r[0], roots[0], 340); + CHECK_ULP_CLOSE(r[1], roots[1], 440); CHECK_ULP_CLOSE(r[2], roots[2], 220); CHECK_ULP_CLOSE(r[3], roots[3], 160); } From 214e19cc5183992f899defe028978eeef95dd29c Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 18:33:28 +0100 Subject: [PATCH 6/7] Apply cyl_bessel_k0 logic change 113 bits --- include/boost/math/special_functions/detail/bessel_k0.hpp | 2 +- reporting/performance/test_kn.cpp | 4 +--- test/test_bessel_k.hpp | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/include/boost/math/special_functions/detail/bessel_k0.hpp b/include/boost/math/special_functions/detail/bessel_k0.hpp index bab202b6cd..a9387c865b 100644 --- a/include/boost/math/special_functions/detail/bessel_k0.hpp +++ b/include/boost/math/special_functions/detail/bessel_k0.hpp @@ -470,7 +470,7 @@ BOOST_MATH_GPU_ENABLED T bessel_k0_imp(const T& x, const boost::math::integral_c BOOST_MATH_BIG_CONSTANT(T, 113, 8.370574966987293592457152146806662562e+03), BOOST_MATH_BIG_CONSTANT(T, 113, 4.871254714311063594080644835895740323e+01) }; - if(x < tools::log_max_value()) + if(-x > tools::log_min_value()) return ((tools::evaluate_rational(P, Q, T(1 / x)) + Y) * exp(-x) / sqrt(x)); else { diff --git a/reporting/performance/test_kn.cpp b/reporting/performance/test_kn.cpp index 73798ce0e0..bf2c8cda19 100644 --- a/reporting/performance/test_kn.cpp +++ b/reporting/performance/test_kn.cpp @@ -48,9 +48,7 @@ static const std::array, 9> kn_data = { { { { SC_(-10.0), SC_(1.0), SC_(1.80713289901029454691597861302340015908245782948536080022119e8) } }, { { SC_(100.0), SC_(5.0), SC_(7.03986019306167654653386616796116726248616158936088056952477e115) } }, { { SC_(100.0), SC_(80.0), SC_(8.39287107246490782848985384895907681748152272748337807033319e-12) } }, - (std::numeric_limits::is_specialized && (std::numeric_limits::min_exponent10 > -300)) - ? std::array { { SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) } } - : std::array { { SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) } }, + { { SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) } }, } }; int main() diff --git a/test/test_bessel_k.hpp b/test/test_bessel_k.hpp index a1163f1d85..6a2a8179d9 100644 --- a/test/test_bessel_k.hpp +++ b/test/test_bessel_k.hpp @@ -133,9 +133,7 @@ void test_bessel(T, const char* name) {{ SC_(-10.0), SC_(1.0), SC_(1.80713289901029454691597861302340015908245782948536080022119e8) }}, {{ SC_(100.0), SC_(5.0), SC_(7.03986019306167654653386616796116726248616158936088056952477e115) }}, {{ SC_(100.0), SC_(80.0), SC_(8.39287107246490782848985384895907681748152272748337807033319e-12) }}, - (std::numeric_limits::is_specialized && (std::numeric_limits::min_exponent10 > -300)) - ? std::array::type, 3> {{ SC_(-1000.0), SC_(660.0), SC_(5.231804195291135637493087823300645230085362374177628598848978) }} - : std::array::type, 3> {{ SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) }}, + {{ SC_(-1000.0), SC_(700.0), SC_(6.51561979144735818903553852606383312984409361984128221539405e-31) }}, }}; static const std::array::type, 3>, 11> kv_data = {{ {{ SC_(0.5), SC_(0.875), SC_(0.558532231646608646115729767013630967055657943463362504577189) }}, From bf7fb3782b569acad72802389386f274d50ad207 Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Thu, 19 Dec 2024 19:41:36 +0100 Subject: [PATCH 7/7] Remove wrong constexpr and revert bessel_j change --- include/boost/math/tools/precision.hpp | 4 ++-- test/test_bessel_j.hpp | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/boost/math/tools/precision.hpp b/include/boost/math/tools/precision.hpp index 662657732c..94c22b55ed 100644 --- a/include/boost/math/tools/precision.hpp +++ b/include/boost/math/tools/precision.hpp @@ -206,7 +206,7 @@ struct log_limit_noexcept_traits : public log_limit_noexcept_traits_imp -BOOST_MATH_GPU_ENABLED inline constexpr T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) noexcept(detail::log_limit_noexcept_traits::value) +BOOST_MATH_GPU_ENABLED inline T log_max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) noexcept(detail::log_limit_noexcept_traits::value) { #ifndef BOOST_MATH_HAS_NVRTC #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS @@ -223,7 +223,7 @@ BOOST_MATH_GPU_ENABLED inline constexpr T log_max_value(BOOST_MATH_EXPLICIT_TEMP } template -BOOST_MATH_GPU_ENABLED inline constexpr T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) noexcept(detail::log_limit_noexcept_traits::value) +BOOST_MATH_GPU_ENABLED inline T log_min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) noexcept(detail::log_limit_noexcept_traits::value) { #ifndef BOOST_MATH_HAS_NVRTC #ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS diff --git a/test/test_bessel_j.hpp b/test/test_bessel_j.hpp index 6b41b5cd5b..c0b719ad89 100644 --- a/test/test_bessel_j.hpp +++ b/test/test_bessel_j.hpp @@ -281,10 +281,7 @@ void test_bessel(T, const char* name) BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(0), T(2.5)), boost::math::cyl_bessel_j(T(0), T(-2.5))); BOOST_CHECK_EQUAL(boost::math::cyl_bessel_j(T(1), T(2.5)), -boost::math::cyl_bessel_j(T(1), T(-2.5))); #ifndef SYCL_LANGUAGE_VERSION - BOOST_IF_CONSTEXPR (std::numeric_limits::min_exponent10 <= -307) - { - BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_j(364, T(38.5)), SC_(1.793940496519190500748409872348034004417458734118663909894e-309), tolerance); - } + BOOST_CHECK_CLOSE_FRACTION(boost::math::cyl_bessel_j(364, T(38.5)), SC_(1.793940496519190500748409872348034004417458734118663909894e-309), tolerance); #endif // // Special cases at infinity: