test_beta.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. // Copyright John Maddock 2006.
  2. // Copyright Paul A. Bristow 2007, 2009
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include "pch_light.hpp"
  7. #include "test_beta.hpp"
  8. //
  9. // DESCRIPTION:
  10. // ~~~~~~~~~~~~
  11. //
  12. // This file tests the function beta. There are two sets of tests, spot
  13. // tests which compare our results with selected values computed
  14. // using the online special function calculator at
  15. // functions.wolfram.com, while the bulk of the accuracy tests
  16. // use values generated with NTL::RR at 1000-bit precision
  17. // and our generic versions of these functions.
  18. //
  19. // Note that when this file is first run on a new platform many of
  20. // these tests will fail: the default accuracy is 1 epsilon which
  21. // is too tight for most platforms. In this situation you will
  22. // need to cast a human eye over the error rates reported and make
  23. // a judgement as to whether they are acceptable. Either way please
  24. // report the results to the Boost mailing list. Acceptable rates of
  25. // error are marked up below as a series of regular expressions that
  26. // identify the compiler/stdlib/platform/data-type/test-data/test-function
  27. // along with the maximum expected peek and RMS mean errors for that
  28. // test.
  29. //
  30. void expected_results()
  31. {
  32. //
  33. // Define the max and mean errors expected for
  34. // various compilers and platforms.
  35. //
  36. #if LDBL_MANT_DIG == 106
  37. // Darwin:
  38. add_expected_result(
  39. ".*", // compiler
  40. ".*", // stdlib
  41. "Mac OS.*", // platform
  42. "(long\\s+)?double", // test type(s)
  43. "Beta Function: Medium.*", // test data group
  44. "beta", 200, 35); // test function
  45. #endif
  46. add_expected_result(
  47. ".*", // compiler
  48. ".*", // stdlib
  49. ".*", // platform
  50. "(long\\s+)?double", // test type(s)
  51. "Beta Function: Small.*", // test data group
  52. "beta", 8, 5); // test function
  53. add_expected_result(
  54. ".*", // compiler
  55. ".*", // stdlib
  56. ".*", // platform
  57. "(long\\s+)?double", // test type(s)
  58. "Beta Function: Medium.*", // test data group
  59. "beta", 160, 35); // test function
  60. add_expected_result(
  61. ".*", // compiler
  62. ".*", // stdlib
  63. ".*", // platform
  64. "(long\\s+)?double", // test type(s)
  65. "Beta Function: Divergent.*", // test data group
  66. "beta", 30, 6); // test function
  67. add_expected_result(
  68. ".*", // compiler
  69. ".*", // stdlib
  70. ".*", // platform
  71. "real_concept", // test type(s)
  72. "Beta Function: Small.*", // test data group
  73. "beta", 25, 15); // test function
  74. add_expected_result(
  75. ".*", // compiler
  76. ".*", // stdlib
  77. ".*", // platform
  78. "real_concept", // test type(s)
  79. "Beta Function: Medium.*", // test data group
  80. "beta", 150, 40); // test function
  81. add_expected_result(
  82. ".*", // compiler
  83. ".*", // stdlib
  84. ".*", // platform
  85. "real_concept", // test type(s)
  86. "Beta Function: Divergent.*", // test data group
  87. "beta", 30, 15); // test function
  88. //
  89. // Finish off by printing out the compiler/stdlib/platform names,
  90. // we do this to make it easier to mark up expected error rates.
  91. //
  92. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  93. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  94. }
  95. BOOST_AUTO_TEST_CASE( test_main )
  96. {
  97. expected_results();
  98. BOOST_MATH_CONTROL_FP;
  99. test_spots(0.0F);
  100. test_spots(0.0);
  101. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  102. test_spots(0.0L);
  103. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
  104. test_spots(boost::math::concepts::real_concept(0.1));
  105. #endif
  106. #else
  107. std::cout << "<note>The long double tests have been disabled on this platform "
  108. "either because the long double overloads of the usual math functions are "
  109. "not available at all, or because they are too inaccurate for these tests "
  110. "to pass.</note>" << std::endl;
  111. #endif
  112. test_beta(0.1F, "float");
  113. test_beta(0.1, "double");
  114. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  115. test_beta(0.1L, "long double");
  116. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  117. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
  118. test_beta(boost::math::concepts::real_concept(0.1), "real_concept");
  119. #endif
  120. #endif
  121. #else
  122. std::cout << "<note>The long double tests have been disabled on this platform "
  123. "either because the long double overloads of the usual math functions are "
  124. "not available at all, or because they are too inaccurate for these tests "
  125. "to pass.</note>" << std::endl;
  126. #endif
  127. }