diff --git a/test/compile_test/instantiate.hpp b/test/compile_test/instantiate.hpp index 7e4ea43a4..4ef2da1b9 100644 --- a/test/compile_test/instantiate.hpp +++ b/test/compile_test/instantiate.hpp @@ -13,13 +13,14 @@ #endif template -struct instantiate_runner_result -{ - static bool value; -}; +struct instantiate_runner_result { static bool value; }; + +template bool instantiate_runner_result::value; template -bool instantiate_runner_result::value; +struct instantiate_mixed_runner_result { static bool value; }; + +template bool instantiate_mixed_runner_result::value; #include @@ -33,6 +34,8 @@ bool instantiate_runner_result::value; #include #endif +#include + #ifndef BOOST_MATH_INSTANTIATE_MINIMUM typedef boost::math::policies::policy, boost::math::policies::promote_double > test_policy; @@ -79,12 +82,6 @@ void instantiate(RealType) using namespace boost::math; using namespace boost::math::concepts; - long l { }; - static_cast(l); -#ifdef BOOST_HAS_LONG_LONG - boost::long_long_type ll; - (void)ll; -#endif #ifdef TEST_GROUP_1 #if !defined(BOOST_MATH_NO_DISTRIBUTION_CONCEPT_TESTS) function_requires > >(); @@ -200,10 +197,12 @@ void instantiate(RealType) #endif int i { 1 }; int i_other { }; + // Deal with unused variable warnings: static_cast(i); + auto v1(static_cast(0.51)); - auto v2(static_cast(0.5)); + auto v2(static_cast(0.5)); auto v3(static_cast(0.5)); boost::detail::dummy_constructor dc; boost::output_iterator_archetype oi(dc); @@ -341,14 +340,7 @@ void instantiate(RealType) boost::math::sinhc_pi(v1); boost::math::asinh(v1); { - using std::fabs; - - auto v_special { v1 }; - - while(v_special < RealType(1)) - { - v_special *= 2; - } + RealType v_special { 1.55L }; boost::math::acosh(v_special); } @@ -389,16 +381,7 @@ void instantiate(RealType) boost::math::cyl_neumann_zero(v1, i, i, oi); boost::math::lambert_w0(v1); { - using std::fabs; - - auto v_special { v1 }; - - using std::exp; - - while(v_special > exp(RealType(-1))) - { - v_special /= 2; - } + RealType v_special { 0.234L }; boost::math::lambert_wm1(-v_special); } @@ -459,11 +442,15 @@ void instantiate(RealType) boost::math::modf(v1, &l_other); } -#ifdef BOOST_HAS_LONG_LONG + boost::math::lltrunc(v1); boost::math::llround(v1); - boost::math::modf(v1, &ll); -#endif + { + long long ll_other { }; + + boost::math::modf(v1, &ll_other); + } + boost::math::pow<2>(v1); boost::math::nextafter(v1, v1); boost::math::float_next(v1); @@ -476,19 +463,15 @@ void instantiate(RealType) boost::math::unchecked_bernoulli_b2n(i); boost::math::bernoulli_b2n(i); { - RealType* v1_array = new RealType[i]; + auto v1_array = std::make_unique(i); boost::math::bernoulli_b2n(i, i, &v1_array[0U]); - - delete [] v1_array; } boost::math::tangent_t2n(i); { - RealType* v1_array = new RealType[i]; + auto v1_array = std::make_unique(i); boost::math::tangent_t2n(i, i, &v1_array[0U]); - - delete [] v1_array; } #endif @@ -627,14 +610,7 @@ void instantiate(RealType) boost::math::sinhc_pi(v1 * 1); boost::math::asinh(v1 * 1); { - using std::fabs; - - auto v_special { v1 }; - - while(v_special < RealType(1)) - { - v_special *= 2; - } + RealType v_special { 1.55L }; boost::math::acosh(v_special * 1); } @@ -673,18 +649,7 @@ void instantiate(RealType) boost::math::cyl_neumann_zero(v1 * 1, i, i, oi); boost::math::lambert_w0(v1 * 1); { - using std::fabs; - - auto v_special { v1 }; - - using std::exp; - - while(v_special > exp(RealType(-1))) - { - v_special /= 2; - } - - v_special = -v_special; + RealType v_special { -0.234L }; boost::math::lambert_wm1(v_special * 1); } @@ -718,19 +683,30 @@ void instantiate(RealType) boost::math::round(v1 * 1); boost::math::iround(v1 * 1); boost::math::lround(v1 * 1); - //boost::math::modf(v1 * 1, &v1_other); - //boost::math::modf(v1 * 1, &i_other); - //{ - // long l_other { }; - // - // boost::math::modf(v1 * 1, &l_other); - //} -#ifdef BOOST_HAS_LONG_LONG + { + RealType v1_other { }; + + boost::math::modf(v1 * 1, &v1_other); + } + { + int i_other { }; + + boost::math::modf(v1 * 1, &i_other); + } + { + long l_other { }; + + boost::math::modf(v1 * 1, &l_other); + } + boost::math::lltrunc(v1 * 1); boost::math::llround(v1 * 1); - //boost::long_long_type ll; - //boost::math::modf(v1 * 1, &ll); -#endif + { + long long ll_other { }; + + boost::math::modf(v1 * 1, &ll_other); + } + boost::math::pow<2>(v1 * 1); boost::math::nextafter(v1 * 1, v1 + 0); boost::math::float_next(v1 * 1); @@ -860,14 +836,7 @@ void instantiate(RealType) boost::math::sinhc_pi(v1, pol); boost::math::asinh(v1, pol); { - using std::fabs; - - auto v_special { v1 }; - - while(v_special < RealType(1)) - { - v_special *= 2; - } + RealType v_special { 1.55L }; boost::math::acosh(v_special, pol); } @@ -904,18 +873,7 @@ void instantiate(RealType) boost::math::cyl_neumann_zero(v1, i, i, oi, pol); boost::math::lambert_w0(v1, pol); { - using std::fabs; - - auto v_special { v1 }; - - using std::exp; - - while(v_special > exp(RealType(-1))) - { - v_special /= 2; - } - - v_special = -v_special; + RealType v_special { -0.234L }; boost::math::lambert_wm1(v_special, pol); } @@ -987,9 +945,9 @@ void instantiate(RealType) iround(v1, pol); lround(v1, pol); { - RealType v1_to_get { v1 }; + RealType v1_other { }; - modf(v1, &v1_to_get, pol); + modf(v1, &v1_other, pol); } modf(v1, &i_other, pol); { @@ -997,13 +955,17 @@ void instantiate(RealType) modf(v1, &l_other, pol); } -#ifdef BOOST_HAS_LONG_LONG + using boost::math::lltrunc; using boost::math::llround; lltrunc(v1, pol); llround(v1, pol); - modf(v1, &ll, pol); -#endif + { + long long ll_other { }; + + modf(v1, &ll_other, pol); + } + boost::math::pow<2>(v1, pol); boost::math::nextafter(v1, v1, pol); boost::math::float_next(v1, pol); @@ -1013,20 +975,16 @@ void instantiate(RealType) boost::math::bernoulli_b2n(i, pol); { - RealType* v1_array = new RealType[i]; + auto v1_array = std::make_unique(i); boost::math::bernoulli_b2n(i, i, &v1_array[0U], pol); - - delete [] v1_array; } boost::math::tangent_t2n(i, pol); { - RealType* v1_array = new RealType[i]; + auto v1_array = std::make_unique(i); boost::math::tangent_t2n(i, i, &v1_array[0U], pol); - - delete [] v1_array; } #endif #ifdef TEST_GROUP_9 @@ -1162,14 +1120,7 @@ void instantiate(RealType) test::sinhc_pi(v1); test::asinh(v1); { - using std::fabs; - - auto v_special { v1 }; - - while(v_special < RealType(1)) - { - v_special *= 2; - } + RealType v_special { 1.55L }; test::acosh(v_special); } @@ -1206,18 +1157,7 @@ void instantiate(RealType) test::cyl_neumann_zero(v1, i, i, oi); test::lambert_w0(v1); { - using std::fabs; - - auto v_special { v1 }; - - using std::exp; - - while(v_special > exp(RealType(-1))) - { - v_special /= 2; - } - - v_special = -v_special; + RealType v_special { -0.234L }; test::lambert_wm1(v_special); } @@ -1268,9 +1208,9 @@ void instantiate(RealType) test::iround(v1); test::lround(v1); { - RealType v1_to_get { v1 }; + RealType v1_other { }; - test::modf(v1, &v1_to_get); + test::modf(v1, &v1_other); } test::modf(v1, &i_other); { @@ -1278,11 +1218,15 @@ void instantiate(RealType) test::modf(v1, &l_other); } -#ifdef BOOST_HAS_LONG_LONG + test::lltrunc(v1); test::llround(v1); - test::modf(v1, &ll); -#endif + { + long long ll_other { }; + + test::modf(v1, &ll_other); + } + test::pow<2>(v1); test::nextafter(v1, v1); test::float_next(v1); @@ -1298,25 +1242,27 @@ void instantiate(RealType) template void instantiate_mixed(RealType) { + instantiate_mixed_runner_result::value = false; + using namespace boost; using namespace boost::math; #ifndef BOOST_MATH_INSTANTIATE_MINIMUM int i = 1; - (void)i; + static_cast(i); long l = 1; - (void)l; + static_cast(l); short s = 1; - (void)s; + static_cast(s); float fr = 0.5F; - (void)fr; + static_cast(fr); double dr = 0.5; - (void)dr; + static_cast(dr); #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS long double lr = 0.5L; - (void)lr; + static_cast(lr); #else - double lr = 0.5L; - (void)lr; + double lr = static_cast(0.5L); + static_cast(lr); #endif #ifdef TEST_GROUP_10 boost::math::tgamma(i); @@ -1350,7 +1296,11 @@ void instantiate_mixed(RealType) boost::math::gamma_q_inva(i, lr); boost::math::erf(i); boost::math::erfc(i); - boost::math::erf_inv(i); + { + int i_zero { 0 }; + + boost::math::erf_inv(i_zero); + } boost::math::erfc_inv(i); boost::math::beta(i, s); boost::math::beta(fr, lr); @@ -1368,9 +1318,19 @@ void instantiate_mixed(RealType) boost::math::ibetac_inv(fr, dr, lr); boost::math::ibeta_inva(l, i, s); boost::math::ibeta_inva(fr, dr, lr); - boost::math::ibetac_inva(l, i, s); + { + int i_zero { 0 }; + short s_zero { 0 }; + + boost::math::ibetac_inva(l, i_zero, s_zero); + } boost::math::ibetac_inva(fr, dr, lr); - boost::math::ibeta_invb(l, i, s); + { + int i_zero { 0 }; + short s_zero { 0 }; + + boost::math::ibeta_invb(l, i_zero, s_zero); + } boost::math::ibeta_invb(fr, dr, lr); boost::math::ibetac_invb(l, i, s); boost::math::ibetac_invb(fr, dr, lr); @@ -1391,7 +1351,11 @@ void instantiate_mixed(RealType) boost::math::powm1(fr, lr); //boost::math::legendre_p(1, i); boost::math::legendre_p(1, 0, s); - boost::math::legendre_q(1, i); + { + int i_zero { 0 }; + + boost::math::legendre_q(1, i_zero); + } boost::math::laguerre(1, i); boost::math::laguerre(2, 1, i); boost::math::laguerre(2u, 1u, s); @@ -1401,22 +1365,44 @@ void instantiate_mixed(RealType) boost::math::chebyshev_t_prime(1, i); boost::math::spherical_harmonic_r(2, 1, s, i); boost::math::spherical_harmonic_i(2, 1, fr, lr); - boost::math::ellint_1(i); + { + int i_zero { 0 }; + + boost::math::ellint_1(i_zero); + } boost::math::ellint_1(i, s); boost::math::ellint_1(fr, lr); boost::math::ellint_2(i); boost::math::ellint_2(i, l); boost::math::ellint_2(fr, lr); - boost::math::ellint_3(i, l); + { + int i_zero { 0 }; + long l_zero { 0 }; + + boost::math::ellint_3(i_zero, l_zero); + } boost::math::ellint_3(fr, lr); - boost::math::ellint_3(s, l, i); + { + int i_zero { 0 }; + long l_zero { 0 }; + + boost::math::ellint_3(s, l_zero, i_zero); + } boost::math::ellint_3(fr, dr, lr); - boost::math::ellint_d(i); + { + int i_zero { 0 }; + + boost::math::ellint_d(i_zero); + } boost::math::ellint_d(i, l); boost::math::ellint_d(fr, lr); boost::math::jacobi_zeta(i, l); boost::math::jacobi_zeta(fr, lr); - boost::math::heuman_lambda(i, l); + { + int i_zero { 0 }; + + boost::math::heuman_lambda(i_zero, l); + } boost::math::heuman_lambda(fr, lr); boost::math::ellint_rc(i, s); boost::math::ellint_rc(fr, lr); @@ -1458,7 +1444,11 @@ void instantiate_mixed(RealType) boost::math::sinhc_pi(i); boost::math::asinh(s); boost::math::acosh(l); - boost::math::atanh(l); + { + long l_zero { 0 }; + + boost::math::atanh(l_zero); + } boost::math::sin_pi(s); boost::math::cos_pi(s); boost::math::cyl_neumann(fr, dr); @@ -1521,7 +1511,11 @@ void instantiate_mixed(RealType) boost::math::gamma_q_inva(i, lr, pol); boost::math::erf(i, pol); boost::math::erfc(i, pol); - boost::math::erf_inv(i, pol); + { + int i_zero { 0 }; + + boost::math::erf_inv(i_zero, pol); + } boost::math::erfc_inv(i, pol); boost::math::beta(i, s, pol); boost::math::beta(fr, lr, pol); @@ -1539,9 +1533,19 @@ void instantiate_mixed(RealType) boost::math::ibetac_inv(fr, dr, lr, pol); boost::math::ibeta_inva(l, i, s, pol); boost::math::ibeta_inva(fr, dr, lr, pol); - boost::math::ibetac_inva(l, i, s, pol); + { + int i_zero { 0 }; + short s_zero { 0 }; + + boost::math::ibetac_inva(l, i_zero, s_zero, pol); + } boost::math::ibetac_inva(fr, dr, lr, pol); - boost::math::ibeta_invb(l, i, s, pol); + { + int i_zero { 0 }; + short s_zero { 0 }; + + boost::math::ibeta_invb(l, i_zero, s_zero, pol); + } boost::math::ibeta_invb(fr, dr, lr, pol); boost::math::ibetac_invb(l, i, s, pol); boost::math::ibetac_invb(fr, dr, lr, pol); @@ -1557,7 +1561,11 @@ void instantiate_mixed(RealType) boost::math::powm1(fr, lr, pol); //boost::math::legendre_p(1, i, pol); boost::math::legendre_p(1, 0, s, pol); - boost::math::legendre_q(1, i, pol); + { + int i_zero { 0 }; + + boost::math::legendre_q(1, i_zero, pol); + } boost::math::laguerre(1, i, pol); boost::math::laguerre(2, 1, i, pol); boost::math::laguerre(2u, 1u, s, pol); @@ -1567,22 +1575,44 @@ void instantiate_mixed(RealType) boost::math::chebyshev_t_prime(1, i, pol); boost::math::spherical_harmonic_r(2, 1, s, i, pol); boost::math::spherical_harmonic_i(2, 1, fr, lr, pol); - boost::math::ellint_1(i, pol); + { + int i_zero { 0 }; + + boost::math::ellint_1(i_zero, pol); + } boost::math::ellint_1(i, s, pol); boost::math::ellint_1(fr, lr, pol); boost::math::ellint_2(i, pol); boost::math::ellint_2(i, l, pol); boost::math::ellint_2(fr, lr, pol); - boost::math::ellint_3(i, l, pol); + { + int i_zero { 0 }; + long l_zero { 0 }; + + boost::math::ellint_3(i_zero, l_zero, pol); + } boost::math::ellint_3(fr, lr, pol); - boost::math::ellint_3(s, l, i, pol); + { + int i_zero { 0 }; + long l_zero { 0 }; + + boost::math::ellint_3(s, l_zero, i_zero, pol); + } boost::math::ellint_3(fr, dr, lr, pol); - boost::math::ellint_d(i, pol); + { + int i_zero { 0 }; + + boost::math::ellint_d(i_zero, pol); + } boost::math::ellint_d(i, l, pol); boost::math::ellint_d(fr, lr, pol); boost::math::jacobi_zeta(i, l, pol); boost::math::jacobi_zeta(fr, lr, pol); - boost::math::heuman_lambda(i, l, pol); + { + int i_zero { 0 }; + + boost::math::heuman_lambda(i_zero, l, pol); + } boost::math::heuman_lambda(fr, lr, pol); boost::math::ellint_rc(i, s, pol); boost::math::ellint_rc(fr, lr, pol); @@ -1624,7 +1654,11 @@ void instantiate_mixed(RealType) boost::math::sinhc_pi(i, pol); boost::math::asinh(s, pol); boost::math::acosh(l, pol); - boost::math::atanh(l, pol); + { + long l_zero { 0 }; + + boost::math::atanh(l_zero, pol); + } boost::math::sin_pi(s, pol); boost::math::cos_pi(s, pol); boost::math::cyl_neumann(fr, dr, pol); @@ -1654,7 +1688,11 @@ void instantiate_mixed(RealType) boost::math::owens_t(fr, dr, pol); boost::math::owens_t(i, s, pol); boost::math::lambert_w0(i, pol); - boost::math::lambert_wm1(i, pol); + { + int i_zero { 0 }; + + boost::math::lambert_wm1(i_zero, pol); + } boost::math::lambert_w0_prime(i, pol); #endif #ifdef TEST_GROUP_11 @@ -1689,7 +1727,11 @@ void instantiate_mixed(RealType) test::gamma_q_inva(i, lr); test::erf(i); test::erfc(i); - test::erf_inv(i); + { + int i_zero { 0 }; + + test::erf_inv(i_zero); + } test::erfc_inv(i); test::beta(i, s); test::beta(fr, lr); @@ -1707,9 +1749,19 @@ void instantiate_mixed(RealType) test::ibetac_inv(fr, dr, lr); test::ibeta_inva(l, i, s); test::ibeta_inva(fr, dr, lr); - test::ibetac_inva(l, i, s); + { + int i_zero { 0 }; + short s_zero { 0 }; + + test::ibetac_inva(l, i_zero, s_zero); + } test::ibetac_inva(fr, dr, lr); - test::ibeta_invb(l, i, s); + { + int i_zero { 0 }; + short s_zero { 0 }; + + test::ibeta_invb(l, i_zero, s_zero); + } test::ibeta_invb(fr, dr, lr); test::ibetac_invb(l, i, s); test::ibetac_invb(fr, dr, lr); @@ -1730,7 +1782,11 @@ void instantiate_mixed(RealType) test::powm1(fr, lr); //test::legendre_p(1, i); test::legendre_p(1, 0, s); - test::legendre_q(1, i); + { + int i_zero { 0 }; + + test::legendre_q(1, i_zero); + } test::laguerre(1, i); test::laguerre(2, 1, i); test::laguerre(2u, 1u, s); @@ -1740,22 +1796,44 @@ void instantiate_mixed(RealType) test::chebyshev_t_prime(1, s); test::spherical_harmonic_r(2, 1, s, i); test::spherical_harmonic_i(2, 1, fr, lr); - test::ellint_1(i); + { + int i_zero { 0 }; + + test::ellint_1(i_zero); + } test::ellint_1(i, s); test::ellint_1(fr, lr); test::ellint_2(i); test::ellint_2(i, l); test::ellint_2(fr, lr); - test::ellint_3(i, l); + { + int i_zero { 0 }; + long l_zero { 0 }; + + test::ellint_3(i_zero, l_zero); + } test::ellint_3(fr, lr); - test::ellint_3(s, l, i); + { + int i_zero { 0 }; + long l_zero { 0 }; + + test::ellint_3(s, l_zero, i_zero); + } test::ellint_3(fr, dr, lr); - test::ellint_d(i); + { + int i_zero { 0 }; + + test::ellint_d(i_zero); + } test::ellint_d(i, l); test::ellint_d(fr, lr); test::jacobi_zeta(i, l); test::jacobi_zeta(fr, lr); - test::heuman_lambda(i, l); + { + int i_zero { 0 }; + + test::heuman_lambda(i_zero, l); + } test::heuman_lambda(fr, lr); test::ellint_rc(i, s); test::ellint_rc(fr, lr); @@ -1773,7 +1851,11 @@ void instantiate_mixed(RealType) test::sinhc_pi(i); test::asinh(s); test::acosh(l); - test::atanh(l); + { + long l_zero { 0 }; + + test::atanh(l_zero); + } test::sin_pi(s); test::cos_pi(s); test::cyl_neumann(fr, dr); @@ -1807,10 +1889,16 @@ void instantiate_mixed(RealType) test::owens_t(fr, dr); test::owens_t(i, s); boost::math::lambert_w0(i); - boost::math::lambert_wm1(i); + { + int i_zero { 0 }; + + boost::math::lambert_wm1(i_zero); + } boost::math::lambert_w0_prime(i); #endif #endif + + instantiate_mixed_runner_result::value = true; } diff --git a/test/test_instantiate3.cpp b/test/test_instantiate3.cpp index 8f753e859..6879da46b 100644 --- a/test/test_instantiate3.cpp +++ b/test/test_instantiate3.cpp @@ -26,13 +26,23 @@ namespace local BOOST_TEST(result_instantiate_and_run_is_ok); } + + auto instantiate_mixed_runner() -> void + { + instantiate_mixed(static_cast(1.23L)); + + const bool result_instantiate_mixed_and_run_is_ok = instantiate_mixed_runner_result::value; + + BOOST_TEST(result_instantiate_mixed_and_run_is_ok); + } } // namespace local auto main() -> int { - static_assert(std::numeric_limits::digits == 53, "Error: rong digits in local::float64_t"); + static_assert((std::numeric_limits::digits == 53), "Error: wrong digits in local::detail::float64_t"); local::instantiate_runner(); + local::instantiate_mixed_runner(); return boost::report_errors(); }