test_bessel_k.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright Christopher Kormanyos 2002 - 2011.
  3. // Copyright 2011 John Maddock. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  6. //
  7. // This work is based on an earlier work:
  8. // "Algorithm 910: A Portable C++ Multiple-Precision System for Special-Function Calculations",
  9. // in ACM TOMS, {VOL 37, ISSUE 4, (February 2011)} (C) ACM, 2011. http://doi.acm.org/10.1145/1916461.1916469
  10. #include "setup.hpp"
  11. #include "table_type.hpp"
  12. #include <boost/math/special_functions/math_fwd.hpp>
  13. #include "libs/math/test/test_bessel_k.hpp"
  14. void expected_results()
  15. {
  16. //
  17. // Define the max and mean errors expected for
  18. // various compilers and platforms.
  19. //
  20. add_expected_result(
  21. ".*", // compiler
  22. ".*", // stdlib
  23. ".*", // platform
  24. ".*gmp.*", // test type(s)
  25. ".*", // test data group
  26. ".*", 2000, 1500); // test function
  27. #ifdef BOOST_INTEL
  28. add_expected_result(
  29. ".*", // compiler
  30. ".*", // stdlib
  31. ".*", // platform
  32. ".*float128.*", // test type(s)
  33. ".*", // test data group
  34. ".*", 300, 100); // test function
  35. #endif
  36. add_expected_result(
  37. ".*", // compiler
  38. ".*", // stdlib
  39. ".*", // platform
  40. ".*mpfr_float_backend<18>.*", // test type(s)
  41. ".*", // test data group
  42. ".*", 3000, 1000); // test function
  43. add_expected_result(
  44. ".*", // compiler
  45. ".*", // stdlib
  46. ".*", // platform
  47. ".*mpfr_float_backend<0>.*", // test type(s)
  48. ".*", // test data group
  49. ".*", 300, 150); // test function
  50. add_expected_result(
  51. ".*", // compiler
  52. ".*", // stdlib
  53. ".*", // platform
  54. ".*", // test type(s)
  55. ".*large.*", // test data group
  56. ".*", 80, 50); // test function
  57. add_expected_result(
  58. ".*", // compiler
  59. ".*", // stdlib
  60. ".*", // platform
  61. ".*cpp_bin_float.*", // test type(s)
  62. ".*", // test data group
  63. ".*", 300, 150); // test function
  64. add_expected_result(
  65. ".*", // compiler
  66. ".*", // stdlib
  67. ".*", // platform
  68. ".*", // test type(s)
  69. ".*", // test data group
  70. ".*", 50, 15); // test function
  71. //
  72. // Finish off by printing out the compiler/stdlib/platform names,
  73. // we do this to make it easier to mark up expected error rates.
  74. //
  75. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  76. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  77. }
  78. template <class T>
  79. void test(T t, const char* p)
  80. {
  81. test_bessel(t, p);
  82. }
  83. BOOST_AUTO_TEST_CASE(test_main)
  84. {
  85. using namespace boost::multiprecision;
  86. expected_results();
  87. //
  88. // Test at:
  89. // 18 decimal digits: tests 80-bit long double approximations
  90. // 30 decimal digits: tests 128-bit long double approximations
  91. // 35 decimal digits: tests arbitrary precision code
  92. //
  93. ALL_TESTS
  94. }