test_ibeta_inv_ab.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // (C) Copyright John Maddock 2006.
  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_ibeta_inv_ab.hpp"
  7. #if !defined(TEST_FLOAT) && !defined(TEST_DOUBLE) && !defined(TEST_LDOUBLE) && !defined(TEST_REAL_CONCEPT)
  8. # define TEST_FLOAT
  9. # define TEST_DOUBLE
  10. # define TEST_LDOUBLE
  11. # define TEST_REAL_CONCEPT
  12. #endif
  13. //
  14. // DESCRIPTION:
  15. // ~~~~~~~~~~~~
  16. //
  17. // This file tests the incomplete beta function inverses
  18. // ibeta_inva and ibetac_inva. There are three sets of tests:
  19. // 1) TODO!!!! Accuracy tests use values generated with NTL::RR at
  20. // 1000-bit precision and our generic versions of these functions.
  21. // 2) Round trip sanity checks, use the test data for the forward
  22. // functions, and verify that we can get (approximately) back
  23. // where we started.
  24. //
  25. // Note that when this file is first run on a new platform many of
  26. // these tests will fail: the default accuracy is 1 epsilon which
  27. // is too tight for most platforms. In this situation you will
  28. // need to cast a human eye over the error rates reported and make
  29. // a judgement as to whether they are acceptable. Either way please
  30. // report the results to the Boost mailing list. Acceptable rates of
  31. // error are marked up below as a series of regular expressions that
  32. // identify the compiler/stdlib/platform/data-type/test-data/test-function
  33. // along with the maximum expected peek and RMS mean errors for that
  34. // test.
  35. //
  36. void expected_results()
  37. {
  38. //
  39. // Define the max and mean errors expected for
  40. // various compilers and platforms.
  41. //
  42. const char* largest_type;
  43. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  44. if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  45. {
  46. largest_type = "(long\\s+)?double";
  47. }
  48. else
  49. {
  50. largest_type = "long double";
  51. }
  52. #else
  53. largest_type = "(long\\s+)?double";
  54. #endif
  55. //
  56. // Linux:
  57. //
  58. add_expected_result(
  59. ".*", // compiler
  60. ".*", // stdlib
  61. "linux", // platform
  62. largest_type, // test type(s)
  63. ".*", // test data group
  64. ".*", 3000, 500); // test function
  65. //
  66. // Catch all cases come last:
  67. //
  68. add_expected_result(
  69. ".*", // compiler
  70. ".*", // stdlib
  71. ".*", // platform
  72. largest_type, // test type(s)
  73. ".*", // test data group
  74. ".*", 500, 500); // test function
  75. add_expected_result(
  76. ".*", // compiler
  77. ".*", // stdlib
  78. ".*", // platform
  79. "float|double", // test type(s)
  80. ".*", // test data group
  81. ".*", 5, 3); // test function
  82. add_expected_result(
  83. ".*", // compiler
  84. ".*", // stdlib
  85. ".*", // platform
  86. "real_concept", // test type(s)
  87. ".*", // test data group
  88. ".*", 1000000, 500000); // test function
  89. //
  90. // Finish off by printing out the compiler/stdlib/platform names,
  91. // we do this to make it easier to mark up expected error rates.
  92. //
  93. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  94. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  95. }
  96. BOOST_AUTO_TEST_CASE( test_main )
  97. {
  98. expected_results();
  99. #ifdef TEST_GSL
  100. gsl_set_error_handler_off();
  101. #endif
  102. #ifdef TEST_FLOAT
  103. test_beta(0.1F, "float");
  104. #endif
  105. #ifdef TEST_DOUBLE
  106. test_beta(0.1, "double");
  107. #endif
  108. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  109. #ifdef TEST_LDOUBLE
  110. test_beta(0.1L, "long double");
  111. #endif
  112. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  113. #ifdef TEST_REAL_CONCEPT
  114. test_beta(boost::math::concepts::real_concept(0.1), "real_concept");
  115. #endif
  116. #endif
  117. #else
  118. std::cout << "<note>The long double tests have been disabled on this platform "
  119. "either because the long double overloads of the usual math functions are "
  120. "not available at all, or because they are too inaccurate for these tests "
  121. "to pass.</note>" << std::endl;
  122. #endif
  123. }