]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | // (C) Copyright Matt Borland 2021. |
2 | // Use, modification and distribution are subject to the | |
3 | // Boost Software License, Version 1.0. (See accompanying file | |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #include <cmath> | |
7 | #include <cfloat> | |
8 | #include <cstdint> | |
9 | #include <limits> | |
10 | #include <type_traits> | |
11 | #include <boost/math/ccmath/copysign.hpp> | |
12 | #include <boost/math/ccmath/isnan.hpp> | |
13 | #include <boost/math/ccmath/isinf.hpp> | |
14 | ||
15 | #ifdef BOOST_HAS_FLOAT128 | |
16 | #include <boost/multiprecision/float128.hpp> | |
17 | #endif | |
18 | ||
19 | #if !defined(BOOST_MATH_NO_CONSTEXPR_DETECTION) && !defined(BOOST_MATH_USING_BUILTIN_CONSTANT_P) | |
20 | template <typename T> | |
21 | constexpr void test() | |
22 | { | |
23 | if constexpr (std::numeric_limits<T>::has_quiet_NaN) | |
24 | { | |
25 | static_assert(boost::math::ccmath::isnan(boost::math::ccmath::copysign(std::numeric_limits<T>::quiet_NaN(), T(1)))); | |
26 | static_assert(boost::math::ccmath::isnan(boost::math::ccmath::copysign(std::numeric_limits<T>::quiet_NaN(), T(-1)))); | |
27 | } | |
28 | ||
29 | static_assert(boost::math::ccmath::copysign(T(1), T(2)) == T(1)); | |
30 | static_assert(boost::math::ccmath::copysign(T(1), T(-2)) == T(-1)); | |
31 | static_assert(boost::math::ccmath::copysign(std::numeric_limits<T>::infinity(), T(2)) == std::numeric_limits<T>::infinity()); | |
32 | static_assert(boost::math::ccmath::copysign(std::numeric_limits<T>::infinity(), T(-2)) == -std::numeric_limits<T>::infinity()); | |
33 | } | |
34 | ||
35 | int main() | |
36 | { | |
37 | test<float>(); | |
38 | test<double>(); | |
39 | ||
40 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
41 | test<long double>(); | |
42 | #endif | |
43 | ||
44 | #ifdef BOOST_HAS_FLOAT128 | |
45 | test<boost::multiprecision::float128>(); | |
46 | #endif | |
47 | ||
48 | return 0; | |
49 | } | |
50 | #else | |
51 | int main() | |
52 | { | |
53 | return 0; | |
54 | } | |
55 | #endif |