test_real_concept.cpp 21 KB

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