powm1_sqrtp1m1_test.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 <boost/math/concepts/real_concept.hpp>
  7. #define BOOST_TEST_MAIN
  8. #include <boost/test/unit_test.hpp>
  9. #include <boost/test/tools/floating_point_comparison.hpp>
  10. #include <boost/math/special_functions/math_fwd.hpp>
  11. #include <boost/math/tools/test.hpp>
  12. #include "powm1_sqrtp1m1_test.hpp"
  13. //
  14. // DESCRIPTION:
  15. // ~~~~~~~~~~~~
  16. //
  17. // This file tests the functions powm1 and sqrt1pm1.
  18. // The accuracy tests
  19. // use values generated with NTL::RR at 1000-bit precision
  20. // and our generic versions of these functions.
  21. //
  22. // Note that when this file is first run on a new platform many of
  23. // these tests will fail: the default accuracy is 1 epsilon which
  24. // is too tight for most platforms. In this situation you will
  25. // need to cast a human eye over the error rates reported and make
  26. // a judgement as to whether they are acceptable. Either way please
  27. // report the results to the Boost mailing list. Acceptable rates of
  28. // error are marked up below as a series of regular expressions that
  29. // identify the compiler/stdlib/platform/data-type/test-data/test-function
  30. // along with the maximum expected peek and RMS mean errors for that
  31. // test.
  32. //
  33. void expected_results()
  34. {
  35. //
  36. // Define the max and mean errors expected for
  37. // various compilers and platforms.
  38. //
  39. add_expected_result(
  40. ".*", // compiler
  41. ".*", // stdlib
  42. ".*", // platform
  43. ".*", // test type(s)
  44. ".*", // test data group
  45. ".*", 5, 2); // test function
  46. //
  47. // Finish off by printing out the compiler/stdlib/platform names,
  48. // we do this to make it easier to mark up expected error rates.
  49. //
  50. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  51. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  52. }
  53. BOOST_AUTO_TEST_CASE( test_main )
  54. {
  55. expected_results();
  56. BOOST_MATH_CONTROL_FP;
  57. test_powm1_sqrtp1m1(1.0F, "float");
  58. test_powm1_sqrtp1m1(1.0, "double");
  59. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  60. test_powm1_sqrtp1m1(1.0L, "long double");
  61. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  62. test_powm1_sqrtp1m1(boost::math::concepts::real_concept(), "real_concept");
  63. #endif
  64. #else
  65. std::cout << "<note>The long double tests have been disabled on this platform "
  66. "either because the long double overloads of the usual math functions are "
  67. "not available at all, or because they are too inaccurate for these tests "
  68. "to pass.</note>" << std::endl;
  69. #endif
  70. }