diff --git a/include/boost/math/differentiation/autodiff.hpp b/include/boost/math/differentiation/autodiff.hpp index 9b973bcda..e98eecab6 100644 --- a/include/boost/math/differentiation/autodiff.hpp +++ b/include/boost/math/differentiation/autodiff.hpp @@ -7,7 +7,6 @@ #define BOOST_MATH_DIFFERENTIATION_AUTODIFF_HPP #include -#include #include #include #include @@ -142,8 +141,6 @@ class fvar { template fvar(RealType2 const& ca); // Supports any RealType2 for which static_cast(ca) compiles. - explicit fvar(char const* ca); // Converts a char const* string to RealType by boost::lexical_cast - // r = cr | RealType& | Assignment operator. fvar& operator=(fvar const&) = default; @@ -684,10 +681,6 @@ template template fvar::fvar(RealType2 const& ca) : v{{static_cast(ca)}} {} -template -fvar::fvar(char const* ca_str) - : v{{static_cast(boost::lexical_cast>(ca_str))}} {} - /* template fvar& fvar::operator=(root_type const& ca) diff --git a/test/test_autodiff_4.cpp b/test/test_autodiff_4.cpp index 016c8b077..842d7e471 100644 --- a/test/test_autodiff_4.cpp +++ b/test/test_autodiff_4.cpp @@ -83,64 +83,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(multiprecision, T, multiprecision_float_types) { } #endif -BOOST_AUTO_TEST_CASE_TEMPLATE(airy_hpp, T, all_float_types) { - using boost::multiprecision::min; - using std::min; - - using test_constants = test_constants_t; - static constexpr auto m = test_constants::order; - - test_detail::RandomSample x_sampler(-100, 100); - for (auto i : boost::irange(test_constants::n_samples)) { - const auto &x = x_sampler.next(); - { - auto autodiff_v = boost::math::airy_ai(make_fvar(x)); - auto anchor_v = boost::math::airy_ai(x); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } - - { - auto autodiff_v = boost::math::airy_ai_prime(make_fvar(x)); - auto anchor_v = boost::math::airy_ai_prime(x); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } - - { - auto x_ = (min)(x, T(26)); - auto autodiff_v = boost::math::airy_bi(make_fvar(x_)); - auto anchor_v = boost::math::airy_bi(x_); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } - - { - auto x_ = ((min))(x, T(26)); - auto autodiff_v = boost::math::airy_bi_prime(make_fvar(x_)); - auto anchor_v = boost::math::airy_bi_prime(x_); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } - - if (i > 0) { - { - auto autodiff_v = boost::math::airy_ai_zero>(i); - auto anchor_v = boost::math::airy_ai_zero(i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } - - { - auto autodiff_v = boost::math::airy_bi_zero>(i); - auto anchor_v = boost::math::airy_bi_zero(i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } - } - } -} - BOOST_AUTO_TEST_CASE_TEMPLATE(acosh_hpp, T, all_float_types) { using boost::math::acosh; using test_constants = test_constants_t; @@ -249,306 +191,4 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(bernoulli_hpp, T, all_float_types) { } } -// TODO(kbhat): Something in here is very slow with boost::multiprecision -BOOST_AUTO_TEST_CASE_TEMPLATE(bessel_hpp, T, bin_float_types) { - using boost::math::fpclassify; - using boost::math::nextafter; - using boost::math::signbit; - using boost::math::tools::max; - using boost::multiprecision::fabs; - using boost::multiprecision::fpclassify; - using boost::multiprecision::signbit; - using detail::fabs; - using std::fabs; - using std::max; - using std::nextafter; - - using test_constants = test_constants_t; - static constexpr auto m = test_constants::order; - test_detail::RandomSample v_sampler{-20, 20}; - test_detail::RandomSample x_sampler{ - -boost::math::tools::log_max_value() + 1, - boost::math::tools::log_max_value() - 1}; - for (auto i : boost::irange(test_constants::n_samples)) { - auto v = v_sampler.next(); - auto x = x_sampler.next(); - v = ((fpclassify(v) == FP_ZERO) ? 1 : -1) * - (max)(v, (nextafter)(T(0), ((std::numeric_limits::max))())); - if (signbit(x)) { - v = static_cast(boost::math::itrunc(v)); - } - - try { - auto autodiff_v = - boost::math::cyl_bessel_i(make_fvar(v), make_fvar(x)); - auto anchor_v = boost::math::cyl_bessel_i(v, x); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - boost::math::cyl_bessel_i(make_fvar(v), make_fvar(x)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_i(v, x), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x << std::endl; - std::rethrow_exception(std::current_exception()); - } - - { - auto x_j = fabs(x) + 1; - try { - auto autodiff_v = - boost::math::cyl_bessel_j(make_fvar(v), make_fvar(x_j)); - auto anchor_v = boost::math::cyl_bessel_j(v, x_j); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - boost::math::cyl_bessel_j(make_fvar(v), make_fvar(x_j)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_j(v, x_j), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x_j << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - try { - auto autodiff_v = - boost::math::cyl_bessel_j_zero(make_fvar(v), i + 1); - auto anchor_v = boost::math::cyl_bessel_j_zero(v, i + 1); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - boost::math::cyl_bessel_j_zero(make_fvar(v), i + 1), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_j_zero(v, i + 1), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " i: " << (i + 1) << std::endl; - std::rethrow_exception(std::current_exception()); - } - - { - auto x_k = fabs(x) + 1; - try { - auto autodiff_v = - boost::math::cyl_bessel_k(make_fvar(v), make_fvar(x_k)); - auto anchor_v = boost::math::cyl_bessel_k(v, x_k); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - boost::math::cyl_bessel_k(make_fvar(v), make_fvar(x_k)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_k(v, x_k), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x_k << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - { - auto x_neumann = fabs(x) + 1; - try { - auto autodiff_v = boost::math::cyl_neumann(make_fvar(v), - make_fvar(x_neumann)); - auto anchor_v = boost::math::cyl_neumann(v, x_neumann); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::cyl_neumann(make_fvar(v), - make_fvar(x_neumann)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_neumann(v, x_neumann), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x_neumann << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - { - try { - auto autodiff_v = - boost::math::cyl_neumann_zero(make_fvar(v), i + 1); - auto anchor_v = boost::math::cyl_neumann_zero(v, i + 1); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (std::overflow_error &) { - BOOST_CHECK_THROW( - boost::math::cyl_neumann_zero((make_fvar)(v), i + 1), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_neumann_zero(v, i + 1), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " i: " << (i + 1) << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - { - auto i_ = static_cast(i); - try { - auto autodiff_v = boost::math::sph_bessel>( - i_, make_fvar(fabs(v))); - auto anchor_v = boost::math::sph_bessel(i_, fabs(v)); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - (boost::math::sph_bessel< - autodiff_fvar>)(i_, (make_fvar)(fabs(v))), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::sph_bessel(i_, fabs(v)), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: i: " << i_ << " v: " << (fabs(v)) << std::endl; - std::rethrow_exception(std::current_exception()); - } - - { - auto v_ = - (max)(T(fabs(v)), - nextafter(T(fabs(v)), 2 * (std::numeric_limits::min)())); - try { - auto autodiff_v = boost::math::sph_neumann>( - i_, make_fvar(v_)); - auto anchor_v = boost::math::sph_neumann(i_, v_); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(((boost::math::sph_neumann>( - i_, make_fvar(v_)))), - boost::wrapexcept); - BOOST_CHECK_THROW(((boost::math::sph_neumann(i_, v_))), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: i: " << i_ << " v: " << v_ << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - try { - auto autodiff_v = boost::math::cyl_bessel_i_prime(make_fvar(v), - make_fvar(x)); - auto anchor_v = boost::math::cyl_bessel_i_prime(v, x); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::cyl_bessel_i_prime((make_fvar)(v), - (make_fvar)(x)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_i_prime(v, x), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x << std::endl; - std::rethrow_exception(std::current_exception()); - } - - { - auto x_j = fabs(x) + 1; - try { - auto autodiff_v = boost::math::cyl_bessel_j_prime( - make_fvar(v), make_fvar(x_j)); - auto anchor_v = boost::math::cyl_bessel_j_prime(v, x_j); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::cyl_bessel_j_prime( - (make_fvar)(v), (make_fvar)(x_j)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_j_prime(v, x_j), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x_k: " << x_j << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - { - auto x_k = fabs(x) + 1; - try { - auto autodiff_v = boost::math::cyl_bessel_k_prime( - make_fvar(v), make_fvar(x_k)); - auto anchor_v = boost::math::cyl_bessel_k_prime(v, x_k); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::cyl_bessel_k_prime( - (make_fvar)(v), (make_fvar)(x_k)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_bessel_k_prime(v, x_k), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x_k << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - { - auto x_neumann = fabs(x) + 1; - try { - auto autodiff_v = boost::math::cyl_neumann_prime( - make_fvar(v), make_fvar(x_neumann)); - auto anchor_v = boost::math::cyl_neumann_prime(v, x_neumann); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - boost::math::cyl_neumann_prime((make_fvar)(v), - (make_fvar)(x_neumann)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::cyl_neumann_prime(v, x_neumann), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: v: " << v << " x: " << x_neumann << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - - try { - auto autodiff_v = boost::math::sph_bessel_prime>( - i_, make_fvar(fabs(v) + 1)); - auto anchor_v = boost::math::sph_bessel_prime(i_, fabs(v) + 1); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - (boost::math::sph_neumann< - autodiff_fvar>)(i_, (make_fvar)(fabs(v) + 1)), - boost::wrapexcept); - BOOST_CHECK_THROW((boost::math::sph_neumann)(i_, fabs(v) + 1), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: i: " << i_ << " v: " << (fabs(v) + 1) - << std::endl; - std::rethrow_exception(std::current_exception()); - } - - try { - auto autodiff_v = boost::math::sph_neumann_prime>( - i_, make_fvar(fabs(v) + 1)); - auto anchor_v = boost::math::sph_neumann_prime(i_, fabs(v) + 1); - BOOST_WARN_CLOSE(autodiff_v.derivative(0u), anchor_v, - 1e4 * test_constants::pct_epsilon()); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW( - (boost::math::sph_neumann_prime< - autodiff_fvar>)(i_, (make_fvar)(fabs(v) + 1)), - boost::wrapexcept); - BOOST_CHECK_THROW((boost::math::sph_neumann_prime)(i_, fabs(v) + 1), - boost::wrapexcept); - } catch (...) { - std::cout << "Inputs: i: " << i << " v: " << (fabs(v) + 1) << std::endl; - std::rethrow_exception(std::current_exception()); - } - } - } -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/test/test_autodiff_5.cpp b/test/test_autodiff_5.cpp index 0e8eecccc..614630cac 100644 --- a/test/test_autodiff_5.cpp +++ b/test/test_autodiff_5.cpp @@ -7,257 +7,6 @@ BOOST_AUTO_TEST_SUITE(test_autodiff_5) -BOOST_AUTO_TEST_CASE_TEMPLATE(beta_hpp, T, bin_float_types) { - using bmp::fabs; - using detail::fabs; - using std::fabs; - - using test_constants = test_constants_t; - static constexpr auto m = test_constants::order; - test_detail::RandomSample a_sampler{-2000, 2000}; - test_detail::RandomSample b_sampler{-2000, 2000}; - test_detail::RandomSample z_sampler{0, 1}; - for (auto i : boost::irange(test_constants::n_samples)) { - std::ignore = i; - auto a = a_sampler.next(); - auto b = b_sampler.next(); - auto z = z_sampler.next(); - { - auto a_ = fabs(a) + 1; - auto b_ = fabs(b) + 1; - try { - auto autodiff_v = boost::math::beta( - make_fvar(a_), make_fvar(b_), make_fvar(z)); - auto anchor_v = boost::math::beta(a_, b_, z); - BOOST_CHECK(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::beta(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::beta(a_, b_, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::beta(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::beta(a_, b_, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = boost::math::betac( - make_fvar(a_), make_fvar(b_), make_fvar(z)); - auto anchor_v = boost::math::betac(a_, b_, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::betac(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::betac(a_, b_, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::betac(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::betac(a_, b_, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = - boost::math::ibeta(make_fvar(a_ - 1), make_fvar(b_ - 1), - make_fvar(z)); - auto anchor_v = boost::math::ibeta(a_ - 1, b_ - 1, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibeta(make_fvar(a_ - 1), - make_fvar(b_ - 1), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta(a_ - 1, b_ - 1, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibeta(make_fvar(a_ - 1), - make_fvar(b_ - 1), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta(a_ - 1, b_ - 1, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = - boost::math::ibetac(make_fvar(a_ - 1), - make_fvar(b_ - 1), make_fvar(z)); - auto anchor_v = boost::math::ibetac(a_ - 1, b_ - 1, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibetac(make_fvar(a_ - 1), - make_fvar(b_ - 1), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibetac(a_ - 1, b_ - 1, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = boost::math::ibeta_derivative( - make_fvar(a_), make_fvar(b_), make_fvar(z)); - auto anchor_v = boost::math::ibeta_derivative(a_, b_, z); - BOOST_CHECK(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_derivative(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_derivative(a_, b_, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_derivative(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_derivative(a_, b_, z), - boost::wrapexcept); - } - - { - try { - auto autodiff_v = boost::math::ibeta_inv( - make_fvar(a_), make_fvar(b_), make_fvar(z)); - auto anchor_v = boost::math::ibeta_inv(a_, b_, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_derivative(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_derivative(a_, b_, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_derivative(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_derivative(a_, b_, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = boost::math::ibetac_inv>( - make_fvar(a_), make_fvar(b_), make_fvar(z)); - auto anchor_v = boost::math::ibetac_inv(a_, b_, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_derivative(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_derivative(a_, b_, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_derivative(make_fvar(a_), - make_fvar(b_), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_derivative(a_, b_, z), - boost::wrapexcept); - } - } - { - auto b_norm = b_sampler.normalize(fabs(b)); - try { - auto autodiff_v = boost::math::ibeta_inva( - make_fvar(a_), make_fvar(b_norm), make_fvar(z)); - auto anchor_v = boost::math::ibeta_inva(a_, b_norm, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_inva(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_inva(a_, b_norm, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_inva(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_inva(a_, b_norm, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = boost::math::ibetac_inva( - make_fvar(a_), make_fvar(b_norm), make_fvar(z)); - auto anchor_v = boost::math::ibetac_inva(a_, b_norm, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibetac_inva(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibetac_inva(a_, b_norm, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibetac_inva(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibetac_inva(a_, b_norm, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = boost::math::ibeta_invb( - make_fvar(a_), make_fvar(b_norm), make_fvar(z)); - auto anchor_v = boost::math::ibeta_invb(a_, b_norm, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_invb(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_invb(a_, b_norm, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibeta_invb(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibeta_invb(a_, b_norm, z), - boost::wrapexcept); - } - - try { - auto autodiff_v = boost::math::ibetac_invb( - make_fvar(a_), make_fvar(b_norm), make_fvar(z)); - auto anchor_v = boost::math::ibetac_invb(a_, b_norm, z); - BOOST_TEST_WARN(isNearZero(autodiff_v.derivative(0u) - anchor_v)); - } catch (const boost::math::evaluation_error &) { - BOOST_CHECK_THROW(boost::math::ibetac_invb(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibetac_invb(a_, b_norm, z), - boost::wrapexcept); - } catch (const std::overflow_error &) { - BOOST_CHECK_THROW(boost::math::ibetac_invb(make_fvar(a_), - make_fvar(b_norm), - make_fvar(z)), - boost::wrapexcept); - BOOST_CHECK_THROW(boost::math::ibetac_invb(a_, b_norm, z), - boost::wrapexcept); - } - } - } - } -} - BOOST_AUTO_TEST_CASE_TEMPLATE(binomial_hpp, T, all_float_types) { using boost::multiprecision::min; using std::fabs; diff --git a/test/test_autodiff_7.cpp b/test/test_autodiff_7.cpp index 1226f2df4..c41d806ae 100644 --- a/test/test_autodiff_7.cpp +++ b/test/test_autodiff_7.cpp @@ -23,60 +23,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(expm1_hpp, T, all_float_types) { } } -BOOST_AUTO_TEST_CASE_TEMPLATE(factorials_hpp, T, all_float_types) { - using test_constants = test_constants_t; - static constexpr auto m = test_constants::order; - test_detail::RandomSample x_sampler{0, 28}; - for (auto i : - boost::irange(static_cast(test_constants::n_samples))) { - { - auto fact_i = boost::math::factorial(i); - auto autodiff_v = boost::math::factorial>(i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), fact_i, - 50 * test_constants::pct_epsilon()); - } - - { - auto fact_i = boost::math::unchecked_factorial(i); - auto autodiff_v = - boost::math::unchecked_factorial>(i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), fact_i, - 50 * test_constants::pct_epsilon()); - } - - { - auto fact_i = boost::math::unchecked_factorial(i); - auto autodiff_v = - boost::math::unchecked_factorial>(i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), fact_i, - 50 * test_constants::pct_epsilon()); - } - - { - auto fact_i = boost::math::double_factorial(i); - auto autodiff_v = boost::math::double_factorial>(i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), fact_i, - 50 * test_constants::pct_epsilon()); - } - - auto x = x_sampler.next(); - { - auto fact_i = boost::math::rising_factorial(x, static_cast(i)); - auto autodiff_v = make_fvar(fact_i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), fact_i, - 50 * test_constants::pct_epsilon()); - } - - { - auto fact_i = - boost::math::falling_factorial(x, test_constants::n_samples - i); - auto autodiff_v = make_fvar(fact_i); - BOOST_CHECK_CLOSE(autodiff_v.derivative(0u), fact_i, - 50 * test_constants::pct_epsilon()); - } - } -} - BOOST_AUTO_TEST_CASE_TEMPLATE(fpclassify_hpp, T, all_float_types) { using boost::math::fpclassify; using boost::math::isfinite; diff --git a/test/test_autodiff_8.cpp b/test/test_autodiff_8.cpp index 2be13d70a..4afab0878 100644 --- a/test/test_autodiff_8.cpp +++ b/test/test_autodiff_8.cpp @@ -295,7 +295,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(next_hpp, T, all_float_types) { } } -/* BOOST_AUTO_TEST_CASE_TEMPLATE(owens_t_hpp, T, bin_float_types) { BOOST_MATH_STD_USING; using test_constants = test_constants_t; @@ -312,7 +311,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(owens_t_hpp, T, bin_float_types) { BOOST_CHECK(isNearZero(autodiff_v.derivative(0u) - anchor_v)); } } -*/ + BOOST_AUTO_TEST_CASE_TEMPLATE(pow_hpp, T, all_float_types) { using test_constants = test_constants_t; @@ -504,19 +503,4 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(trigamma_hpp, T, all_float_types) { } } -BOOST_AUTO_TEST_CASE_TEMPLATE(zeta_hpp, T, all_float_types) { - using test_constants = test_constants_t; - static constexpr auto m = test_constants::order; - test_detail::RandomSample x_sampler{-30, 30}; - for (auto i : boost::irange(test_constants::n_samples)) { - std::ignore = i; - auto x = x_sampler.next(); - BOOST_WARN( - isNearZero(boost::math::zeta(make_fvar(x)).derivative(0u) - - boost::math::zeta(x))); - BOOST_CHECK_CLOSE(boost::math::zeta(make_fvar(x)).derivative(0u), - boost::math::zeta(x), 50 * test_constants::pct_epsilon()); - } -} - BOOST_AUTO_TEST_SUITE_END()