test_gamma.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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_gamma.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. ".*gmp_float<18>.*", // test type(s)
  21. ".*", // test data group
  22. "tgamma", 4000, 2500); // test function
  23. add_expected_result(
  24. ".*", // compiler
  25. ".*", // stdlib
  26. ".*", // platform
  27. ".*mpfr_float_backend<0>.*", // test type(s)
  28. "factorials", // test data group
  29. "tgamma", 400, 100); // test function
  30. add_expected_result(
  31. ".*", // compiler
  32. ".*", // stdlib
  33. ".*", // platform
  34. ".*", // test type(s)
  35. "factorials", // test data group
  36. "tgamma", 170, 70); // test function
  37. add_expected_result(
  38. ".*", // compiler
  39. ".*", // stdlib
  40. ".*", // platform
  41. ".*", // test type(s)
  42. "factorials", // test data group
  43. "lgamma", 750, 100); // test function
  44. #ifdef BOOST_INTEL
  45. add_expected_result(
  46. ".*", // compiler
  47. ".*", // stdlib
  48. ".*", // platform
  49. "float128", // test type(s)
  50. ".*near -.*", // test data group
  51. ".*", 150000L, 30000L); // test function
  52. #endif
  53. add_expected_result(
  54. ".*", // compiler
  55. ".*", // stdlib
  56. ".*", // platform
  57. ".*", // test type(s)
  58. "near.*", // test data group
  59. "tgamma", 250, 120); // test function
  60. add_expected_result(
  61. ".*", // compiler
  62. ".*", // stdlib
  63. ".*", // platform
  64. ".*", // test type(s)
  65. "near.*", // test data group
  66. "lgamma", 1400, 250); // test function
  67. add_expected_result(
  68. ".*", // compiler
  69. ".*", // stdlib
  70. ".*", // platform
  71. ".*", // test type(s)
  72. "tgamma1pm1.*", // test data group
  73. "tgamma1pm1", 1500, 400); // test function
  74. //
  75. // Finish off by printing out the compiler/stdlib/platform names,
  76. // we do this to make it easier to mark up expected error rates.
  77. //
  78. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  79. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  80. }
  81. template <class T>
  82. void test(T t, const char* p)
  83. {
  84. test_gamma(t, p);
  85. }
  86. BOOST_AUTO_TEST_CASE(test_main)
  87. {
  88. using namespace boost::multiprecision;
  89. expected_results();
  90. //
  91. // Test at:
  92. // 18 decimal digits: tests 80-bit long double approximations
  93. // 30 decimal digits: tests 128-bit long double approximations
  94. // 35 decimal digits: tests arbitrary precision code
  95. //
  96. ALL_TESTS
  97. }