• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright (c) 2013 Anton Bikineev
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 
6 #include "pch_light.hpp"
7 #include "test_bessel_i_prime.hpp"
8 
9 //
10 // DESCRIPTION:
11 // ~~~~~~~~~~~~
12 //
13 // This file tests the bessel I functions derivatives.  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 Boost.Multiprecision at 50 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 
expected_results()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    //
53    // Mac OS has higher error rates, why?
54    //
55    add_expected_result(
56       ".*",                          // compiler
57       ".*",                          // stdlib
58       "Mac OS",                      // platform
59       largest_type,                  // test type(s)
60       ".*",                          // test data group
61       ".*", 3500, 1500);               // test function
62    //
63    // G++ on Linux, results vary a bit by processor type,
64    // on Itanium results are *much* better than listed here,
65    // but x86 appears to have much less accurate std::pow
66    // that throws off the results for tgamma(long double)
67    // which then impacts on the Bessel functions:
68    //
69    add_expected_result(
70       ".*",                          // compiler
71       ".*",                          // stdlib
72       "linux",                       // platform
73       largest_type,                  // test type(s)
74       ".*Random.*",                  // test data group
75       ".*", 600, 200);               // test function
76 
77    add_expected_result(
78       "GNU.*",                       // compiler
79       ".*",                          // stdlib
80       "Win32.*",                     // platform
81       largest_type,                  // test type(s)
82       ".*Random.*",                  // test data group
83       ".*", 500, 200);               // test function
84    add_expected_result(
85       "GNU.*",                       // compiler
86       ".*",                          // stdlib
87       "Win32.*",                     // platform
88       largest_type,                  // test type(s)
89       ".*",                          // test data group
90       ".*", 3500, 1000);                 // test function
91    add_expected_result(
92       ".*",                          // compiler
93       ".*",                          // stdlib
94       ".*",                          // platform
95       largest_type,                  // test type(s)
96       ".*I'v.*Mathworld.*",          // test data group
97       ".*", 4000, 2000);             // test function
98    add_expected_result(
99       ".*",                          // compiler
100       ".*",                          // stdlib
101       ".*Solaris.*",                 // platform
102       largest_type,                  // test type(s)
103       ".*",                          // test data group
104       ".*", 900, 300);               // test function
105    add_expected_result(
106       ".*",                          // compiler
107       ".*",                          // stdlib
108       ".*",                          // platform
109       largest_type,                  // test type(s)
110       ".*",                          // test data group
111       ".*", 40, 25);                 // test function
112    //
113    // Set error rates a little higher for real_concept -
114    // now that we use a series approximation for small z
115    // that relies on tgamma the error rates are a little
116    // higher only when a Lanczos approximation is not available.
117    // All other types are unaffected.
118    //
119    add_expected_result(
120       ".*",                          // compiler
121       ".*",                          // stdlib
122       ".*",                          // platform
123       "real_concept",                // test type(s)
124       ".*I'v.*Mathworld.*",          // test data group
125       ".*", 4000, 2000);             // test function
126    add_expected_result(
127       ".*",                          // compiler
128       ".*",                          // stdlib
129       ".*Solaris.*",                          // platform
130       "real_concept",                // test type(s)
131       ".*",                          // test data group
132       ".*", 800, 400);               // test function
133    add_expected_result(
134       ".*",                          // compiler
135       ".*",                          // stdlib
136       ".*",                          // platform
137       "real_concept",                // test type(s)
138       ".*",                          // test data group
139       ".*", 600, 200);               // test function
140    add_expected_result(
141       ".*",                          // compiler
142       ".*",                          // stdlib
143       ".*",                          // platform
144       "double",                      // test type(s)
145       ".*",                          // test data group
146       ".*", 2, 1);                   // test function
147    //
148    // Finish off by printing out the compiler/stdlib/platform names,
149    // we do this to make it easier to mark up expected error rates.
150    //
151    std::cout << "Tests run with " << BOOST_COMPILER << ", "
152       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
153 }
154 
BOOST_AUTO_TEST_CASE(test_main)155 BOOST_AUTO_TEST_CASE( test_main )
156 {
157 #ifdef TEST_GSL
158    gsl_set_error_handler_off();
159 #endif
160    expected_results();
161    BOOST_MATH_CONTROL_FP;
162 
163 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
164    test_bessel(0.1F, "float");
165 #endif
166    test_bessel(0.1, "double");
167 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
168    test_bessel(0.1L, "long double");
169 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
170    test_bessel(boost::math::concepts::real_concept(0.1), "real_concept");
171 #endif
172 #else
173    std::cout << "<note>The long double tests have been disabled on this platform "
174       "either because the long double overloads of the usual math functions are "
175       "not available at all, or because they are too inaccurate for these tests "
176       "to pass.</note>" << std::endl;
177 #endif
178 }
179 
180 
181 
182 
183