test_zeta.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. #ifndef BOOST_MATH_OVERFLOW_ERROR_POLICY
  7. # define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
  8. #endif
  9. #include "test_zeta.hpp"
  10. //
  11. // DESCRIPTION:
  12. // ~~~~~~~~~~~~
  13. //
  14. // This file tests the zeta function. There are two sets of tests:
  15. // 1) Sanity checks: comparison to test values created with the
  16. // online calculator at functions.wolfram.com
  17. // 2) Accuracy tests use values generated with NTL::RR at
  18. // 1000-bit precision and our generic versions of these functions.
  19. //
  20. // Note that when this file is first run on a new platform many of
  21. // these tests will fail: the default accuracy is 1 epsilon which
  22. // is too tight for most platforms. In this situation you will
  23. // need to cast a human eye over the error rates reported and make
  24. // a judgement as to whether they are acceptable. Either way please
  25. // report the results to the Boost mailing list. Acceptable rates of
  26. // error are marked up below as a series of regular expressions that
  27. // identify the compiler/stdlib/platform/data-type/test-data/test-function
  28. // along with the maximum expected peek and RMS mean errors for that
  29. // test.
  30. //
  31. void expected_results()
  32. {
  33. //
  34. // Define the max and mean errors expected for
  35. // various compilers and platforms.
  36. //
  37. const char* largest_type;
  38. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  39. if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  40. {
  41. largest_type = "(long\\s+)?double";
  42. }
  43. else
  44. {
  45. largest_type = "long double";
  46. }
  47. #else
  48. largest_type = "(long\\s+)?double";
  49. #endif
  50. add_expected_result(
  51. ".*", // compiler
  52. ".*", // stdlib
  53. ".*", // platform
  54. largest_type, // test type(s)
  55. ".*Random values less than 1", // test data group
  56. ".*", 1200, 500); // test function
  57. add_expected_result(
  58. ".*", // compiler
  59. ".*", // stdlib
  60. ".*", // platform
  61. "real_concept", // test type(s)
  62. ".*Random values less than 1", // test data group
  63. ".*", 1200, 500); // test function
  64. add_expected_result(
  65. ".*", // compiler
  66. ".*", // stdlib
  67. ".*", // platform
  68. largest_type, // test type(s)
  69. ".*Integer.*", // test data group
  70. ".*", 30, 15); // test function
  71. add_expected_result(
  72. ".*", // compiler
  73. ".*", // stdlib
  74. ".*", // platform
  75. largest_type, // test type(s)
  76. ".*", // test data group
  77. ".*", 3, 3); // test function
  78. add_expected_result(
  79. ".*", // compiler
  80. ".*", // stdlib
  81. ".*Solaris.*", // platform
  82. "real_concept", // test type(s)
  83. ".*", // test data group
  84. ".*", 60, 15); // test function
  85. add_expected_result(
  86. ".*", // compiler
  87. ".*", // stdlib
  88. ".*", // platform
  89. "real_concept", // test type(s)
  90. ".*", // test data group
  91. ".*", 40, 15); // test function
  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, "float");
  100. test_spots(0.0, "double");
  101. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  102. test_spots(0.0L, "long double");
  103. test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
  104. #else
  105. std::cout << "<note>The long double tests have been disabled on this platform "
  106. "either because the long double overloads of the usual math functions are "
  107. "not available at all, or because they are too inaccurate for these tests "
  108. "to pass.</note>" << std::endl;
  109. #endif
  110. test_zeta(0.1F, "float");
  111. test_zeta(0.1, "double");
  112. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  113. test_zeta(0.1L, "long double");
  114. test_zeta(boost::math::concepts::real_concept(0.1), "real_concept");
  115. #else
  116. std::cout << "<note>The long double tests have been disabled on this platform "
  117. "either because the long double overloads of the usual math functions are "
  118. "not available at all, or because they are too inaccurate for these tests "
  119. "to pass.</note>" << std::endl;
  120. #endif
  121. }