test_binomial_coeff.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_binomial_coeff.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. ".*", 3000, 1500); // test function
  27. add_expected_result(
  28. ".*", // compiler
  29. ".*", // stdlib
  30. ".*", // platform
  31. ".*mpfr_float_backend<18>.*", // test type(s)
  32. ".*", // test data group
  33. ".*", 750, 150); // test function
  34. add_expected_result(
  35. ".*", // compiler
  36. ".*", // stdlib
  37. ".*", // platform
  38. ".*mpfr_float_backend<0>.*", // test type(s)
  39. ".*", // test data group
  40. ".*", 150, 100); // test function
  41. add_expected_result(
  42. ".*", // compiler
  43. ".*", // stdlib
  44. ".*", // platform
  45. ".*", // test type(s)
  46. ".*", // test data group
  47. ".*", 100, 20); // test function
  48. //
  49. // Finish off by printing out the compiler/stdlib/platform names,
  50. // we do this to make it easier to mark up expected error rates.
  51. //
  52. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  53. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  54. }
  55. template <class T>
  56. void test(T t, const char* p)
  57. {
  58. test_binomial(t, p);
  59. }
  60. BOOST_AUTO_TEST_CASE(test_main)
  61. {
  62. using namespace boost::multiprecision;
  63. expected_results();
  64. //
  65. // Test at:
  66. // 18 decimal digits: tests 80-bit long double approximations
  67. // 30 decimal digits: tests 128-bit long double approximations
  68. // 35 decimal digits: tests arbitrary precision code
  69. //
  70. ALL_TESTS
  71. }