test_laguerre.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 "test_laguerre.hpp"
  7. //
  8. // DESCRIPTION:
  9. // ~~~~~~~~~~~~
  10. //
  11. // This file tests the Laguerre polynomials.
  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";
  41. }
  42. else
  43. {
  44. largest_type = "long double";
  45. }
  46. #else
  47. largest_type = "(long\\s+)?double";
  48. #endif
  49. //
  50. // Linux special cases, error rates seem to be much higer here
  51. // even though the implementation contains nothing but basic
  52. // arithmetic?
  53. //
  54. if((std::numeric_limits<long double>::digits <= 64)
  55. && (std::numeric_limits<long double>::digits != std::numeric_limits<double>::digits))
  56. {
  57. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  58. add_expected_result(
  59. ".*", // compiler
  60. ".*", // stdlib
  61. ".*", // platform
  62. "double", // test type(s)
  63. ".*", // test data group
  64. ".*", 10, 5); // test function
  65. #endif
  66. }
  67. add_expected_result(
  68. ".*", // compiler
  69. ".*", // stdlib
  70. "linux.*|Mac OS|Sun.*", // platform
  71. largest_type, // test type(s)
  72. ".*", // test data group
  73. ".*", 40000, 1000); // test function
  74. add_expected_result(
  75. ".*", // compiler
  76. ".*", // stdlib
  77. "linux.*|Mac OS|Sun.*", // platform
  78. "real_concept", // test type(s)
  79. ".*", // test data group
  80. ".*", 40000, 1000); // test function
  81. add_expected_result(
  82. "GNU.*", // compiler
  83. ".*", // stdlib
  84. "Win32.*", // platform
  85. largest_type, // test type(s)
  86. ".*", // test data group
  87. ".*", 40000, 1000); // test function
  88. add_expected_result(
  89. "GNU.*", // compiler
  90. ".*", // stdlib
  91. "Win32.*", // platform
  92. "real_concept", // test type(s)
  93. ".*", // test data group
  94. ".*", 40000, 1000); // test function
  95. add_expected_result(
  96. ".*", // compiler
  97. ".*", // stdlib
  98. "IBM Aix", // platform
  99. largest_type, // test type(s)
  100. ".*", // test data group
  101. ".*", 5000, 500); // test function
  102. add_expected_result(
  103. ".*", // compiler
  104. ".*", // stdlib
  105. "IBM Aix", // platform
  106. "real_concept", // test type(s)
  107. ".*", // test data group
  108. ".*", 5000, 500); // test function
  109. //
  110. // Catch all cases come last:
  111. //
  112. add_expected_result(
  113. ".*", // compiler
  114. ".*", // stdlib
  115. ".*", // platform
  116. largest_type, // test type(s)
  117. ".*", // test data group
  118. ".*", 4000, 500); // test function
  119. add_expected_result(
  120. ".*", // compiler
  121. ".*", // stdlib
  122. ".*", // platform
  123. "real_concept", // test type(s)
  124. ".*", // test data group
  125. ".*", 4000, 500); // test function
  126. //
  127. // Finish off by printing out the compiler/stdlib/platform names,
  128. // we do this to make it easier to mark up expected error rates.
  129. //
  130. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  131. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  132. }
  133. BOOST_AUTO_TEST_CASE( test_main )
  134. {
  135. BOOST_MATH_CONTROL_FP;
  136. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  137. test_spots(0.0F, "float");
  138. #endif
  139. test_spots(0.0, "double");
  140. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  141. test_spots(0.0L, "long double");
  142. test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
  143. #endif
  144. expected_results();
  145. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  146. test_laguerre(0.1F, "float");
  147. #endif
  148. test_laguerre(0.1, "double");
  149. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  150. test_laguerre(0.1L, "long double");
  151. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  152. test_laguerre(boost::math::concepts::real_concept(0.1), "real_concept");
  153. #endif
  154. #else
  155. std::cout << "<note>The long double tests have been disabled on this platform "
  156. "either because the long double overloads of the usual math functions are "
  157. "not available at all, or because they are too inaccurate for these tests "
  158. "to pass.</note>" << std::endl;
  159. #endif
  160. }