test_long_double_support.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. // Copyright John Maddock 2009
  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 <cmath>
  7. #include <math.h>
  8. #include <limits.h>
  9. #define BOOST_TEST_MAIN
  10. #include <boost/test/unit_test.hpp> // Boost.Test
  11. #include <boost/test/results_collector.hpp>
  12. #include <boost/test/unit_test.hpp>
  13. #include <boost/test/tools/floating_point_comparison.hpp>
  14. #include <iostream>
  15. #include <iomanip>
  16. using std::cout;
  17. using std::endl;
  18. using std::setprecision;
  19. #include <boost/array.hpp>
  20. #include "functor.hpp"
  21. #include "handle_test_result.hpp"
  22. #include "table_type.hpp"
  23. #include <boost/math/tools/config.hpp>
  24. void expected_results()
  25. {
  26. //
  27. // Define the max and mean errors expected for
  28. // various compilers and platforms.
  29. //
  30. const char* largest_type;
  31. largest_type = "(long\\s+)?double";
  32. add_expected_result(
  33. ".*", // compiler
  34. ".*", // stdlib
  35. ".*", // platform
  36. largest_type, // test type(s)
  37. ".*", // test data group
  38. ".*", 50, 20); // test function
  39. }
  40. template <class R, class Proc, class Arg>
  41. struct simple_binder
  42. {
  43. simple_binder(Proc p, Arg a) : m_proc(p), m_arg(a) {}
  44. R operator()(R arg) { return m_proc(arg, m_arg); }
  45. operator bool() { return m_proc ? true : false; }
  46. private:
  47. Proc m_proc;
  48. Arg m_arg;
  49. };
  50. template <class A, class Proc>
  51. void do_test_std_function(const A& data, const char* type_name, const char* function_name, const char* test_name, Proc proc, const char* inv_function_name = 0, Proc inv_proc = 0)
  52. {
  53. // warning suppression:
  54. (void)data;
  55. (void)type_name;
  56. (void)test_name;
  57. typedef typename A::value_type row_type;
  58. typedef typename row_type::value_type value_type;
  59. boost::math::tools::test_result<value_type> result;
  60. //
  61. // test against data:
  62. //
  63. result = boost::math::tools::test(
  64. data,
  65. bind_func<value_type>(proc, 0),
  66. extract_result<value_type>(1));
  67. handle_test_result(result, data[result.worst()], result.worst(), type_name, function_name, test_name);
  68. if(inv_proc)
  69. {
  70. result = boost::math::tools::test(
  71. data,
  72. bind_func<value_type>(inv_proc, 1),
  73. extract_result<value_type>(0));
  74. handle_test_result(result, data[result.worst()], result.worst(), type_name, inv_function_name, test_name);
  75. }
  76. }
  77. template <class A>
  78. void do_test_std_function_2(const A& data, const char* type_name, const char* function_name, const char* test_name, long double(*proc)(long double, long double), const char* inv_function_name = 0, long double(*inv_proc)(long double, long double) = 0)
  79. {
  80. // warning suppression:
  81. (void)data;
  82. (void)type_name;
  83. (void)test_name;
  84. typedef typename A::value_type row_type;
  85. typedef typename row_type::value_type value_type;
  86. boost::math::tools::test_result<value_type> result;
  87. //
  88. // test against data:
  89. //
  90. result = boost::math::tools::test(
  91. data,
  92. bind_func<value_type>(proc, 0, 1),
  93. extract_result<value_type>(2));
  94. handle_test_result(result, data[result.worst()], result.worst(), type_name, function_name, test_name);
  95. if(inv_proc)
  96. {
  97. result = boost::math::tools::test(
  98. data,
  99. bind_func<value_type>(inv_proc, 2, 1),
  100. extract_result<value_type>(0));
  101. handle_test_result(result, data[result.worst()], result.worst(), type_name, inv_function_name, test_name);
  102. }
  103. }
  104. long double std_inv_pow(long double a, long double b)
  105. {
  106. return std::pow(a, 1 / b);
  107. }
  108. long double std_inv_powl(long double a, long double b)
  109. {
  110. return ::powl(a, 1 / b);
  111. }
  112. void test_spots()
  113. {
  114. // Basic sanity checks.
  115. // Test data taken from functions.wolfram.com
  116. long double (*unary_proc)(long double);
  117. long double (*inv_unary_proc)(long double);
  118. long double(*binary_proc)(long double, long double);
  119. long double(*inv_binary_proc)(long double, long double);
  120. //
  121. // COS:
  122. //
  123. boost::array<boost::array<long double, 2>, 4> cos_test_data = {{
  124. {{ 0, 1, }},
  125. {{ 0.125L, 0.992197667229329053149096907788250869543327304736601263468910L, }},
  126. {{ 1.125L, 0.431176516798666176551969042921689826840697850225767471037314L, }},
  127. {{ 1.75L, -0.178246055649492090382676943942631358969920851291548272886063L, }},
  128. }};
  129. unary_proc = std::cos;
  130. inv_unary_proc = std::acos;
  131. do_test_std_function(cos_test_data, "long double", "std::cos", "Mathematica data", unary_proc, "std::acos", inv_unary_proc);
  132. unary_proc = ::cosl;
  133. inv_unary_proc = ::acosl;
  134. do_test_std_function(cos_test_data, "long double", "::cosl", "Mathematica data", unary_proc, "::acosl", inv_unary_proc);
  135. //
  136. // SIN:
  137. //
  138. boost::array<boost::array<long double, 2>, 6> sin_test_data = {{
  139. {{ 0, 0, }},
  140. {{ 0.125L, 0.124674733385227689957442708712108467587834905641679257885515L, }},
  141. {{ -0.125L, -0.124674733385227689957442708712108467587834905641679257885515L, }},
  142. {{ 1.125L, 0.902267594099095162918416128654829100758989018716070814389152L, }},
  143. #if LDBL_MAX_EXP > DBL_MAX_EXP
  144. {{ 1e-500L, 1e-500L, }},
  145. {{ 1e-1500L, 1e-1500L, }},
  146. #else
  147. {{ 0, 0, }},
  148. {{ 0, 0, }},
  149. #endif
  150. }};
  151. unary_proc = std::sin;
  152. inv_unary_proc = std::asin;
  153. do_test_std_function(sin_test_data, "long double", "std::sin", "Mathematica data", unary_proc, "std::asin", inv_unary_proc);
  154. unary_proc = ::sinl;
  155. inv_unary_proc = ::asinl;
  156. do_test_std_function(sin_test_data, "long double", "::sinl", "Mathematica data", unary_proc, "::asinl", inv_unary_proc);
  157. //
  158. // TAN:
  159. //
  160. boost::array<boost::array<long double, 2>, 6> tan_test_data = {{
  161. {{ 0, 0, }},
  162. {{ 0.125L, 0.125655136575130967792678218629774000758665763892225542668867L, }},
  163. {{ -0.125L, -0.125655136575130967792678218629774000758665763892225542668867L, }},
  164. {{ 1.125L, 2.09257127637217900442373398123488678225994171614872057291399L, }},
  165. #if LDBL_MAX_EXP > DBL_MAX_EXP
  166. {{ 1e-500L, 1e-500L, }},
  167. {{ 1e-1500L, 1e-1500L, }},
  168. #else
  169. {{ 0, 0, }},
  170. {{ 0, 0, }},
  171. #endif
  172. }};
  173. unary_proc = std::tan;
  174. inv_unary_proc = std::atan;
  175. do_test_std_function(tan_test_data, "long double", "std::tan", "Mathematica data", unary_proc, "std::atan", inv_unary_proc);
  176. unary_proc = ::tanl;
  177. inv_unary_proc = ::atanl;
  178. do_test_std_function(tan_test_data, "long double", "::tanl", "Mathematica data", unary_proc, "::atanl", inv_unary_proc);
  179. //
  180. // EXP:
  181. //
  182. boost::array<boost::array<long double, 2>, 16> exp_test_data = {{
  183. {{ 0, 1, }},
  184. {{ 0.125L, 1.13314845306682631682900722781179387256550313174518162591282L, }},
  185. {{ -0.125L, 0.882496902584595402864892143229050736222004824990650741770309L, }},
  186. {{ 1.125L, 3.08021684891803124500466787877703957705899375982613074033239L, }},
  187. {{ 4.60517018598809136803598290936872841520220297725754595206666L, 100L, }},
  188. {{ 23.0258509299404568401799145468436420760110148862877297603333L, 1e10L, }},
  189. {{ 230.258509299404568401799145468436420760110148862877297603333L, 1e100L, }},
  190. {{ -230.258509299404568401799145468436420760110148862877297603333L, 1e-100L, }},
  191. {{ -23.0258509299404568401799145468436420760110148862877297603333L, 1e-10L, }},
  192. {{ -4.60517018598809136803598290936872841520220297725754595206666L, 0.01L, }},
  193. #if LDBL_MAX_EXP > DBL_MAX_EXP
  194. {{ 1151.5L, 1.23054049904018215810329849694e+500L, }},
  195. {{ 2302.5, 9.1842687219959504902800771504e+999L, }},
  196. {{ 11351.5, 7.83089362896060182981072520459e+4929L, }},
  197. {{ -11351.5, 1.27699346636729947157842192471e-4930L, }},
  198. {{ -2302.5, 1.0888183156107362404277325218e-1000L, }},
  199. {{ -1151.5, 8.12651026747999724274336150307e-501L, }},
  200. #else
  201. {{ 0, 1, }},
  202. {{ 0, 1, }},
  203. {{ 0, 1, }},
  204. {{ 0, 1, }},
  205. {{ 0, 1, }},
  206. {{ 0, 1, }},
  207. #endif
  208. }};
  209. unary_proc = std::exp;
  210. inv_unary_proc = std::log;
  211. do_test_std_function(exp_test_data, "long double", "std::exp", "Mathematica data", unary_proc, "std::log", inv_unary_proc);
  212. unary_proc = ::expl;
  213. inv_unary_proc = ::logl;
  214. do_test_std_function(exp_test_data, "long double", "::expl", "Mathematica data", unary_proc, "::logl", inv_unary_proc);
  215. //
  216. // SQRT:
  217. //
  218. boost::array<boost::array<long double, 2>, 8> sqrt_test_data = {{
  219. {{ 1, 1, }},
  220. {{ 0.125L, 0.353553390593273762200422181052424519642417968844237018294170L, }},
  221. {{ 1.125L, 1.06066017177982128660126654315727355892725390653271105488251L, }},
  222. {{ 1e10L, 1e5L, }},
  223. {{ 1e100L, 1e50L, }},
  224. #if LDBL_MAX_EXP > DBL_MAX_EXP
  225. {{ 1e500L, 1e250L, }},
  226. {{ 1e1000L, 1e500L, }},
  227. {{ 1e4930L, 1e2465L }},
  228. #else
  229. {{ 1, 1, }},
  230. {{ 1, 1, }},
  231. {{ 1, 1, }},
  232. #endif
  233. }};
  234. unary_proc = std::sqrt;
  235. inv_unary_proc = 0;
  236. do_test_std_function(sqrt_test_data, "long double", "std::sqrt", "Mathematica data", unary_proc, "", inv_unary_proc);
  237. unary_proc = ::sqrtl;
  238. do_test_std_function(sqrt_test_data, "long double", "::sqrtl", "Mathematica data", unary_proc, "", inv_unary_proc);
  239. //
  240. // POW:
  241. //
  242. boost::array<boost::array<long double, 3>, 40> pow_test_data = { {
  243. {{ 0.66666666666666666666666666666666667L, 10.5L, 0.014159299884333205600738476477156445L }}, {{ 0.40000000000000000000000000000000000L, 10.5L, 0.000066317769195774370528601435944941645L }}, {{ 0.28571428571428571428571428571428571L, 10.5L, 1.9376955162420093656912416026996235e-6L }}, {{ 0.22222222222222222222222222222222222L, 10.5L, 1.3844223610486906136767179806965939e-7L }}, {{ 0.18181818181818181818181818181818182L, 10.5L, 1.6834172004858801495594195366987548e-8L }}, {{ 0.15384615384615384615384615384615385L, 10.5L, 2.9134646649328940997378075111892189e-9L }}, {{ 0.13333333333333333333333333333333333L, 10.5L, 6.4842049648996264411393424327833257e-10L }}, {{ 0.11764705882352941176470588235294118L, 10.5L, 1.7422131202561313794251961087695707e-10L }}, {{ 0.10526315789473684210526315789473684L, 10.5L, 5.4187878014379968862785381990028068e-11L }}, {{ 0.095238095238095238095238095238095238L, 10.5L, 1.8945774321493250860060262734435905e-11L }}, {{ 0.086956521739130434782608695652173913L, 10.5L, 7.2890793204362496660639940633060965e-12L }}, {{ 0.080000000000000000000000000000000000L, 10.5L, 3.0370004999760496924513885300263083e-12L }}, {{ 0.074074074074074074074074074074074074L, 10.5L, 1.3536158492499429228631254734846878e-12L }}, {{ 0.068965517241379310344827586206896552L, 10.5L, 6.3919883760311690617057708564070401e-13L }}, {{ 0.064516129032258064516129032258064516L, 10.5L, 3.1733441149827305559623332316304054e-13L }}, {{ 0.060606060606060606060606060606060606L, 10.5L, 1.6459573809191842515197160159747426e-13L }}, {{ 0.057142857142857142857142857142857143L, 10.5L, 8.8736130949400182344750668262188042e-14L }}, {{ 0.054054054054054054054054054054054054L, 10.5L, 4.9510447505703867036532738058014010e-14L }}, {{ 0.051282051282051282051282051282051282L, 10.5L, 2.8486335222839832002073312496999392e-14L }}, {{ 0.048780487804878048780487804878048780L, 10.5L, 1.6849400716758403447644197639952420e-14L }},
  244. {{ 1.5000000000000000000000000000000000L, 10.5L, 70.624960850392521250220423499662198L }}, {{ 2.5000000000000000000000000000000000L, 10.5L, 15078.914929239174518579929086841195L }}, {{ 3.5000000000000000000000000000000000L, 10.5L, 516076.95410237226543172579761452715L }}, {{ 4.5000000000000000000000000000000000L, 10.5L, 7.2232291830544165404082939248515132e6L }}, {{ 5.5000000000000000000000000000000000L, 10.5L, 5.9402981014532387277725120300837238e7L }}, {{ 6.5000000000000000000000000000000000L, 10.5L, 3.4323395510377093368928553895198363e8L }}, {{ 7.5000000000000000000000000000000000L, 10.5L, 1.5422091149388577381859115936567576e9L }}, {{ 8.5000000000000000000000000000000000L, 10.5L, 5.7398259051853831024096483301864439e9L }}, {{ 9.5000000000000000000000000000000000L, 10.5L, 1.8454311861679240697429074147628415e10L }}, {{ 10.500000000000000000000000000000000L, 10.5L, 5.2782218505872232242456985697751839e10L }}, {{ 11.500000000000000000000000000000000L, 10.5L, 1.3719153764678064136017469971586606e11L }}, {{ 12.500000000000000000000000000000000L, 10.5L, 3.2927225399135962333569506281281311e11L }}, {{ 13.500000000000000000000000000000000L, 10.5L, 7.3876203544315301346698877141070794e11L }}, {{ 14.500000000000000000000000000000000L, 10.5L, 1.5644584144580486482323422555543492e12L }}, {{ 15.500000000000000000000000000000000L, 10.5L, 3.1512497975828317415327223169183800e12L }}, {{ 16.500000000000000000000000000000000L, 10.5L, 6.0754914531356236794145301221027031e12L }}, {{ 17.500000000000000000000000000000000L, 10.5L, 1.1269366708925227994916228749680770e13L }}, {{ 18.500000000000000000000000000000000L, 10.5L, 2.0197757248806823614685377151546893e13L }}, {{ 19.500000000000000000000000000000000L, 10.5L, 3.5104550732037231618759085175272827e13L }}, {{ 20.500000000000000000000000000000000L, 10.5L, 5.9349291812224551314681152356459565e13L }},
  245. } };
  246. binary_proc = std::pow;
  247. inv_binary_proc = std_inv_pow;
  248. do_test_std_function_2(pow_test_data, "long double", "std::pow", "Mathematica data", binary_proc, "std::pow", inv_binary_proc);
  249. binary_proc = ::powl;
  250. inv_binary_proc = std_inv_powl;
  251. do_test_std_function_2(pow_test_data, "long double", "::powl", "Mathematica data", binary_proc, "::pow", inv_binary_proc);
  252. //
  253. // LDEXP:
  254. //
  255. boost::array<boost::array<long double, 2>, 20> ld_data = { {
  256. {{ 0.66666666666666666666666666666666667L, 8.4510040015215293433113547025066667e29L }}, {{ 0.40000000000000000000000000000000000L, 5.0706024009129176059868128215040000e29L }}, {{ 0.28571428571428571428571428571428571L, 3.6218588577949411471334377296457143e29L }}, {{ 0.22222222222222222222222222222222222L, 2.8170013338405097811037849008355556e29L }}, {{ 0.18181818181818181818181818181818182L, 2.3048192731422352754485512825018182e29L }}, {{ 0.15384615384615384615384615384615385L, 1.9502316926588144638410818544246154e29L }}, {{ 0.13333333333333333333333333333333333L, 1.6902008003043058686622709405013333e29L }}, {{ 0.11764705882352941176470588235294118L, 1.4913536473273287076431802416188235e29L }}, {{ 0.10526315789473684210526315789473684L, 1.3343690528718204226281086372378947e29L }}, {{ 0.095238095238095238095238095238095238L, 1.2072862859316470490444792432152381e29L }}, {{ 0.086956521739130434782608695652173913L, 1.1023048697636777404319158307617391e29L }}, {{ 0.080000000000000000000000000000000000L, 1.0141204801825835211973625643008000e29L }}, {{ 0.074074074074074074074074074074074074L, 9.3900044461350326036792830027851852e28L }}, {{ 0.068965517241379310344827586206896552L, 8.7424179326084786310117462439724138e28L }}, {{ 0.064516129032258064516129032258064516L, 8.1783909692143832354626013250064516e28L }}, {{ 0.060606060606060606060606060606060606L, 7.6827309104741175848285042750060606e28L }}, {{ 0.057142857142857142857142857142857143L, 7.2437177155898822942668754592914286e28L }}, {{ 0.054054054054054054054054054054054054L, 6.8521654066390778459281254344648649e28L }}, {{ 0.051282051282051282051282051282051282L, 6.5007723088627148794702728480820513e28L }}, {{ 0.048780487804878048780487804878048780L, 6.1836614645279482999839180750048780e28L }}
  257. }};
  258. using namespace boost;
  259. long double(*pld)(long double, int) = std::ldexp;
  260. do_test_std_function(ld_data, "long double", "std::ldexp", "Mathematica data", simple_binder<long double, long double(*)(long double, int), int>(pld, 100), "std::ldexp", simple_binder<long double, long double(*)(long double, int), int>(pld, -100));
  261. pld = ::ldexpl;
  262. do_test_std_function(ld_data, "long double", "::ldexp", "Mathematica data", simple_binder<long double, long double(*)(long double, int), int>(pld, 100), "::ldexp", simple_binder<long double, long double(*)(long double, int), int>(pld, -100));
  263. //
  264. // Sinh:
  265. //
  266. boost::array<boost::array<long double, 2>, 20> sinh_data = { {
  267. {{ 1.0L, 1.1752011936438014568823818505956008L }}, {{ 2.0L, 3.6268604078470187676682139828012617L }}, {{ 3.0L, 10.017874927409901898974593619465828L }}, {{ 4.0L, 27.289917197127752448908271590793819L }}, {{ 5.0L, 74.203210577788758977009471996064566L }}, {{ 6.0L, 201.71315737027922812498206768797873L }}, {{ 7.0L, 548.31612327324652237375611757601851L }}, {{ 8.0L, 1490.4788257895501861158766390318814L }}, {{ 9.0L, 4051.5419020827899605152235958980346L }}, {{ 10.L, 11013.232874703393377236524554846364L }}, {{ 11.L, 29937.070849248058832540413239811132L }}, {{ 12.L, 81377.395706429854227338497569902237L }}, {{ 13.L, 221206.69600333008695956086081165150L }}, {{ 14.L, 601302.14208197262451506660144189773L }}, {{ 15.L, 1.6345086862359023684906766101516749e6L }}, {{ 16.L, 4.4430552602538800507941522408334683e6L }}, {{ 17.L, 1.2077476376787628407699123664359614e7L }}, {{ 18.L, 3.2829984568665247954403379273215799e7L }}, {{ 19.L, 8.9241150481593627621056798125727582e7L }}, {{ 20.L, 2.4258259770489513795397660405149137e8L }},
  268. } };
  269. unary_proc = &std::sinh;
  270. #if __cplusplus >= 201103
  271. inv_unary_proc = &std::asinh;
  272. #else
  273. inv_unary_proc = 0;
  274. #endif
  275. do_test_std_function(sinh_data, "long double", "std::sinh", "Mathematica data", unary_proc, "std::asinh", inv_unary_proc);
  276. unary_proc = ::sinhl;
  277. #if __cplusplus >= 201103
  278. inv_unary_proc = ::asinhl;
  279. #endif
  280. do_test_std_function(sinh_data, "long double", "::sinhl", "Mathematica data", unary_proc, "::asinhl", inv_unary_proc);
  281. //
  282. // Cosh:
  283. //
  284. boost::array<boost::array<long double, 2L>, 20L> cosh_data = { {
  285. {{ 1.0L, 1.5430806348152437784779056207570617L }}, {{ 2.0L, 3.7621956910836314595622134777737461L }}, {{ 3.0L, 10.067661995777765841953936035115890L }}, {{ 4.0L, 27.308232836016486629201989612067060L }}, {{ 5.0L, 74.209948524787844444106108044487714L }}, {{ 6.0L, 201.71563612245589448340511285540955L }}, {{ 7.0L, 548.31703515521207688996412071210292L }}, {{ 8.0L, 1490.4791612521780886277154604210072L }}, {{ 9.0L, 4051.5420254925940471947730935347253L }}, {{ 10.L, 11013.232920103323139721376090437880L }}, {{ 11.L, 29937.070865949759622786072552446649L }}, {{ 12.L, 81377.395712574066580666707328584546L }}, {{ 13.L, 221206.69600559041636654191513743678L }}, {{ 14.L, 601302.14208280415323417016932596172L }}, {{ 15.L, 1.6345086862362082708111784359400464e6L }}, {{ 16.L, 4.4430552602539925859688714999479821e6L }}, {{ 17.L, 1.2077476376787669807076311516026210e7L }}, {{ 18.L, 3.2829984568665263184383123985844235e7L }}, {{ 19.L, 8.9241150481593633223853235662995122e7L }}, {{ 20.L, 2.4258259770489514001513022649004919e8L }},
  286. } };
  287. unary_proc = &std::cosh;
  288. #if __cplusplus >= 201103
  289. inv_unary_proc = &std::acosh;
  290. #endif
  291. do_test_std_function(cosh_data, "long double", "std::cosh", "Mathematica data", unary_proc, "std::acosh", inv_unary_proc);
  292. unary_proc = ::coshl;
  293. #if __cplusplus >= 201103
  294. inv_unary_proc = ::acoshl;
  295. #endif
  296. do_test_std_function(cosh_data, "long double", "::cosh", "Mathematica data", unary_proc, "::acosh", inv_unary_proc);
  297. //
  298. // Tanh:
  299. //
  300. boost::array<boost::array<long double, 2L>, 20L> tanh_data = { {
  301. {{ 2.0000000000000000000000000000000000L, 0.96402758007581688394641372410092315L }}, {{ 1.0000000000000000000000000000000000L, 0.76159415595576488811945828260479359L }}, {{ 0.66666666666666666666666666666666667L, 0.58278294534791012006763998724863620L }}, {{ 0.50000000000000000000000000000000000L, 0.46211715726000975850231848364367255L }}, {{ 0.40000000000000000000000000000000000L, 0.37994896225522488526774812389687331L }}, {{ 0.33333333333333333333333333333333333L, 0.32151273753163434471940622242520647L }}, {{ 0.28571428571428571428571428571428571L, 0.27818549032570244047180008724146611L }}, {{ 0.25000000000000000000000000000000000L, 0.24491866240370912927780113149101696L }}, {{ 0.22222222222222222222222222222222222L, 0.21863508368712133408473136585229335L }}, {{ 0.20000000000000000000000000000000000L, 0.19737532022490400073815731881101567L }}, {{ 0.18181818181818181818181818181818182L, 0.17984081852510791219962261245781186L }}, {{ 0.16666666666666666666666666666666667L, 0.16514041292462935373278922792245912L }}, {{ 0.15384615384615384615384615384615385L, 0.15264375981490485028417961210708858L }}, {{ 0.14285714285714285714285714285714286L, 0.14189319376693254602300070386766884L }}, {{ 0.13333333333333333333333333333333333L, 0.13254878839087838732054090217452509L }}, {{ 0.12500000000000000000000000000000000L, 0.12435300177159620805464727580589271L }}, {{ 0.11764705882352941176470588235294118L, 0.11710726941545656349019174731833940L }}, {{ 0.11111111111111111111111111111111111L, 0.11065611052473799138171921474515056L }}, {{ 0.10526315789473684210526315789473684L, 0.10487608974842188468874887218357955L }}, {{ 0.10000000000000000000000000000000000L, 0.099667994624955817118305083678352184L }}
  302. } };
  303. unary_proc = &std::tanh;
  304. #if __cplusplus >= 201103
  305. inv_unary_proc = &std::atanh;
  306. #endif
  307. do_test_std_function(tanh_data, "long double", "std::tanh", "Mathematica data", unary_proc, "std::atanh", inv_unary_proc);
  308. unary_proc = ::tanhl;
  309. #if __cplusplus >= 201103
  310. inv_unary_proc = ::atanhl;
  311. #endif
  312. do_test_std_function(tanh_data, "long double", "::tanh", "Mathematica data", unary_proc, "::atanh", inv_unary_proc);
  313. //
  314. // ABS, FABS:
  315. //
  316. boost::array<boost::array<long double, 2L>, 20L> abs_data = { {
  317. {{ -2.0000000000000000000000000000000000L, 2.0000000000000000000000000000000000L }}, {{ -1.0000000000000000000000000000000000L, 1.0000000000000000000000000000000000L }}, {{ -0.66666666666666666666666666666666667L, 0.66666666666666666666666666666666667L }}, {{ -0.50000000000000000000000000000000000L, 0.50000000000000000000000000000000000L }}, {{ -0.40000000000000000000000000000000000L, 0.40000000000000000000000000000000000L }}, {{ -0.33333333333333333333333333333333333L, 0.33333333333333333333333333333333333L }}, {{ -0.28571428571428571428571428571428571L, 0.28571428571428571428571428571428571L }}, {{ -0.25000000000000000000000000000000000L, 0.25000000000000000000000000000000000L }}, {{ -0.22222222222222222222222222222222222L, 0.22222222222222222222222222222222222L }}, {{ -0.20000000000000000000000000000000000L, 0.20000000000000000000000000000000000L }}, {{ -0.18181818181818181818181818181818182L, 0.18181818181818181818181818181818182L }}, {{ -0.16666666666666666666666666666666667L, 0.16666666666666666666666666666666667L }}, {{ -0.15384615384615384615384615384615385L, 0.15384615384615384615384615384615385L }}, {{ -0.14285714285714285714285714285714286L, 0.14285714285714285714285714285714286L }}, {{ -0.13333333333333333333333333333333333L, 0.13333333333333333333333333333333333L }}, {{ -0.12500000000000000000000000000000000L, 0.12500000000000000000000000000000000L }}, {{ -0.11764705882352941176470588235294118L, 0.11764705882352941176470588235294118L }}, {{ -0.11111111111111111111111111111111111L, 0.11111111111111111111111111111111111L }}, {{ -0.10526315789473684210526315789473684L, 0.10526315789473684210526315789473684L }}, {{ -0.10000000000000000000000000000000000L, 0.10000000000000000000000000000000000L }}
  318. } };
  319. unary_proc = &std::abs;
  320. inv_unary_proc = 0;
  321. do_test_std_function(abs_data, "long double", "std::abs", "Mathematica data", unary_proc, "std::abs", inv_unary_proc);
  322. unary_proc = &std::fabs;
  323. inv_unary_proc = 0;
  324. do_test_std_function(abs_data, "long double", "std::fabs", "Mathematica data", unary_proc, "std::abs", inv_unary_proc);
  325. unary_proc = ::fabsl;
  326. do_test_std_function(abs_data, "long double", "::fabs", "Mathematica data", unary_proc, "::abs", inv_unary_proc);
  327. }
  328. BOOST_AUTO_TEST_CASE( test_main )
  329. {
  330. expected_results();
  331. std::cout << "Running tests with BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS "
  332. #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  333. "defined."
  334. #else
  335. "not defined."
  336. #endif
  337. << std::endl;
  338. // Basic sanity-check spot values.
  339. // (Parameter value, arbitrarily zero, only communicates the floating point type).
  340. test_spots(); // Test long double.
  341. } // BOOST_AUTO_TEST_CASE( test_main )