test_hermite.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // Copyright John Maddock 2006, 2007
  2. // Copyright Paul A. Bristow 2007
  3. // Use, modification and distribution are subject to the
  4. // Boost Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include <pch_light.hpp>
  7. #include"test_hermite.hpp"
  8. //
  9. // DESCRIPTION:
  10. // ~~~~~~~~~~~~
  11. //
  12. // This file tests the Hermite polynomials.
  13. // There are two sets of tests, spot
  14. // tests which compare our results with selected values computed
  15. // using the online special function calculator at
  16. // functions.wolfram.com, while the bulk of the accuracy tests
  17. // use values generated with NTL::RR at 1000-bit precision
  18. // 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. //
  51. // Catch all cases come last:
  52. //
  53. add_expected_result(
  54. ".*", // compiler
  55. ".*", // stdlib
  56. ".*", // platform
  57. largest_type, // test type(s)
  58. ".*", // test data group
  59. "hermite", 10, 5); // test function
  60. add_expected_result(
  61. ".*", // compiler
  62. ".*", // stdlib
  63. ".*", // platform
  64. "real_concept", // test type(s)
  65. ".*", // test data group
  66. "hermite", 10, 5); // test function
  67. //
  68. // Finish off by printing out the compiler/stdlib/platform names,
  69. // we do this to make it easier to mark up expected error rates.
  70. //
  71. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  72. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  73. }
  74. BOOST_AUTO_TEST_CASE( test_main )
  75. {
  76. BOOST_MATH_CONTROL_FP;
  77. boost::math::hermite(51, 915.0);
  78. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  79. test_spots(0.0F, "float");
  80. #endif
  81. test_spots(0.0, "double");
  82. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  83. test_spots(0.0L, "long double");
  84. test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
  85. #endif
  86. expected_results();
  87. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  88. test_hermite(0.1F, "float");
  89. #endif
  90. test_hermite(0.1, "double");
  91. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  92. test_hermite(0.1L, "long double");
  93. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  94. test_hermite(boost::math::concepts::real_concept(0.1), "real_concept");
  95. #endif
  96. #else
  97. std::cout << "<note>The long double tests have been disabled on this platform "
  98. "either because the long double overloads of the usual math functions are "
  99. "not available at all, or because they are too inaccurate for these tests "
  100. "to pass.</note>" << std::endl;
  101. #endif
  102. }