diff --git a/boost-math b/boost-math index db2a7cbb44a..f395de082ec 160000 --- a/boost-math +++ b/boost-math @@ -1 +1 @@ -Subproject commit db2a7cbb44a84c4c9cba62232c07f18b22bd965d +Subproject commit f395de082eca6ee993a15f2bdb90277eda518295 diff --git a/docs/cgmanifest.json b/docs/cgmanifest.json index 81d35d6dd53..a7d932b2729 100644 --- a/docs/cgmanifest.json +++ b/docs/cgmanifest.json @@ -6,7 +6,7 @@ "type": "git", "git": { "repositoryUrl": "https://github.com/boostorg/math", - "commitHash": "db2a7cbb44a84c4c9cba62232c07f18b22bd965d" + "commitHash": "f395de082eca6ee993a15f2bdb90277eda518295" } } }, diff --git a/tests/std/tests/LWG3234_math_special_overloads/test.cpp b/tests/std/tests/LWG3234_math_special_overloads/test.cpp index 8975a1e2a2f..8594c3cf11e 100644 --- a/tests/std/tests/LWG3234_math_special_overloads/test.cpp +++ b/tests/std/tests/LWG3234_math_special_overloads/test.cpp @@ -5,6 +5,7 @@ #include #include #include +#include using namespace std; @@ -102,8 +103,24 @@ Ambiguous sph_neumann(unsigned int, Ambiguous) { return Ambiguous{}; } -bool expect_epsilons(double expected, double calculated, unsigned int multiple) { - return abs((calculated - expected) / expected) <= multiple * numeric_limits::epsilon(); +template +bool isclose(Float f, Float g, const int ulps = 1) { + if (f == g) { + return true; + } + + if (f > g) { + swap(f, g); + } + // f < g + for (int i = 0; i < ulps; ++i) { + f = nextafter(f, numeric_limits::infinity()); + if (f == g) { + return true; + } + } + + return false; } void test_assoc_laguerre() { @@ -197,7 +214,7 @@ void test_comp_ellint_2() { static_assert(is_same_v); static_assert(is_same_v); static_assert(is_same_v); - assert(comp_ellint_2(0) == acos(-1.0) / 2); + assert(isclose(comp_ellint_2(0), acos(-1.0) / 2)); } void test_comp_ellint_3() { @@ -285,7 +302,7 @@ void test_cyl_bessel_k() { static_assert(is_same_v); static_assert(is_same_v); static_assert(is_same_v); - assert(expect_epsilons(cyl_bessel_k(0.5, 1), acos(-1.0) / 2 * (cyl_bessel_i(-0.5, 1) - cyl_bessel_i(0.5, 1)), 10)); + assert(isclose(cyl_bessel_k(0.5, 1), acos(-1.0) / 2 * (cyl_bessel_i(-0.5, 1) - cyl_bessel_i(0.5, 1)), 15)); } void test_cyl_neumann() { @@ -507,7 +524,7 @@ void test_sph_bessel() { static_assert(is_same_v); static_assert(is_same_v); static_assert(is_same_v); - assert(expect_epsilons(sph_bessel(1, 2), sin(2) / (static_cast(2) * 2) - cos(2) / 2, 2)); + assert(isclose(sph_bessel(1, 2), sin(2) / (2.0 * 2) - cos(2) / 2, 2)); } void test_sph_legendre() { @@ -527,7 +544,7 @@ void test_sph_legendre() { static_assert(is_same_v); const double pi = acos(-1.0); - assert(expect_epsilons(sph_legendre(3, 0, 1), 0.25 * sqrt(7 / pi) * (5 * pow(cos(1), 3) - 3 * cos(1)), 2)); + assert(isclose(sph_legendre(3, 0, 1), 0.25 * sqrt(7 / pi) * (5 * pow(cos(1), 3) - 3 * cos(1)))); } void test_sph_neumann() { @@ -545,7 +562,7 @@ void test_sph_neumann() { static_assert(is_same_v); static_assert(is_same_v); static_assert(is_same_v); - assert(expect_epsilons(sph_neumann(1, 1), -cos(1) - sin(1), 2)); + assert(isclose(sph_neumann(1, 1), -cos(1) - sin(1), 2)); } int main() {