]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_real_concept.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / test / test_real_concept.cpp
1 // Copyright John Maddock 2010
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 #include <boost/math/concepts/real_concept.hpp> // for real_concept
8 #include <boost/math/constants/constants.hpp>
9
10 #define BOOST_TEST_MAIN
11 #include <boost/test/unit_test.hpp> // Boost.Test
12 #include <boost/test/results_collector.hpp>
13 #include <boost/test/unit_test.hpp>
14 #include <boost/test/floating_point_comparison.hpp>
15 #include <iostream>
16 #include <iomanip>
17
18
19 BOOST_AUTO_TEST_CASE( test_main )
20 {
21 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
22
23 typedef boost::math::concepts::real_concept rc_t;
24
25 rc_t r1(2.5), r2(0.125), r3(45.5);
26 long double l1(2.5), l2(0.125), l3(45.5);
27 long double tol = std::numeric_limits<long double>::epsilon() * 2;
28
29 {
30 rc_t t(r1);
31 long double t2(l1);
32 t += r2;
33 t2 += l2;
34 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
35 t = r1;
36 t += l2;
37 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
38 t = r1;
39 t += 0.125;
40 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
41 t = r1;
42 t += 0.125f;
43 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
44
45 t = r1;
46 t += 23L;
47 t2 = 23 + l1;
48 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
49 t = r1;
50 t += 23uL;
51 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
52 t = r1;
53 t += 23;
54 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
55 t = r1;
56 t += 23u;
57 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
58 t = r1;
59 t += static_cast<short>(23);
60 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
61 t = r1;
62 t += static_cast<unsigned short>(23);
63 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
64 t = r1;
65 t += static_cast<char>(23);
66 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
67 t = r1;
68 t += static_cast<signed char>(23);
69 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
70 t = r1;
71 t += static_cast<unsigned char>(23);
72 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
73 }
74
75 {
76 rc_t t(r1);
77 long double t2(l1);
78 t -= r2;
79 t2 -= l2;
80 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
81 t = r1;
82 t -= l2;
83 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
84 t = r1;
85 t -= 0.125;
86 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
87 t = r1;
88 t -= 0.125f;
89 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
90
91 t = r1;
92 t -= 23L;
93 t2 = l1 - 23;
94 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
95 t = r1;
96 t -= 23uL;
97 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
98 t = r1;
99 t -= 23;
100 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
101 t = r1;
102 t -= 23u;
103 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
104 t = r1;
105 t -= static_cast<short>(23);
106 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
107 t = r1;
108 t -= static_cast<unsigned short>(23);
109 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
110 t = r1;
111 t -= static_cast<char>(23);
112 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
113 t = r1;
114 t -= static_cast<signed char>(23);
115 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
116 t = r1;
117 t -= static_cast<unsigned char>(23);
118 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
119 }
120
121 {
122 rc_t t(r1);
123 long double t2(l1);
124 t *= r2;
125 t2 *= l2;
126 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
127 t = r1;
128 t *= l2;
129 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
130 t = r1;
131 t *= 0.125;
132 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
133 t = r1;
134 t *= 0.125f;
135 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
136
137 t = r1;
138 t *= 23L;
139 t2 = 23 * l1;
140 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
141 t = r1;
142 t *= 23uL;
143 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
144 t = r1;
145 t *= 23;
146 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
147 t = r1;
148 t *= 23u;
149 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
150 t = r1;
151 t *= static_cast<short>(23);
152 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
153 t = r1;
154 t *= static_cast<unsigned short>(23);
155 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
156 t = r1;
157 t *= static_cast<char>(23);
158 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
159 t = r1;
160 t *= static_cast<signed char>(23);
161 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
162 t = r1;
163 t *= static_cast<unsigned char>(23);
164 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
165 }
166 {
167 rc_t t(r1);
168 long double t2(l1);
169 t /= r2;
170 t2 /= l2;
171 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
172 t = r1;
173 t /= l2;
174 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
175 t = r1;
176 t /= 0.125;
177 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
178 t = r1;
179 t /= 0.125f;
180 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
181
182 t = r1;
183 t /= 23L;
184 t2 = l1 / 23;
185 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
186 t = r1;
187 t /= 23uL;
188 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
189 t = r1;
190 t /= 23;
191 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
192 t = r1;
193 t /= 23u;
194 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
195 t = r1;
196 t /= static_cast<short>(23);
197 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
198 t = r1;
199 t /= static_cast<unsigned short>(23);
200 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
201 t = r1;
202 t /= static_cast<char>(23);
203 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
204 t = r1;
205 t /= static_cast<signed char>(23);
206 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
207 t = r1;
208 t /= static_cast<unsigned char>(23);
209 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
210 }
211
212 {
213 rc_t t;
214 long double t2;
215 t = r1 + r2;
216 t2 = l1 + l2;
217 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
218 t = r1 + l2;
219 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
220 t = r1 + 0.125;
221 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
222 t = r1 + 0.125f;
223 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
224 t = l2 + r1;
225 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
226 t = 0.125 + r1;
227 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
228 t = 0.125f + r1;
229 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
230
231 t2 = l1 + 23L;
232 t = r1 + 23L;
233 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
234 t = r1 + 23uL;
235 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
236 t = r1 + 23;
237 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
238 t = r1 + 23u;
239 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
240 t = r1 + static_cast<short>(23);
241 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
242 t = r1 + static_cast<unsigned short>(23);
243 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
244 t = r1 + static_cast<char>(23);
245 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
246 t = r1 + static_cast<signed char>(23);
247 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
248 t = r1 + static_cast<unsigned char>(23);
249 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
250
251 t = 23L + r1;
252 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
253 t = 23uL + r1;
254 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
255 t = 23 + r1;
256 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
257 t = 23u + r1;
258 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
259 t = static_cast<short>(23) + r1;
260 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
261 t = static_cast<unsigned short>(23) + r1;
262 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
263 t = static_cast<char>(23) + r1;
264 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
265 t = static_cast<signed char>(23) + r1;
266 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
267 t = static_cast<unsigned char>(23) + r1;
268 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
269 }
270 {
271 rc_t t;
272 long double t2;
273 t = r1 - r2;
274 t2 = l1 - l2;
275 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
276 t = r1 - l2;
277 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
278 t = r1 - 0.125;
279 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
280 t = r1 - 0.125f;
281 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
282 t2 = l2 - l1;
283 t = l2 - r1;
284 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
285 t = 0.125 - r1;
286 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
287 t = 0.125f - r1;
288 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
289
290 t2 = l1 - 23L;
291 t = r1 - 23L;
292 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
293 t = r1 - 23uL;
294 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
295 t = r1 - 23;
296 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
297 t = r1 - 23u;
298 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
299 t = r1 - static_cast<short>(23);
300 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
301 t = r1 - static_cast<unsigned short>(23);
302 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
303 t = r1 - static_cast<char>(23);
304 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
305 t = r1 - static_cast<signed char>(23);
306 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
307 t = r1 - static_cast<unsigned char>(23);
308 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
309
310 t2 = 23L - l1;
311 t = 23L - r1;
312 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
313 t = 23uL - r1;
314 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
315 t = 23 - r1;
316 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
317 t = 23u - r1;
318 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
319 t = static_cast<short>(23) - r1;
320 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
321 t = static_cast<unsigned short>(23) - r1;
322 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
323 t = static_cast<char>(23) - r1;
324 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
325 t = static_cast<signed char>(23) - r1;
326 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
327 t = static_cast<unsigned char>(23) - r1;
328 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
329 }
330 {
331 rc_t t;
332 long double t2;
333 t = r1 * r2;
334 t2 = l1 * l2;
335 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
336 t = r1 * l2;
337 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
338 t = r1 * 0.125;
339 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
340 t = r1 * 0.125f;
341 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
342 t = l2 * r1;
343 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
344 t = 0.125 * r1;
345 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
346 t = 0.125f * r1;
347 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
348
349 t2 = l1 * 23L;
350 t = r1 * 23L;
351 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
352 t = r1 * 23uL;
353 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
354 t = r1 * 23;
355 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
356 t = r1 * 23u;
357 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
358 t = r1 * static_cast<short>(23);
359 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
360 t = r1 * static_cast<unsigned short>(23);
361 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
362 t = r1 * static_cast<char>(23);
363 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
364 t = r1 * static_cast<signed char>(23);
365 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
366 t = r1 * static_cast<unsigned char>(23);
367 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
368
369 t = 23L * r1;
370 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
371 t = 23uL * r1;
372 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
373 t = 23 * r1;
374 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
375 t = 23u * r1;
376 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
377 t = static_cast<short>(23) * r1;
378 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
379 t = static_cast<unsigned short>(23) * r1;
380 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
381 t = static_cast<char>(23) * r1;
382 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
383 t = static_cast<signed char>(23) * r1;
384 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
385 t = static_cast<unsigned char>(23) * r1;
386 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
387 }
388 {
389 rc_t t;
390 long double t2;
391 t = r1 / r2;
392 t2 = l1 / l2;
393 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
394 t = r1 / l2;
395 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
396 t = r1 / 0.125;
397 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
398 t = r1 / 0.125f;
399 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
400 t2 = l2 / l1;
401 t = l2 / r1;
402 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
403 t = 0.125 / r1;
404 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
405 t = 0.125f / r1;
406 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
407
408 t2 = l1 / 23L;
409 t = r1 / 23L;
410 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
411 t = r1 / 23uL;
412 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
413 t = r1 / 23;
414 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
415 t = r1 / 23u;
416 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
417 t = r1 / static_cast<short>(23);
418 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
419 t = r1 / static_cast<unsigned short>(23);
420 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
421 t = r1 / static_cast<char>(23);
422 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
423 t = r1 / static_cast<signed char>(23);
424 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
425 t = r1 / static_cast<unsigned char>(23);
426 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
427
428 t2 = 23L / l1;
429 t = 23L / r1;
430 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
431 t = 23uL / r1;
432 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
433 t = 23 / r1;
434 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
435 t = 23u / r1;
436 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
437 t = static_cast<short>(23) / r1;
438 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
439 t = static_cast<unsigned short>(23) / r1;
440 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
441 t = static_cast<char>(23) / r1;
442 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
443 t = static_cast<signed char>(23) / r1;
444 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
445 t = static_cast<unsigned char>(23) / r1;
446 BOOST_CHECK_CLOSE_FRACTION(t.value(), t2, tol);
447 }
448
449 {
450 BOOST_CHECK_EQUAL(r1 == r2, l1 == l2);
451 BOOST_CHECK_EQUAL(r1 == l2, l1 == l2);
452 BOOST_CHECK_EQUAL(r1 == 0.125, l1 == l2);
453 BOOST_CHECK_EQUAL(r1 == 0.125f, l1 == l2);
454 BOOST_CHECK_EQUAL(l1 == r2, l1 == l2);
455 BOOST_CHECK_EQUAL(2.5 == r2, l1 == l2);
456 BOOST_CHECK_EQUAL(2.5f == r2, l1 == l2);
457
458 BOOST_CHECK_EQUAL(r1 <= r2, l1 <= l2);
459 BOOST_CHECK_EQUAL(r1 <= l2, l1 <= l2);
460 BOOST_CHECK_EQUAL(r1 <= 0.125, l1 <= l2);
461 BOOST_CHECK_EQUAL(r1 <= 0.125f, l1 <= l2);
462 BOOST_CHECK_EQUAL(l1 <= r2, l1 <= l2);
463 BOOST_CHECK_EQUAL(2.5 <= r2, l1 <= l2);
464 BOOST_CHECK_EQUAL(2.5f <= r2, l1 <= l2);
465
466 BOOST_CHECK_EQUAL(r1 >= r2, l1 >= l2);
467 BOOST_CHECK_EQUAL(r1 >= l2, l1 >= l2);
468 BOOST_CHECK_EQUAL(r1 >= 0.125, l1 >= l2);
469 BOOST_CHECK_EQUAL(r1 >= 0.125f, l1 >= l2);
470 BOOST_CHECK_EQUAL(l1 >= r2, l1 >= l2);
471 BOOST_CHECK_EQUAL(2.5 >= r2, l1 >= l2);
472 BOOST_CHECK_EQUAL(2.5f >= r2, l1 >= l2);
473
474 BOOST_CHECK_EQUAL(r1 < r2, l1 < l2);
475 BOOST_CHECK_EQUAL(r1 < l2, l1 < l2);
476 BOOST_CHECK_EQUAL(r1 < 0.125, l1 < l2);
477 BOOST_CHECK_EQUAL(r1 < 0.125f, l1 < l2);
478 BOOST_CHECK_EQUAL(l1 < r2, l1 < l2);
479 BOOST_CHECK_EQUAL(2.5 < r2, l1 < l2);
480 BOOST_CHECK_EQUAL(2.5f < r2, l1 < l2);
481
482 BOOST_CHECK_EQUAL(r1 > r2, l1 > l2);
483 BOOST_CHECK_EQUAL(r1 > l2, l1 > l2);
484 BOOST_CHECK_EQUAL(r1 > 0.125, l1 > l2);
485 BOOST_CHECK_EQUAL(r1 > 0.125f, l1 > l2);
486 BOOST_CHECK_EQUAL(l1 > r2, l1 > l2);
487 BOOST_CHECK_EQUAL(2.5 > r2, l1 > l2);
488 BOOST_CHECK_EQUAL(2.5f > r2, l1 > l2);
489 }
490
491 {
492 BOOST_MATH_STD_USING
493 BOOST_CHECK_CLOSE_FRACTION(acos(r2), acos(l2), tol);
494 BOOST_CHECK_CLOSE_FRACTION(cos(r2), cos(l2), tol);
495 BOOST_CHECK_CLOSE_FRACTION(asin(r2), asin(l2), tol);
496 BOOST_CHECK_CLOSE_FRACTION(atan(r2), atan(l2), tol);
497 BOOST_CHECK_CLOSE_FRACTION(atan2(r2, r3), atan2(l2, l3), tol);
498 BOOST_CHECK_CLOSE_FRACTION(ceil(r2), ceil(l2), tol);
499 BOOST_CHECK_CLOSE_FRACTION(fmod(r2, r3), fmod(l2, l3), tol);
500 BOOST_CHECK_CLOSE_FRACTION(cosh(r2), cosh(l2), tol);
501 BOOST_CHECK_CLOSE_FRACTION(exp(r2), exp(l2), tol);
502 BOOST_CHECK_CLOSE_FRACTION(fabs(r2), fabs(l2), tol);
503 BOOST_CHECK_CLOSE_FRACTION(abs(r2), abs(l2), tol);
504 rc_t rc_result;
505 long double ld_result;
506 #ifdef __MINGW32__
507 BOOST_CHECK_CLOSE_FRACTION(modf(r2, &rc_result), boost::math::modf(l2, &ld_result), tol);
508 #else
509 BOOST_CHECK_CLOSE_FRACTION(modf(r2, &rc_result), modf(l2, &ld_result), tol);
510 #endif
511 BOOST_CHECK_CLOSE_FRACTION(rc_result, ld_result, tol);
512 int i1, i2;
513 BOOST_CHECK_CLOSE_FRACTION(frexp(r3, &i1), frexp(l3, &i2), tol);
514 BOOST_CHECK_EQUAL(i1, i2);
515 BOOST_CHECK_CLOSE_FRACTION(ldexp(r3, i1), ldexp(l3, i1), tol);
516 BOOST_CHECK_CLOSE_FRACTION(log(r2), log(l2), tol);
517 BOOST_CHECK_CLOSE_FRACTION(log10(r2), log10(l2), tol);
518 BOOST_CHECK_CLOSE_FRACTION(tan(r2), tan(l2), tol);
519 BOOST_CHECK_CLOSE_FRACTION(pow(r2, r3), pow(l2, l3), tol);
520 BOOST_CHECK_CLOSE_FRACTION(pow(r2, i1), pow(l2, i1), tol);
521 BOOST_CHECK_CLOSE_FRACTION(sin(r2), sin(l2), tol);
522 BOOST_CHECK_CLOSE_FRACTION(sinh(r2), sinh(l2), tol);
523 BOOST_CHECK_CLOSE_FRACTION(sqrt(r2), sqrt(l2), tol);
524 BOOST_CHECK_CLOSE_FRACTION(tanh(r2), tanh(l2), tol);
525
526 BOOST_CHECK_EQUAL(iround(r2), boost::math::iround(l2));
527 BOOST_CHECK_EQUAL(lround(r2), boost::math::lround(l2));
528 #ifdef BOOST_HAS_LONG_LONG
529 BOOST_CHECK_EQUAL(llround(r2), boost::math::llround(l2));
530 #endif
531 BOOST_CHECK_EQUAL(itrunc(r2), boost::math::itrunc(l2));
532 BOOST_CHECK_EQUAL(ltrunc(r2), boost::math::ltrunc(l2));
533 #ifdef BOOST_HAS_LONG_LONG
534 BOOST_CHECK_EQUAL(lltrunc(r2), boost::math::lltrunc(l2));
535 #endif
536 }
537
538 {
539 using namespace boost::math::tools;
540 tol = std::numeric_limits<long double>::epsilon();
541 BOOST_CHECK_CLOSE_FRACTION(max_value<rc_t>(), max_value<long double>(), tol);
542 BOOST_CHECK_CLOSE_FRACTION(min_value<rc_t>(), min_value<long double>(), tol);
543 BOOST_CHECK_CLOSE_FRACTION(log_max_value<rc_t>(), log_max_value<long double>(), tol);
544 BOOST_CHECK_CLOSE_FRACTION(log_min_value<rc_t>(), log_min_value<long double>(), tol);
545 BOOST_CHECK_CLOSE_FRACTION(epsilon<rc_t>(), epsilon<long double>(), tol);
546 BOOST_CHECK_EQUAL(digits<rc_t>(), digits<long double>());
547 }
548
549 {
550 using namespace boost::math::constants;
551 BOOST_CHECK_CLOSE_FRACTION(pi<rc_t>(), pi<long double>(), tol);
552 BOOST_CHECK_CLOSE_FRACTION(root_pi<rc_t>(), root_pi<long double>(), tol);
553 BOOST_CHECK_CLOSE_FRACTION(root_half_pi<rc_t>(), root_half_pi<long double>(), tol);
554 BOOST_CHECK_CLOSE_FRACTION(root_two_pi<rc_t>(), root_two_pi<long double>(), tol);
555 BOOST_CHECK_CLOSE_FRACTION(root_ln_four<rc_t>(), root_ln_four<long double>(), tol);
556 BOOST_CHECK_CLOSE_FRACTION(half<rc_t>(), half<long double>(), tol);
557 BOOST_CHECK_CLOSE_FRACTION(euler<rc_t>(), euler<long double>(), tol);
558 BOOST_CHECK_CLOSE_FRACTION(root_two<rc_t>(), root_two<long double>(), tol);
559 BOOST_CHECK_CLOSE_FRACTION(ln_two<rc_t>(), ln_two<long double>(), tol);
560 BOOST_CHECK_CLOSE_FRACTION(ln_ln_two<rc_t>(), ln_ln_two<long double>(), tol);
561 BOOST_CHECK_CLOSE_FRACTION(third<rc_t>(), third<long double>(), tol);
562 BOOST_CHECK_CLOSE_FRACTION(twothirds<rc_t>(), twothirds<long double>(), tol);
563 BOOST_CHECK_CLOSE_FRACTION(pi_minus_three<rc_t>(), pi_minus_three<long double>(), tol);
564 BOOST_CHECK_CLOSE_FRACTION(four_minus_pi<rc_t>(), four_minus_pi<long double>(), tol);
565 // BOOST_CHECK_CLOSE_FRACTION(pow23_four_minus_pi<rc_t>(), pow23_four_minus_pi<long double>(), tol);
566 BOOST_CHECK_CLOSE_FRACTION(exp_minus_half<rc_t>(), exp_minus_half<long double>(), tol);
567 }
568
569 #else
570 std::cout << "<note>The long double tests have been disabled on this platform "
571 "either because the long double overloads of the usual math functions are "
572 "not available at all, or because they are too inaccurate for these tests "
573 "to pass.</note>" << std::endl;
574 #endif
575
576
577 } // BOOST_AUTO_TEST_CASE( test_main )
578