]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // Copyright Matthew Pulver 2018 - 2019. |
2 | // Distributed under the Boost Software License, Version 1.0. | |
3 | // (See accompanying file LICENSE_1_0.txt or copy at | |
4 | // https://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #include "test_autodiff.hpp" | |
7 | ||
8 | BOOST_AUTO_TEST_SUITE(test_autodiff_7) | |
9 | ||
10 | BOOST_AUTO_TEST_CASE_TEMPLATE(expm1_hpp, T, all_float_types) { | |
11 | using boost::math::differentiation::detail::log; | |
12 | using boost::multiprecision::log; | |
13 | using std::log; | |
14 | using test_constants = test_constants_t<T>; | |
15 | static constexpr auto m = test_constants::order; | |
16 | test_detail::RandomSample<T> x_sampler{-log(T(2000)), log(T(2000))}; | |
17 | for (auto i : boost::irange(test_constants::n_samples)) { | |
18 | std::ignore = i; | |
19 | auto x = x_sampler.next(); | |
20 | BOOST_CHECK_CLOSE(boost::math::expm1(make_fvar<T, m>(x)).derivative(0u), | |
21 | boost::math::expm1(x), | |
22 | 50 * test_constants::pct_epsilon()); | |
23 | } | |
24 | } | |
25 | ||
26 | BOOST_AUTO_TEST_CASE_TEMPLATE(fpclassify_hpp, T, all_float_types) { | |
27 | using boost::math::fpclassify; | |
28 | using boost::math::isfinite; | |
29 | using boost::math::isinf; | |
30 | using boost::math::isnan; | |
31 | using boost::math::isnormal; | |
32 | using boost::multiprecision::fpclassify; | |
33 | using boost::multiprecision::isfinite; | |
34 | using boost::multiprecision::isinf; | |
35 | using boost::multiprecision::isnan; | |
36 | using boost::multiprecision::isnormal; | |
37 | ||
38 | using test_constants = test_constants_t<T>; | |
39 | static constexpr auto m = test_constants::order; | |
40 | test_detail::RandomSample<T> x_sampler{-1000, 1000}; | |
41 | for (auto i : boost::irange(test_constants::n_samples)) { | |
42 | std::ignore = i; | |
43 | ||
44 | BOOST_CHECK_EQUAL(fpclassify(make_fvar<T, m>(0)), FP_ZERO); | |
45 | BOOST_CHECK_EQUAL(fpclassify(make_fvar<T, m>(10)), FP_NORMAL); | |
46 | BOOST_CHECK_EQUAL( | |
47 | fpclassify(make_fvar<T, m>(std::numeric_limits<T>::infinity())), | |
48 | FP_INFINITE); | |
49 | BOOST_CHECK_EQUAL( | |
50 | fpclassify(make_fvar<T, m>(std::numeric_limits<T>::quiet_NaN())), | |
51 | FP_NAN); | |
52 | if (std::numeric_limits<T>::has_denorm != std::denorm_absent) { | |
53 | BOOST_CHECK_EQUAL( | |
54 | fpclassify(make_fvar<T, m>(std::numeric_limits<T>::denorm_min())), | |
55 | FP_SUBNORMAL); | |
56 | } | |
57 | ||
58 | BOOST_CHECK(isfinite(make_fvar<T, m>(0))); | |
59 | BOOST_CHECK(isnormal(make_fvar<T, m>((std::numeric_limits<T>::min)()))); | |
60 | BOOST_CHECK( | |
61 | !isnormal(make_fvar<T, m>(std::numeric_limits<T>::denorm_min()))); | |
62 | BOOST_CHECK(isinf(make_fvar<T, m>(std::numeric_limits<T>::infinity()))); | |
63 | BOOST_CHECK(isnan(make_fvar<T, m>(std::numeric_limits<T>::quiet_NaN()))); | |
64 | } | |
65 | } | |
66 | ||
67 | BOOST_AUTO_TEST_SUITE_END() |