• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  (C) Copyright John Maddock 2007.
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 
8 #include "test_bessel_y.hpp"
9 
10 //
11 // DESCRIPTION:
12 // ~~~~~~~~~~~~
13 //
14 // This file tests the bessel Y function.  There are two sets of tests, spot
15 // tests which compare our results with selected values computed
16 // using the online special function calculator at
17 // functions.wolfram.com, while 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 
expected_results()33 void expected_results()
34 {
35    //
36    // Define the max and mean errors expected for
37    // various compilers and platforms.
38    //
39    const char* largest_type;
40 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
41    if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
42    {
43       largest_type = "(long\\s+)?double|real_concept";
44    }
45    else
46    {
47       largest_type = "long double|real_concept";
48    }
49 #else
50    largest_type = "(long\\s+)?double";
51 #endif
52 
53    //
54    // HP-UX and Solaris rates are very slightly higher:
55    //
56    add_expected_result(
57       ".*",                          // compiler
58       ".*",                          // stdlib
59       "HP-UX|Sun Solaris",                          // platform
60       largest_type,                // test type(s)
61       ".*(Y[nv]|y).*Random.*",           // test data group
62       ".*", 30000, 30000);             // test function
63    add_expected_result(
64       ".*",                          // compiler
65       ".*",                          // stdlib
66       "HP-UX|Sun Solaris",                          // platform
67       largest_type,                  // test type(s)
68       ".*Y[01Nv].*",           // test data group
69       ".*", 1300, 500);               // test function
70    //
71    // Tru64:
72    //
73    add_expected_result(
74       ".*Tru64.*",                          // compiler
75       ".*",                          // stdlib
76       ".*",                          // platform
77       largest_type,                // test type(s)
78       ".*(Y[nv]|y).*Random.*",           // test data group
79       ".*", 30000, 30000);             // test function
80    add_expected_result(
81       ".*Tru64.*",                          // compiler
82       ".*",                          // stdlib
83       ".*",                          // platform
84       largest_type,                      // test type(s)
85       ".*Y[01Nv].*",           // test data group
86       ".*", 400, 200);               // test function
87 
88    //
89    // Mac OS X rates are very slightly higher:
90    //
91    add_expected_result(
92       ".*",                          // compiler
93       ".*",                          // stdlib
94       "Mac OS",                          // platform
95       largest_type,                // test type(s)
96       ".*(Y[nv1]).*",           // test data group
97       ".*", 600000, 100000);             // test function
98    add_expected_result(
99       ".*",                          // compiler
100       ".*",                          // stdlib
101       "Mac OS",                          // platform
102       "long double|real_concept",        // test type(s)
103       ".*Y[0].*",           // test data group
104       ".*", 1200, 1000);               // test function
105 
106    //
107    // Linux:
108    //
109       add_expected_result(
110          ".*",                          // compiler
111          ".*",                          // stdlib
112          "linux",                          // platform
113          largest_type,                  // test type(s)
114          ".*Yv.*Random.*",              // test data group
115          ".*", 200000, 200000);         // test function
116       add_expected_result(
117          ".*",                          // compiler
118          ".*",                          // stdlib
119          "linux",                          // platform
120          largest_type,                  // test type(s)
121          ".*Y[01v].*",              // test data group
122          ".*", 2000, 1000);         // test function
123       add_expected_result(
124          ".*",                          // compiler
125          ".*",                          // stdlib
126          "linux",                          // platform
127          largest_type,                  // test type(s)
128          ".*Yn.*",              // test data group
129          ".*", 30000, 30000);         // test function
130    //
131    // MinGW:
132    //
133       add_expected_result(
134          "GNU.*",                          // compiler
135          ".*",                          // stdlib
136          "Win32.*",                          // platform
137          largest_type,                  // test type(s)
138          ".*Yv.*Random.*",              // test data group
139          ".*", 200000, 200000);         // test function
140       add_expected_result(
141          "GNU.*",                          // compiler
142          ".*",                          // stdlib
143          "Win32.*",                          // platform
144          largest_type,                  // test type(s)
145          ".*Y[01v].*",              // test data group
146          ".*", 2000, 1000);         // test function
147       add_expected_result(
148          "GNU.*",                          // compiler
149          ".*",                          // stdlib
150          "Win32.*",                          // platform
151          largest_type,                  // test type(s)
152          ".*Yn.*",              // test data group
153          ".*", 30000, 30000);         // test function
154    //
155    // Solaris version of long double has it's own error rates,
156    // again just a touch higher than msvc's 64-bit double:
157    //
158    add_expected_result(
159       "GNU.*",                          // compiler
160       ".*",                          // stdlib
161       "Sun.*",                          // platform
162       largest_type,                  // test type(s)
163       "Y[0N].*Mathworld.*",              // test data group
164       ".*", 2000, 2000);         // test function
165 
166 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
167    if((std::numeric_limits<double>::digits != std::numeric_limits<long double>::digits)
168       && (std::numeric_limits<long double>::digits < 90))
169    {
170       // some errors spill over into type double as well:
171       add_expected_result(
172          ".*",                          // compiler
173          ".*",                          // stdlib
174          ".*",                          // platform
175          "double",                      // test type(s)
176          ".*Y[Nn].*",              // test data group
177          ".*", 20, 20);         // test function
178       add_expected_result(
179          ".*",                          // compiler
180          ".*",                          // stdlib
181          ".*",                          // platform
182          "double",                      // test type(s)
183          ".*Yv.*",              // test data group
184          ".*", 80, 70);         // test function
185    }
186 #endif
187    //
188    // defaults are based on MSVC-8 on Win32:
189    //
190    add_expected_result(
191       ".*",                          // compiler
192       ".*",                          // stdlib
193       ".*",                          // platform
194       "real_concept",                // test type(s)
195       ".*(Y[nv]|y).*Random.*",           // test data group
196       ".*", 2000, 2000);             // test function
197    add_expected_result(
198       ".*",                          // compiler
199       ".*",                          // stdlib
200       ".*",                          // platform
201       largest_type,                  // test type(s)
202       ".*(Y[nv]|y).*Random.*",           // test data group
203       ".*", 1500, 1000);               // test function
204    //
205    // Fallback for sun has to go after the general cases above:
206    //
207    add_expected_result(
208       "GNU.*",                          // compiler
209       ".*",                          // stdlib
210       "Sun.*",                          // platform
211       largest_type,                  // test type(s)
212       "Y[0N].*",              // test data group
213       ".*", 200, 200);         // test function
214    //
215    // General fallback:
216    //
217    add_expected_result(
218       ".*",                          // compiler
219       ".*",                          // stdlib
220       ".*",                          // platform
221       largest_type,                  // test type(s)
222       ".*",                          // test data group
223       ".*", 80, 40);                 // test function
224    //
225    // One set of float tests has inexact input values, so there is a slight error:
226    //
227    add_expected_result(
228       ".*",                          // compiler
229       ".*",                          // stdlib
230       ".*",                          // platform
231       "float",                       // test type(s)
232       "Yv: Mathworld Data",    // test data group
233       ".*", 20, 20);                 // test function
234    //
235    // Finish off by printing out the compiler/stdlib/platform names,
236    // we do this to make it easier to mark up expected error rates.
237    //
238    std::cout << "Tests run with " << BOOST_COMPILER << ", "
239       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
240 }
241 
BOOST_AUTO_TEST_CASE(test_main)242 BOOST_AUTO_TEST_CASE( test_main )
243 {
244 #ifdef TEST_GSL
245    gsl_set_error_handler_off();
246 #endif
247    expected_results();
248    BOOST_MATH_CONTROL_FP;
249 
250 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
251    test_bessel(0.1F, "float");
252 #endif
253    test_bessel(0.1, "double");
254 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
255    test_bessel(0.1L, "long double");
256 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
257    test_bessel(boost::math::concepts::real_concept(0.1), "real_concept");
258 #endif
259 #else
260    std::cout << "<note>The long double tests have been disabled on this platform "
261       "either because the long double overloads of the usual math functions are "
262       "not available at all, or because they are too inaccurate for these tests "
263       "to pass.</note>" << std::endl;
264 #endif
265 }
266 
267 
268 
269 
270