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