test_jacobi.cpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // Copyright John Maddock 2012
  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_jacobi.hpp>
  7. //
  8. // DESCRIPTION:
  9. // ~~~~~~~~~~~~
  10. //
  11. // This file tests the Jacobi Elliptic Functions.
  12. // 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. const char* largest_type;
  37. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  38. if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  39. {
  40. largest_type = "(long\\s+)?double|real_concept";
  41. }
  42. else
  43. {
  44. largest_type = "long double|real_concept";
  45. }
  46. #else
  47. largest_type = "(long\\s+)?double";
  48. #endif
  49. add_expected_result(
  50. ".*", // compiler
  51. ".*", // stdlib
  52. ".*", // platform
  53. largest_type, // test type(s)
  54. ".*Mathworld.*", // test data group
  55. ".*", 500, 250); // test function
  56. add_expected_result(
  57. ".*", // compiler
  58. ".*", // stdlib
  59. ".*", // platform
  60. largest_type, // test type(s)
  61. ".*Large Phi.*", // test data group
  62. ".*", 50000, 5000); // test function
  63. add_expected_result(
  64. ".*", // compiler
  65. ".*", // stdlib
  66. ".*", // platform
  67. largest_type, // test type(s)
  68. ".*near 1.*", // test data group
  69. ".*", 7000, 500); // test function
  70. if(std::numeric_limits<long double>::digits == 64)
  71. {
  72. //
  73. // Some errors spill over into double precision:
  74. //
  75. add_expected_result(
  76. ".*", // compiler
  77. ".*", // stdlib
  78. ".*", // platform
  79. "double", // test type(s)
  80. ".*Large Phi.*", // test data group
  81. ".*", 500, 50); // test function
  82. add_expected_result(
  83. ".*", // compiler
  84. ".*", // stdlib
  85. ".*", // platform
  86. "double", // test type(s)
  87. ".*near 1.*", // test data group
  88. ".*", 10, 5); // test function
  89. }
  90. //
  91. // Catch all cases come last:
  92. //
  93. add_expected_result(
  94. ".*", // compiler
  95. ".*", // stdlib
  96. ".*", // platform
  97. largest_type, // test type(s)
  98. ".*", // test data group
  99. ".*", 50, 20); // test function
  100. //
  101. // Finish off by printing out the compiler/stdlib/platform names,
  102. // we do this to make it easier to mark up expected error rates.
  103. //
  104. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  105. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  106. }
  107. BOOST_AUTO_TEST_CASE( test_main )
  108. {
  109. expected_results();
  110. BOOST_MATH_CONTROL_FP;
  111. test_spots(0.0F, "float");
  112. test_spots(0.0, "double");
  113. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  114. test_spots(0.0L, "long double");
  115. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  116. test_spots(boost::math::concepts::real_concept(0), "real_concept");
  117. #endif
  118. #else
  119. std::cout << "<note>The long double tests have been disabled on this platform "
  120. "either because the long double overloads of the usual math functions are "
  121. "not available at all, or because they are too inaccurate for these tests "
  122. "to pass.</note>" << std::endl;
  123. #endif
  124. }