Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / test / concepts / sf_concept_check_basic.cpp
1 //  Copyright John Maddock 2012.
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 //
7 // This tests that cpp_dec_float_50 meets our
8 // conceptual requirements when used with Boost.Math.
9 //
10 #ifdef _MSC_VER
11 #define _SCL_SECURE_NO_WARNINGS
12 #pragma warning(disable : 4800)
13 #pragma warning(disable : 4512)
14 #pragma warning(disable : 4127)
15 #pragma warning(disable : 4512)
16 #pragma warning(disable : 4503) // decorated name length exceeded, name was truncated
17 #endif
18
19 #include <boost/container_hash/hash.hpp>
20 #include <libs/math/test/compile_test/poison.hpp>
21
22 #if !defined(TEST_MPF_50) && !defined(TEST_BACKEND) && !defined(TEST_MPZ) && !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_MPFR_50) && !defined(TEST_MPFR_6) && !defined(TEST_MPFR_15) && !defined(TEST_MPFR_17) && !defined(TEST_MPFR_30) && !defined(TEST_CPP_DEC_FLOAT_NO_ET) && !defined(TEST_LOGGED_ADAPTER) && !defined(TEST_CPP_BIN_FLOAT)
23 #define TEST_MPF_50
24 #define TEST_BACKEND
25 #define TEST_MPZ
26 #define TEST_MPFR_50
27 #define TEST_MPFR_6
28 #define TEST_MPFR_15
29 #define TEST_MPFR_17
30 #define TEST_MPFR_30
31 #define TEST_CPP_DEC_FLOAT
32 #define TEST_CPP_DEC_FLOAT_NO_ET
33 #define TEST_LOGGED_ADAPTER
34 #define TEST_CPP_BIN_FLOAT
35
36 #ifdef _MSC_VER
37 #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
38 #endif
39 #ifdef __GNUC__
40 #pragma warning "CAUTION!!: No backend type specified so testing everything.... this will take some time!!"
41 #endif
42
43 #endif
44
45 #if defined(TEST_MPF_50) || defined(TEST_MPZ)
46 #include <boost/multiprecision/gmp.hpp>
47 #endif
48 #ifdef TEST_BACKEND
49 #include <boost/multiprecision/concepts/mp_number_archetypes.hpp>
50 #endif
51 #if defined(TEST_CPP_DEC_FLOAT) || defined(TEST_CPP_DEC_FLOAT_NO_ET) || defined(TEST_LOGGED_ADAPTER)
52 #include <boost/multiprecision/cpp_dec_float.hpp>
53 #endif
54 #if defined(TEST_CPP_BIN_FLOAT)
55 #include <boost/multiprecision/cpp_bin_float.hpp>
56 #endif
57 #if defined(TEST_MPFR_50) || defined(TEST_MPFR_6) || defined(TEST_MPFR_15) || defined(TEST_MPFR_17) || defined(TEST_MPFR_30)
58 #include <boost/multiprecision/mpfr.hpp>
59 #endif
60 #ifdef TEST_LOGGED_ADAPTER
61 #include <boost/multiprecision/logged_adaptor.hpp>
62 #endif
63
64 #include <boost/math/special_functions.hpp>
65
66 template <class T>
67 void test_extra(T)
68 {
69    T   v1, v2, v3;
70    int i;
71    (boost::math::fpclassify)(v1);
72    (boost::math::isfinite)(v1);
73    (boost::math::isnormal)(v1);
74    (boost::math::isnan)(v1);
75    (boost::math::isinf)(v1);
76    (boost::math::signbit)(v1);
77    (boost::math::copysign)(v1, v2);
78    (boost::math::changesign)(v1);
79    (boost::math::sign)(v1);
80    boost::math::log1p(v1);
81    boost::math::expm1(v1);
82    boost::math::cbrt(v1);
83    boost::math::sqrt1pm1(v1);
84    boost::math::powm1(v1, v2);
85    boost::math::hypot(v1, v2);
86    boost::math::sinc_pi(v1);
87    boost::math::sinhc_pi(v1);
88    boost::math::asinh(v1);
89    boost::math::acosh(v1);
90    boost::math::atanh(v1);
91    boost::math::sin_pi(v1);
92    boost::math::cos_pi(v1);
93    boost::math::trunc(v1);
94    boost::math::itrunc(v1);
95    boost::math::ltrunc(v1);
96    boost::math::round(v1);
97    boost::math::iround(v1);
98    boost::math::lround(v1);
99    boost::math::modf(v1, &v1);
100    boost::math::modf(v1, &i);
101    long l;
102    boost::math::modf(v1, &l);
103 #ifdef BOOST_HAS_LONG_LONG
104    boost::math::lltrunc(v1);
105    boost::math::llround(v1);
106    boost::long_long_type ll;
107    boost::math::modf(v1, &ll);
108 #endif
109    boost::math::pow<2>(v1);
110    boost::math::nextafter(v1, v1);
111    boost::math::float_next(v1);
112    boost::math::float_prior(v1);
113    boost::math::float_distance(v1, v1);
114    // Misc functions that don't fit elsewhere:
115    boost::math::expint(v1);
116    boost::math::expint(i);
117    boost::math::expint(i, v2);
118    boost::math::expint(i, i);
119    boost::math::zeta(v1);
120    boost::math::zeta(i);
121    boost::math::owens_t(v1, v2);
122 }
123
124 void foo()
125 {
126 #ifdef TEST_BACKEND
127    test_extra(boost::multiprecision::concepts::mp_number_float_architype());
128 #endif
129 #ifdef TEST_MPF_50
130    test_extra(boost::multiprecision::mpf_float_50());
131 #endif
132 #ifdef TEST_MPFR_50
133    test_extra(boost::multiprecision::mpfr_float_50());
134 #endif
135 #ifdef TEST_MPFR_6
136    test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<6> >());
137 #endif
138 #ifdef TEST_MPFR_15
139    test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<15> >());
140 #endif
141 #ifdef TEST_MPFR_17
142    test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<17> >());
143 #endif
144 #ifdef TEST_MPFR_30
145    test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<30> >());
146 #endif
147 #ifdef TEST_CPP_DEC_FLOAT
148    test_extra(boost::multiprecision::cpp_dec_float_50());
149 #endif
150 #ifdef TEST_CPP_BIN_FLOAT
151    test_extra(boost::multiprecision::cpp_bin_float_50());
152 #endif
153 #ifdef TEST_CPP_DEC_FLOAT_NO_ET
154    test_extra(boost::multiprecision::number<boost::multiprecision::cpp_dec_float<100>, boost::multiprecision::et_off>());
155 #endif
156 #ifdef TEST_LOGGED_ADAPTER
157    typedef boost::multiprecision::number<boost::multiprecision::logged_adaptor<boost::multiprecision::cpp_dec_float<50> > > num_t;
158    test_extra(num_t());
159 #endif
160 }
161
162 int main()
163 {
164    foo();
165 }