]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_autodiff_7.cpp
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)
6 #include "test_autodiff.hpp"
8 BOOST_AUTO_TEST_SUITE(test_autodiff_7
)
10 BOOST_AUTO_TEST_CASE_TEMPLATE(expm1_hpp
, T
, all_float_types
) {
11 using boost::math::differentiation::detail::log
;
12 using boost::multiprecision::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
)) {
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());
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
;
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
)) {
44 BOOST_CHECK_EQUAL(fpclassify(make_fvar
<T
, m
>(0)), FP_ZERO
);
45 BOOST_CHECK_EQUAL(fpclassify(make_fvar
<T
, m
>(10)), FP_NORMAL
);
47 fpclassify(make_fvar
<T
, m
>(std::numeric_limits
<T
>::infinity())),
50 fpclassify(make_fvar
<T
, m
>(std::numeric_limits
<T
>::quiet_NaN())),
52 if (std::numeric_limits
<T
>::has_denorm
!= std::denorm_absent
) {
54 fpclassify(make_fvar
<T
, m
>(std::numeric_limits
<T
>::denorm_min())),
58 BOOST_CHECK(isfinite(make_fvar
<T
, m
>(0)));
59 BOOST_CHECK(isnormal(make_fvar
<T
, m
>((std::numeric_limits
<T
>::min
)())));
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())));
67 BOOST_AUTO_TEST_SUITE_END()