test_digamma.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. ///////////////////////////////////////////////////////////////
  2. // Copyright 2011 John Maddock. Distributed under the Boost
  3. // Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
  5. #include "setup.hpp"
  6. #include "table_type.hpp"
  7. #define TEST_UDT
  8. #include <boost/math/special_functions/math_fwd.hpp>
  9. #include "libs/math/test/test_digamma.hpp"
  10. void expected_results()
  11. {
  12. //
  13. // Define the max and mean errors expected for
  14. // various compilers and platforms.
  15. //
  16. add_expected_result(
  17. ".*", // compiler
  18. ".*", // stdlib
  19. ".*", // platform
  20. ".*mpfr_float_backend<18>.*", // test type(s)
  21. ".*Negative.*", // test data group
  22. ".*", 20000, 2000); // test function
  23. add_expected_result(
  24. ".*", // compiler
  25. ".*", // stdlib
  26. ".*", // platform
  27. ".*", // test type(s)
  28. ".*Negative.*", // test data group
  29. ".*", 550, 40); // test function
  30. add_expected_result(
  31. ".*", // compiler
  32. ".*", // stdlib
  33. ".*", // platform
  34. ".*cpp_dec_float.*", // test type(s)
  35. ".*Near the Positive Root.*", // test data group
  36. ".*", 2500, 200); // test function
  37. add_expected_result(
  38. ".*", // compiler
  39. ".*", // stdlib
  40. ".*", // platform
  41. ".*mpfr_float_backend<0>.*", // test type(s)
  42. ".*Near the Positive Root.*", // test data group
  43. ".*", 30000, 2000); // test function
  44. add_expected_result(
  45. ".*", // compiler
  46. ".*", // stdlib
  47. ".*", // platform
  48. ".*", // test type(s)
  49. ".*Near the Positive Root.*", // test data group
  50. ".*", 6000, 1000); // test function
  51. add_expected_result(
  52. ".*", // compiler
  53. ".*", // stdlib
  54. ".*", // platform
  55. ".*", // test type(s)
  56. ".*", // test data group
  57. ".*", 80, 30); // test function
  58. //
  59. // Finish off by printing out the compiler/stdlib/platform names,
  60. // we do this to make it easier to mark up expected error rates.
  61. //
  62. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  63. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  64. }
  65. template <class T>
  66. void test(T t, const char* p)
  67. {
  68. test_digamma(t, p);
  69. }
  70. BOOST_AUTO_TEST_CASE(test_main)
  71. {
  72. using namespace boost::multiprecision;
  73. expected_results();
  74. //
  75. // Test at:
  76. // 18 decimal digits: tests 80-bit long double approximations
  77. // 30 decimal digits: tests 128-bit long double approximations
  78. // 35 decimal digits: tests arbitrary precision code
  79. //
  80. ALL_TESTS
  81. }