test_polygamma.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // (C) Copyright John Maddock 2014.
  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_polygamma.hpp"
  7. //#include <boost/cstdfloat.hpp>
  8. void expected_results()
  9. {
  10. //
  11. // Define the max and mean errors expected for
  12. // various compilers and platforms.
  13. //
  14. const char* largest_type;
  15. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  16. if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  17. {
  18. largest_type = "(long\\s+)?double|real_concept";
  19. }
  20. else
  21. {
  22. largest_type = "long double|real_concept";
  23. }
  24. #else
  25. largest_type = "(long\\s+)?double|real_concept";
  26. #endif
  27. add_expected_result(
  28. ".*", // compiler
  29. ".*", // stdlib
  30. ".*", // platform
  31. largest_type, // test type(s)
  32. ".*large arguments", // test data group
  33. ".*", 400, 200); // test function
  34. add_expected_result(
  35. ".*", // compiler
  36. ".*", // stdlib
  37. ".*", // platform
  38. largest_type, // test type(s)
  39. ".*negative.*", // test data group
  40. ".*", 800, 500); // test function
  41. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  42. if((std::numeric_limits<long double>::digits > std::numeric_limits<double>::digits)
  43. && (std::numeric_limits<long double>::digits - std::numeric_limits<double>::digits < 20))
  44. {
  45. add_expected_result(
  46. ".*", // compiler
  47. ".*", // stdlib
  48. ".*", // platform
  49. "double", // test type(s)
  50. ".*bug cases.*", // test data group
  51. ".*", 100, 30); // test function
  52. }
  53. #endif
  54. add_expected_result(
  55. ".*", // compiler
  56. ".*", // stdlib
  57. ".*", // platform
  58. largest_type, // test type(s)
  59. ".*bug cases.*", // test data group
  60. ".*", 100000, 50000); // test function
  61. add_expected_result(
  62. ".*", // compiler
  63. ".*", // stdlib
  64. ".*", // platform
  65. largest_type, // test type(s)
  66. ".*", // test data group
  67. ".*", 40, 10); // test function
  68. //
  69. // Finish off by printing out the compiler/stdlib/platform names,
  70. // we do this to make it easier to mark up expected error rates.
  71. //
  72. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  73. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  74. }
  75. BOOST_AUTO_TEST_CASE( test_main )
  76. {
  77. expected_results();
  78. BOOST_MATH_CONTROL_FP;
  79. test_polygamma(0.0F, "float");
  80. test_polygamma(0.0, "double");
  81. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  82. test_polygamma(0.0L, "long double");
  83. test_polygamma(boost::math::concepts::real_concept(0.1), "real_concept");
  84. #endif
  85. #ifdef BOOST_FLOAT128_C
  86. //test_polygamma(BOOST_FLOAT128_C(0.0), "float128_t");
  87. #endif
  88. }