test_bessel_y_prime.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. // Copyright (c) 2013 Anton Bikineev
  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. #include "pch_light.hpp"
  6. #include "test_bessel_y_prime.hpp"
  7. //
  8. // DESCRIPTION:
  9. // ~~~~~~~~~~~~
  10. //
  11. // This file tests the bessel Y functions derivatives. There are two sets of tests, spot
  12. // tests which compare our results with selected values computed
  13. // using the online special function calculator at
  14. // functions.wolfram.com, while the bulk of the accuracy tests
  15. // use values generated with Boost.Multiprecision at 50 precision
  16. // and our generic versions of these functions.
  17. //
  18. // Note that when this file is first run on a new platform many of
  19. // these tests will fail: the default accuracy is 1 epsilon which
  20. // is too tight for most platforms. In this situation you will
  21. // need to cast a human eye over the error rates reported and make
  22. // a judgement as to whether they are acceptable. Either way please
  23. // report the results to the Boost mailing list. Acceptable rates of
  24. // error are marked up below as a series of regular expressions that
  25. // identify the compiler/stdlib/platform/data-type/test-data/test-function
  26. // along with the maximum expected peek and RMS mean errors for that
  27. // test.
  28. //
  29. void expected_results()
  30. {
  31. //
  32. // Define the max and mean errors expected for
  33. // various compilers and platforms.
  34. //
  35. const char* largest_type;
  36. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  37. if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  38. {
  39. largest_type = "(long\\s+)?double|real_concept";
  40. }
  41. else
  42. {
  43. largest_type = "long double|real_concept";
  44. }
  45. #else
  46. largest_type = "(long\\s+)?double";
  47. #endif
  48. //
  49. // HP-UX and Solaris rates are very slightly higher:
  50. //
  51. add_expected_result(
  52. ".*", // compiler
  53. ".*", // stdlib
  54. "HP-UX|Sun Solaris", // platform
  55. largest_type, // test type(s)
  56. ".*(Y'[nv]|y').*Random.*", // test data group
  57. ".*", 150000, 30000); // test function
  58. add_expected_result(
  59. ".*", // compiler
  60. ".*", // stdlib
  61. "HP-UX|Sun Solaris", // platform
  62. largest_type, // test type(s)
  63. ".*Y'[01Nv].*", // test data group
  64. ".*", 1300, 500); // test function
  65. //
  66. // Tru64:
  67. //
  68. add_expected_result(
  69. ".*Tru64.*", // compiler
  70. ".*", // stdlib
  71. ".*", // platform
  72. largest_type, // test type(s)
  73. ".*(Y'[nv]|y').*Random.*", // test data group
  74. ".*", 30000, 30000); // test function
  75. add_expected_result(
  76. ".*Tru64.*", // compiler
  77. ".*", // stdlib
  78. ".*", // platform
  79. largest_type, // test type(s)
  80. ".*Y'[01Nv].*", // test data group
  81. ".*", 400, 200); // test function
  82. //
  83. // Mac OS X rates are very slightly higher:
  84. //
  85. add_expected_result(
  86. ".*", // compiler
  87. ".*", // stdlib
  88. "Mac OS", // platform
  89. largest_type, // test type(s)
  90. ".*(Y'[nv1]).*", // test data group
  91. ".*", 600000, 100000); // test function
  92. add_expected_result(
  93. ".*", // compiler
  94. ".*", // stdlib
  95. "Mac OS", // platform
  96. "long double|real_concept", // test type(s)
  97. ".*Y'[0].*", // test data group
  98. ".*", 1500, 1000); // test function
  99. //
  100. // Linux:
  101. //
  102. add_expected_result(
  103. ".*", // compiler
  104. ".*", // stdlib
  105. "linux", // platform
  106. largest_type, // test type(s)
  107. ".*Y'v.*Random.*", // test data group
  108. ".*", 400000, 200000); // test function
  109. add_expected_result(
  110. ".*", // compiler
  111. ".*", // stdlib
  112. "linux", // platform
  113. largest_type, // test type(s)
  114. ".*Y'[01v].*", // test data group
  115. ".*", 2000, 1000); // test function
  116. add_expected_result(
  117. ".*", // compiler
  118. ".*", // stdlib
  119. "linux", // platform
  120. largest_type, // test type(s)
  121. ".*Y'n.*", // test data group
  122. ".*", 30000, 30000); // test function
  123. //
  124. // MinGW:
  125. //
  126. add_expected_result(
  127. "GNU.*", // compiler
  128. ".*", // stdlib
  129. "Win32.*", // platform
  130. largest_type, // test type(s)
  131. ".*Y'v.*Random.*", // test data group
  132. ".*", 400000, 300000); // test function
  133. add_expected_result(
  134. "GNU.*", // compiler
  135. ".*", // stdlib
  136. "Win32.*", // platform
  137. largest_type, // test type(s)
  138. ".*Y'[01v].*", // test data group
  139. ".*", 2000, 1000); // test function
  140. add_expected_result(
  141. "GNU.*", // compiler
  142. ".*", // stdlib
  143. "Win32.*", // platform
  144. largest_type, // test type(s)
  145. ".*Y'n.*", // test data group
  146. ".*", 30000, 30000); // test function
  147. //
  148. // Solaris version of long double has it's own error rates,
  149. // again just a touch higher than msvc's 64-bit double:
  150. //
  151. add_expected_result(
  152. "GNU.*", // compiler
  153. ".*", // stdlib
  154. "Sun.*", // platform
  155. largest_type, // test type(s)
  156. "Y'[0N].*Mathworld.*", // test data group
  157. ".*", 2000, 2000); // test function
  158. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  159. if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
  160. && (std::numeric_limits<long double>::digits < 90))
  161. {
  162. // some errors spill over into type double as well:
  163. add_expected_result(
  164. ".*", // compiler
  165. ".*", // stdlib
  166. ".*", // platform
  167. "double", // test type(s)
  168. ".*Y'[Nn].*", // test data group
  169. ".*", 20, 20); // test function
  170. add_expected_result(
  171. ".*", // compiler
  172. ".*", // stdlib
  173. ".*", // platform
  174. "double", // test type(s)
  175. ".*Y'v.*", // test data group
  176. ".*", 200, 70); // test function
  177. }
  178. #endif
  179. //
  180. // defaults are based on MSVC-8 on Win32:
  181. //
  182. add_expected_result(
  183. ".*", // compiler
  184. ".*", // stdlib
  185. ".*", // platform
  186. "real_concept", // test type(s)
  187. ".*(Y'[nv]|y').*Random.*", // test data group
  188. ".*", 40000, 3000); // test function
  189. add_expected_result(
  190. ".*", // compiler
  191. ".*", // stdlib
  192. ".*", // platform
  193. largest_type, // test type(s)
  194. ".*(Y'[nv]|y').*Random.*", // test data group
  195. ".*", 40000, 3000); // test function
  196. //
  197. // Fallback for sun has to go after the general cases above:
  198. //
  199. add_expected_result(
  200. "GNU.*", // compiler
  201. ".*", // stdlib
  202. "Sun.*", // platform
  203. largest_type, // test type(s)
  204. "Y'[0N].*", // test data group
  205. ".*", 200, 200); // test function
  206. //
  207. // General fallback:
  208. //
  209. add_expected_result(
  210. ".*", // compiler
  211. ".*", // stdlib
  212. ".*", // platform
  213. largest_type, // test type(s)
  214. ".*", // test data group
  215. ".*", 700, 300); // test function
  216. //
  217. // One set of float tests has inexact input values, so there is a slight error:
  218. //
  219. add_expected_result(
  220. ".*", // compiler
  221. ".*", // stdlib
  222. ".*", // platform
  223. "float", // test type(s)
  224. "Y'v: Mathworld Data", // test data group
  225. ".*", 30, 20); // test function
  226. //
  227. // Finish off by printing out the compiler/stdlib/platform names,
  228. // we do this to make it easier to mark up expected error rates.
  229. //
  230. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  231. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  232. }
  233. BOOST_AUTO_TEST_CASE( test_main )
  234. {
  235. #ifdef TEST_GSL
  236. gsl_set_error_handler_off();
  237. #endif
  238. expected_results();
  239. BOOST_MATH_CONTROL_FP;
  240. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  241. test_bessel_prime(0.1F, "float");
  242. #endif
  243. test_bessel_prime(0.1, "double");
  244. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  245. test_bessel_prime(0.1L, "long double");
  246. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  247. test_bessel_prime(boost::math::concepts::real_concept(0.1), "real_concept");
  248. #endif
  249. #else
  250. std::cout << "<note>The long double tests have been disabled on this platform "
  251. "either because the long double overloads of the usual math functions are "
  252. "not available at all, or because they are too inaccurate for these tests "
  253. "to pass.</note>" << std::endl;
  254. #endif
  255. }