test_ellint_1.cpp 3.4 KB

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