]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright John Maddock 2011. |
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. | |
9 | // | |
10 | #ifdef _MSC_VER | |
92f5a8d4 TL |
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 | |
7c673cae FG |
17 | #endif |
18 | ||
92f5a8d4 | 19 | #include <boost/container_hash/hash.hpp> |
7c673cae FG |
20 | #include <libs/math/test/compile_test/poison.hpp> |
21 | ||
92f5a8d4 TL |
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 | |
7c673cae FG |
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/concepts/real_type_concept.hpp> | |
65 | ||
66 | template <class T> | |
67 | void test_extra(T) | |
68 | { | |
69 | T t = 1; | |
92f5a8d4 TL |
70 | t = abs(t); |
71 | t = abs(t * t); | |
7c673cae FG |
72 | |
73 | t = fabs(t); | |
92f5a8d4 | 74 | t = fabs(t * t); |
7c673cae FG |
75 | |
76 | t = sqrt(t); | |
92f5a8d4 | 77 | t = sqrt(t * t); |
7c673cae FG |
78 | |
79 | t = floor(t); | |
92f5a8d4 | 80 | t = floor(t * t); |
7c673cae FG |
81 | |
82 | t = ceil(t); | |
92f5a8d4 | 83 | t = ceil(t * t); |
7c673cae FG |
84 | |
85 | t = trunc(t); | |
92f5a8d4 | 86 | t = trunc(t * t); |
7c673cae FG |
87 | |
88 | t = round(t); | |
92f5a8d4 | 89 | t = round(t * t); |
7c673cae FG |
90 | |
91 | t = exp(t); | |
92f5a8d4 | 92 | t = exp(t * t); |
7c673cae FG |
93 | |
94 | t = log(t); | |
92f5a8d4 | 95 | t = log(t * t); |
7c673cae FG |
96 | |
97 | t = log10(t); | |
92f5a8d4 | 98 | t = log10(t * t); |
7c673cae FG |
99 | |
100 | t = cos(t); | |
92f5a8d4 | 101 | t = cos(t * t); |
7c673cae FG |
102 | |
103 | t = sin(t); | |
92f5a8d4 | 104 | t = sin(t * t); |
7c673cae FG |
105 | |
106 | t = tan(t); | |
92f5a8d4 | 107 | t = tan(t * t); |
7c673cae FG |
108 | |
109 | t = asin(t); | |
92f5a8d4 | 110 | t = asin(t * t); |
7c673cae FG |
111 | |
112 | t = atan(t); | |
92f5a8d4 | 113 | t = atan(t * t); |
7c673cae FG |
114 | |
115 | t = acos(t); | |
92f5a8d4 | 116 | t = acos(t * t); |
7c673cae FG |
117 | |
118 | t = cosh(t); | |
92f5a8d4 | 119 | t = cosh(t * t); |
7c673cae FG |
120 | |
121 | t = sinh(t); | |
92f5a8d4 | 122 | t = sinh(t * t); |
7c673cae FG |
123 | |
124 | t = tanh(t); | |
92f5a8d4 | 125 | t = tanh(t * t); |
7c673cae FG |
126 | |
127 | double dval = 2; | |
92f5a8d4 TL |
128 | t = pow(t, t); |
129 | t = pow(t, t * t); | |
130 | t = pow(t, dval); | |
131 | t = pow(t * t, t); | |
132 | t = pow(t * t, t * t); | |
133 | t = pow(t * t, dval); | |
134 | t = pow(dval, t); | |
135 | t = pow(dval, t * t); | |
7c673cae FG |
136 | |
137 | t = atan2(t, t); | |
92f5a8d4 | 138 | t = atan2(t, t * t); |
7c673cae | 139 | t = atan2(t, dval); |
92f5a8d4 TL |
140 | t = atan2(t * t, t); |
141 | t = atan2(t * t, t * t); | |
142 | t = atan2(t * t, dval); | |
7c673cae | 143 | t = atan2(dval, t); |
92f5a8d4 | 144 | t = atan2(dval, t * t); |
7c673cae FG |
145 | |
146 | t = fmod(t, t); | |
92f5a8d4 | 147 | t = fmod(t, t * t); |
7c673cae | 148 | t = fmod(t, dval); |
92f5a8d4 TL |
149 | t = fmod(t * t, t); |
150 | t = fmod(t * t, t * t); | |
151 | t = fmod(t * t, dval); | |
7c673cae | 152 | t = fmod(dval, t); |
92f5a8d4 | 153 | t = fmod(dval, t * t); |
7c673cae | 154 | |
92f5a8d4 | 155 | typedef typename T::backend_type backend_type; |
7c673cae | 156 | typedef typename backend_type::exponent_type exp_type; |
92f5a8d4 TL |
157 | exp_type e = 0; |
158 | int i = 0; | |
7c673cae FG |
159 | |
160 | t = ldexp(t, i); | |
92f5a8d4 | 161 | t = ldexp(t * t, i); |
7c673cae | 162 | t = ldexp(t, e); |
92f5a8d4 | 163 | t = ldexp(t * t, e); |
7c673cae FG |
164 | |
165 | t = frexp(t, &i); | |
92f5a8d4 | 166 | t = frexp(t * t, &i); |
7c673cae | 167 | t = frexp(t, &e); |
92f5a8d4 | 168 | t = frexp(t * t, &e); |
7c673cae FG |
169 | |
170 | t = scalbn(t, i); | |
92f5a8d4 | 171 | t = scalbn(t * t, i); |
7c673cae | 172 | t = scalbn(t, e); |
92f5a8d4 | 173 | t = scalbn(t * t, e); |
7c673cae FG |
174 | |
175 | t = logb(t); | |
92f5a8d4 | 176 | t = logb(t * t); |
7c673cae | 177 | e = ilogb(t); |
92f5a8d4 | 178 | e = ilogb(t * t); |
7c673cae FG |
179 | } |
180 | ||
181 | void foo() | |
182 | { | |
183 | #ifdef TEST_BACKEND | |
184 | test_extra(boost::multiprecision::concepts::mp_number_float_architype()); | |
185 | #endif | |
186 | #ifdef TEST_MPF_50 | |
187 | test_extra(boost::multiprecision::mpf_float_50()); | |
188 | #endif | |
189 | #ifdef TEST_MPFR_50 | |
190 | test_extra(boost::multiprecision::mpfr_float_50()); | |
191 | #endif | |
192 | #ifdef TEST_MPFR_6 | |
193 | test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<6> >()); | |
194 | #endif | |
195 | #ifdef TEST_MPFR_15 | |
196 | test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<15> >()); | |
197 | #endif | |
198 | #ifdef TEST_MPFR_17 | |
199 | test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<17> >()); | |
200 | #endif | |
201 | #ifdef TEST_MPFR_30 | |
202 | test_extra(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<30> >()); | |
203 | #endif | |
204 | #ifdef TEST_CPP_DEC_FLOAT | |
205 | test_extra(boost::multiprecision::cpp_dec_float_50()); | |
206 | #endif | |
207 | #ifdef TEST_CPP_BIN_FLOAT | |
208 | test_extra(boost::multiprecision::cpp_bin_float_50()); | |
209 | #endif | |
210 | #ifdef TEST_CPP_DEC_FLOAT_NO_ET | |
211 | test_extra(boost::multiprecision::number<boost::multiprecision::cpp_dec_float<100>, boost::multiprecision::et_off>()); | |
212 | #endif | |
213 | } | |
214 | ||
215 | int main() | |
216 | { | |
217 | #ifdef TEST_BACKEND | |
218 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::concepts::mp_number_float_architype>)); | |
219 | #endif | |
220 | #ifdef TEST_MPF_50 | |
221 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpf_float_50>)); | |
222 | #endif | |
223 | #ifdef TEST_MPFR_50 | |
224 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpfr_float_50>)); | |
225 | #endif | |
226 | #ifdef TEST_MPFR_6 | |
227 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<6> > >)); | |
228 | #endif | |
229 | #ifdef TEST_MPFR_15 | |
230 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<15> > >)); | |
231 | #endif | |
232 | #ifdef TEST_MPFR_17 | |
233 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<17> > >)); | |
234 | #endif | |
235 | #ifdef TEST_MPFR_30 | |
236 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<30> > >)); | |
237 | #endif | |
238 | #ifdef TEST_MPFR_50 | |
239 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::mpfr_float_50>)); | |
240 | #endif | |
241 | #ifdef TEST_CPP_DEC_FLOAT | |
242 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::cpp_dec_float_50>)); | |
243 | #endif | |
244 | #ifdef TEST_CPP_BIN_FLOAT | |
245 | BOOST_CONCEPT_ASSERT((boost::math::concepts::RealTypeConcept<boost::multiprecision::cpp_bin_float_50>)); | |
246 | #endif | |
247 | #ifdef TEST_LOGGED_ADAPTER | |
248 | typedef boost::multiprecision::number<boost::multiprecision::logged_adaptor<boost::multiprecision::cpp_dec_float<50> > > num_t; | |
249 | test_extra(num_t()); | |
250 | #endif | |
7c673cae | 251 | } |