From f684b04fdc70619fa63a6d82e70a4893d0591b93 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 20 Aug 2023 11:22:26 -0400 Subject: [PATCH 1/3] test fix for multiprecision 562 --- test/test_autodiff_7.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/test_autodiff_7.cpp b/test/test_autodiff_7.cpp index c41d806ae4..f8a34bd971 100644 --- a/test/test_autodiff_7.cpp +++ b/test/test_autodiff_7.cpp @@ -53,12 +53,22 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fpclassify_hpp, T, all_float_types) { BOOST_CHECK_EQUAL( fpclassify(make_fvar(std::numeric_limits::denorm_min())), FP_SUBNORMAL); + } else { +#if 0 + // TODO: use when the following gets merged: + // https://github.com/boostorg/multiprecision/pull/562 + BOOST_CHECK(make_fvar(std::numeric_limits::denorm_min() == make_fvar((std::numeric_limits::min)()); +#else + // Temporary fix to work irrespective of the above PR + BOOST_CHECK( + (make_fvar(0) <= make_fvar(std::numeric_limits::denorm_min())) && + (make_fvar(std::numeric_limits::denorm_min()) <= make_fvar((std::numeric_limits::min)())) + ); +#endif } BOOST_CHECK(isfinite(make_fvar(0))); BOOST_CHECK(isnormal(make_fvar((std::numeric_limits::min)()))); - BOOST_CHECK( - !isnormal(make_fvar(std::numeric_limits::denorm_min()))); BOOST_CHECK(isinf(make_fvar(std::numeric_limits::infinity()))); BOOST_CHECK(isnan(make_fvar(std::numeric_limits::quiet_NaN()))); } From 4f191e2752e7d62de3be66af6f6c6ba31c8b7744 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 21 Aug 2023 10:42:15 -0400 Subject: [PATCH 2/3] run test_classify on autodiff type --- test/test_autodiff_7.cpp | 51 ---------------------------------------- test/test_classify.cpp | 15 ++++++++++++ 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/test/test_autodiff_7.cpp b/test/test_autodiff_7.cpp index f8a34bd971..cbf81c6566 100644 --- a/test/test_autodiff_7.cpp +++ b/test/test_autodiff_7.cpp @@ -23,55 +23,4 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(expm1_hpp, T, all_float_types) { } } -BOOST_AUTO_TEST_CASE_TEMPLATE(fpclassify_hpp, T, all_float_types) { - using boost::math::fpclassify; - using boost::math::isfinite; - using boost::math::isinf; - using boost::math::isnan; - using boost::math::isnormal; - using boost::multiprecision::fpclassify; - using boost::multiprecision::isfinite; - using boost::multiprecision::isinf; - using boost::multiprecision::isnan; - using boost::multiprecision::isnormal; - - using test_constants = test_constants_t; - static constexpr auto m = test_constants::order; - test_detail::RandomSample x_sampler{-1000, 1000}; - for (auto i : boost::irange(test_constants::n_samples)) { - std::ignore = i; - - BOOST_CHECK_EQUAL(fpclassify(make_fvar(0)), FP_ZERO); - BOOST_CHECK_EQUAL(fpclassify(make_fvar(10)), FP_NORMAL); - BOOST_CHECK_EQUAL( - fpclassify(make_fvar(std::numeric_limits::infinity())), - FP_INFINITE); - BOOST_CHECK_EQUAL( - fpclassify(make_fvar(std::numeric_limits::quiet_NaN())), - FP_NAN); - if (std::numeric_limits::has_denorm != std::denorm_absent) { - BOOST_CHECK_EQUAL( - fpclassify(make_fvar(std::numeric_limits::denorm_min())), - FP_SUBNORMAL); - } else { -#if 0 - // TODO: use when the following gets merged: - // https://github.com/boostorg/multiprecision/pull/562 - BOOST_CHECK(make_fvar(std::numeric_limits::denorm_min() == make_fvar((std::numeric_limits::min)()); -#else - // Temporary fix to work irrespective of the above PR - BOOST_CHECK( - (make_fvar(0) <= make_fvar(std::numeric_limits::denorm_min())) && - (make_fvar(std::numeric_limits::denorm_min()) <= make_fvar((std::numeric_limits::min)())) - ); -#endif - } - - BOOST_CHECK(isfinite(make_fvar(0))); - BOOST_CHECK(isnormal(make_fvar((std::numeric_limits::min)()))); - BOOST_CHECK(isinf(make_fvar(std::numeric_limits::infinity()))); - BOOST_CHECK(isnan(make_fvar(std::numeric_limits::quiet_NaN()))); - } -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/test/test_classify.cpp b/test/test_classify.cpp index d7a7c4d249..e6f51a0c77 100644 --- a/test/test_classify.cpp +++ b/test/test_classify.cpp @@ -16,6 +16,8 @@ #include #include +#include "test_autodiff.hpp" + #ifdef _MSC_VER #pragma warning(disable: 4127 4146) // conditional expression is constant #endif @@ -256,6 +258,9 @@ void test_classify(T t, const char* type) #endif } + +BOOST_AUTO_TEST_SUITE(test_fpclassify) + BOOST_AUTO_TEST_CASE( test_main ) { BOOST_MATH_CONTROL_FP; @@ -288,6 +293,16 @@ BOOST_AUTO_TEST_CASE( test_main ) test_classify(unsigned(0), "unsigned"); } +BOOST_AUTO_TEST_CASE_TEMPLATE(fpclassify_autodiff, T, all_float_types) { + test_classify(boost::math::differentiation::make_fvar(0), "autodiff float"); + test_classify(boost::math::differentiation::make_fvar(0), "autodiff float"); + test_classify(boost::math::differentiation::make_fvar(0), "autodiff float"); + test_classify(boost::math::differentiation::make_fvar(0), "autodiff float"); + test_classify(boost::math::differentiation::make_fvar(0), "autodiff float"); +} + +BOOST_AUTO_TEST_SUITE_END() + /* Autorun "i:\Boost-sandbox\math_toolkit\libs\math\test\MSVC80\debug\test_classify.exe" Running 1 test case... From 1e0c890f6f70d3a6713c50f894711baf382783b1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 21 Aug 2023 11:31:47 -0400 Subject: [PATCH 3/3] add /bigobj compiler flag for msvc --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7885649f71..691fbebc07 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -983,7 +983,7 @@ test-suite misc : [ run centered_continued_fraction_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : -lquadmath ] ] [ run luroth_expansion_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : -lquadmath ] ] [ run engel_expansion_test.cpp : : : [ requires cxx17_if_constexpr cxx17_std_apply ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : -lquadmath ] ] - [ run test_classify.cpp pch ../../test/build//boost_unit_test_framework ] + [ run test_classify.cpp pch ../../test/build//boost_unit_test_framework : : : msvc:/bigobj ] [ run test_error_handling.cpp ../../test/build//boost_unit_test_framework ] [ run legendre_stieltjes_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx11_auto_declarations cxx11_range_based_for ] [ check-target-builds ../config//has_float128 "GCC libquadmath and __float128 support" : -lquadmath ] ] [ run test_minima.cpp pch ../../test/build//boost_unit_test_framework ]