test_carlson.cpp 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. // Copyright 2006 John Maddock
  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_carlson.hpp"
  8. //
  9. // DESCRIPTION:
  10. // ~~~~~~~~~~~~
  11. //
  12. // This file tests the Carlson Elliptic Integrals.
  13. // There are two sets of tests, spot
  14. // tests which compare our results with the published test values,
  15. // in Numerical Computation of Real or Complex Elliptic Integrals,
  16. // B. C. Carlson: http://arxiv.org/abs/math.CA/9409227
  17. // However, 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. // real long doubles:
  53. //
  54. if(boost::math::policies::digits<long double, boost::math::policies::policy<> >() > 53)
  55. {
  56. add_expected_result(
  57. ".*", // compiler
  58. ".*", // stdlib
  59. BOOST_PLATFORM, // platform
  60. largest_type, // test type(s)
  61. ".*RJ.*", // test data group
  62. ".*", 1000, 50); // test function
  63. add_expected_result(
  64. ".*", // compiler
  65. ".*", // stdlib
  66. BOOST_PLATFORM, // platform
  67. "real_concept", // test type(s)
  68. ".*RJ.*", // test data group
  69. ".*", 1000, 50); // test function
  70. }
  71. //
  72. // Catch all cases come last:
  73. //
  74. add_expected_result(
  75. ".*", // compiler
  76. ".*", // stdlib
  77. ".*", // platform
  78. largest_type, // test type(s)
  79. ".*RJ.*", // test data group
  80. ".*", 250, 50); // test function
  81. add_expected_result(
  82. ".*", // compiler
  83. ".*", // stdlib
  84. ".*", // platform
  85. "real_concept", // test type(s)
  86. ".*RJ.*", // test data group
  87. ".*", 250, 50); // test function
  88. add_expected_result(
  89. ".*", // compiler
  90. ".*", // stdlib
  91. ".*", // platform
  92. largest_type, // test type(s)
  93. ".*", // test data group
  94. ".*", 25, 8); // test function
  95. add_expected_result(
  96. ".*", // compiler
  97. ".*", // stdlib
  98. ".*", // platform
  99. "real_concept", // test type(s)
  100. ".*", // test data group
  101. ".*", 25, 8); // test function
  102. //
  103. // Finish off by printing out the compiler/stdlib/platform names,
  104. // we do this to make it easier to mark up expected error rates.
  105. //
  106. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  107. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  108. }
  109. BOOST_AUTO_TEST_CASE( test_main )
  110. {
  111. expected_results();
  112. BOOST_MATH_CONTROL_FP;
  113. boost::math::ellint_rj(1.778e-31, 1.407e+18, 10.05, -4.83e-10);
  114. test_spots(0.0F, "float");
  115. test_spots(0.0, "double");
  116. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  117. test_spots(0.0L, "long double");
  118. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  119. test_spots(boost::math::concepts::real_concept(0), "real_concept");
  120. #endif
  121. #else
  122. std::cout << "<note>The long double tests have been disabled on this platform "
  123. "either because the long double overloads of the usual math functions are "
  124. "not available at all, or because they are too inaccurate for these tests "
  125. "to pass.</note>" << std::endl;
  126. #endif
  127. }
  128. /*
  129. test_carlson.cpp
  130. Linking...
  131. Embedding manifest...
  132. Autorun "i:\boost-06-05-03-1300\libs\math\test\Math_test\debug\test_carlson.exe"
  133. Running 1 test case...
  134. Tests run with Microsoft Visual C++ version 8.0, Dinkumware standard library version 405, Win32
  135. Testing: RF: Random data
  136. boost::math::ellint_rf<float> Max = 0 RMS Mean=0
  137. Testing: RC: Random data
  138. boost::math::ellint_rc<float> Max = 0 RMS Mean=0
  139. Testing: RJ: Random data
  140. boost::math::ellint_rf<float> Max = 0 RMS Mean=0
  141. Testing: RD: Random data
  142. boost::math::ellint_rd<float> Max = 0 RMS Mean=0
  143. Testing: RF: Random data
  144. boost::math::ellint_rf<double> Max = 2.949 RMS Mean=0.7498
  145. worst case at row: 377
  146. { 3.418e+025, 2.594e-005, 3.264e-012, 6.169e-012 }
  147. Testing: RC: Random data
  148. boost::math::ellint_rc<double> Max = 2.396 RMS Mean=0.6283
  149. worst case at row: 10
  150. { 1.97e-029, 3.224e-025, 2.753e+012 }
  151. Testing: RJ: Random data
  152. boost::math::ellint_rf<double> Max = 152.9 RMS Mean=11.15
  153. worst case at row: 633
  154. { 1.876e+016, 0.000278, 3.796e-006, -4.412e-005, -1.656e-005 }
  155. Testing: RD: Random data
  156. boost::math::ellint_rd<double> Max = 2.586 RMS Mean=0.8614
  157. worst case at row: 45
  158. { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
  159. Testing: RF: Random data
  160. boost::math::ellint_rf<long double> Max = 2.949 RMS Mean=0.7498
  161. worst case at row: 377
  162. { 3.418e+025, 2.594e-005, 3.264e-012, 6.169e-012 }
  163. Testing: RC: Random data
  164. boost::math::ellint_rc<long double> Max = 2.396 RMS Mean=0.6283
  165. worst case at row: 10
  166. { 1.97e-029, 3.224e-025, 2.753e+012 }
  167. Testing: RJ: Random data
  168. boost::math::ellint_rf<long double> Max = 152.9 RMS Mean=11.15
  169. worst case at row: 633
  170. { 1.876e+016, 0.000278, 3.796e-006, -4.412e-005, -1.656e-005 }
  171. Testing: RD: Random data
  172. boost::math::ellint_rd<long double> Max = 2.586 RMS Mean=0.8614
  173. worst case at row: 45
  174. { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
  175. Testing: RF: Random data
  176. boost::math::ellint_rf<real_concept> Max = 2.949 RMS Mean=0.7498
  177. worst case at row: 377
  178. { 3.418e+025, 2.594e-005, 3.264e-012, 6.169e-012 }
  179. Testing: RC: Random data
  180. boost::math::ellint_rc<real_concept> Max = 2.396 RMS Mean=0.6283
  181. worst case at row: 10
  182. { 1.97e-029, 3.224e-025, 2.753e+012 }
  183. Testing: RJ: Random data
  184. boost::math::ellint_rf<real_concept> Max = 152.9 RMS Mean=11.15
  185. worst case at row: 633
  186. { 1.876e+016, 0.000278, 3.796e-006, -4.412e-005, -1.656e-005 }
  187. Testing: RD: Random data
  188. boost::math::ellint_rd<real_concept> Max = 2.586 RMS Mean=0.8614
  189. worst case at row: 45
  190. { 2.111e-020, 8.757e-026, 1.923e-023, 1.004e+033 }
  191. *** No errors detected
  192. */