]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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) | |
92f5a8d4 TL |
5 | #if defined(__GNUC__) |
6 | #pragma GCC diagnostic push | |
7 | #pragma GCC diagnostic ignored "-Wliteral-range" | |
8 | #endif | |
7c673cae FG |
9 | #include <pch_light.hpp> |
10 | #include "test_ibeta_derivative.hpp" | |
11 | ||
12 | #if !defined(TEST_FLOAT) && !defined(TEST_DOUBLE) && !defined(TEST_LDOUBLE) && !defined(TEST_REAL_CONCEPT) | |
13 | # define TEST_FLOAT | |
14 | # define TEST_DOUBLE | |
15 | # define TEST_LDOUBLE | |
16 | # define TEST_REAL_CONCEPT | |
17 | #endif | |
18 | ||
19 | // | |
20 | // DESCRIPTION: | |
21 | // ~~~~~~~~~~~~ | |
22 | // | |
92f5a8d4 | 23 | // This file tests the incomplete beta functions beta, |
7c673cae FG |
24 | // betac, ibeta and ibetac. There are two sets of tests, spot |
25 | // tests which compare our results with selected values computed | |
92f5a8d4 | 26 | // using the online special function calculator at |
7c673cae FG |
27 | // functions.wolfram.com, while the bulk of the accuracy tests |
28 | // use values generated with NTL::RR at 1000-bit precision | |
29 | // and our generic versions of these functions. | |
30 | // | |
31 | // Note that when this file is first run on a new platform many of | |
32 | // these tests will fail: the default accuracy is 1 epsilon which | |
92f5a8d4 | 33 | // is too tight for most platforms. In this situation you will |
7c673cae FG |
34 | // need to cast a human eye over the error rates reported and make |
35 | // a judgement as to whether they are acceptable. Either way please | |
36 | // report the results to the Boost mailing list. Acceptable rates of | |
37 | // error are marked up below as a series of regular expressions that | |
38 | // identify the compiler/stdlib/platform/data-type/test-data/test-function | |
39 | // along with the maximum expected peek and RMS mean errors for that | |
40 | // test. | |
41 | // | |
42 | ||
43 | void expected_results() | |
44 | { | |
45 | // | |
46 | // Define the max and mean errors expected for | |
47 | // various compilers and platforms. | |
48 | // | |
49 | const char* largest_type; | |
50 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
51 | if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >()) | |
52 | { | |
53 | largest_type = "(long\\s+)?double|real_concept"; | |
54 | } | |
55 | else | |
56 | { | |
57 | largest_type = "long double|real_concept"; | |
58 | } | |
59 | #else | |
60 | largest_type = "(long\\s+)?double"; | |
61 | #endif | |
62 | ||
63 | if(std::numeric_limits<long double>::max_exponent > std::numeric_limits<double>::max_exponent) | |
64 | { | |
65 | add_expected_result( | |
66 | "[^|]*", // compiler | |
67 | "[^|]*", // stdlib | |
68 | "[^|]*", // platform | |
69 | largest_type, // test type(s) | |
92f5a8d4 TL |
70 | "[^|]*Medium.*", // test data group |
71 | ".*", 200000, 7000); // test function | |
72 | add_expected_result( | |
73 | "[^|]*", // compiler | |
74 | "[^|]*", // stdlib | |
75 | "[^|]*", // platform | |
76 | "real_concept", // test type(s) | |
77 | "[^|]*Large.*", // test data group | |
78 | ".*", 300000, 10000); // test function | |
7c673cae FG |
79 | add_expected_result( |
80 | "[^|]*", // compiler | |
81 | "[^|]*", // stdlib | |
82 | "[^|]*", // platform | |
83 | largest_type, // test type(s) | |
92f5a8d4 TL |
84 | "[^|]*Large.*", // test data group |
85 | ".*", 80000, 5000); // test function | |
7c673cae FG |
86 | add_expected_result( |
87 | "[^|]*", // compiler | |
88 | "[^|]*", // stdlib | |
89 | "[^|]*", // platform | |
90 | largest_type, // test type(s) | |
92f5a8d4 TL |
91 | "[^|]*Integer.*", // test data group |
92 | ".*", 30000, 1500); // test function | |
7c673cae FG |
93 | add_expected_result( |
94 | "[^|]*", // compiler | |
95 | "[^|]*", // stdlib | |
96 | "[^|]*", // platform | |
92f5a8d4 | 97 | "double", // test type(s) |
7c673cae | 98 | "[^|]*Large.*", // test data group |
92f5a8d4 | 99 | ".*", 3300, 200); // test function |
7c673cae FG |
100 | add_expected_result( |
101 | "[^|]*", // compiler | |
102 | "[^|]*", // stdlib | |
103 | "[^|]*", // platform | |
92f5a8d4 TL |
104 | "double", // test type(s) |
105 | "[^|]*", // test data group | |
106 | ".*", 200, 50); // test function | |
7c673cae FG |
107 | } |
108 | ||
109 | // catch all default is 2eps for all types: | |
110 | add_expected_result( | |
111 | "[^|]*", // compiler | |
112 | "[^|]*", // stdlib | |
113 | "[^|]*", // platform | |
114 | "real_concept", // test type(s) | |
115 | "[^|]*large.*", // test data group | |
92f5a8d4 | 116 | ".*", 200000, 6000); // test function |
7c673cae FG |
117 | add_expected_result( |
118 | "[^|]*", // compiler | |
119 | "[^|]*", // stdlib | |
120 | "[^|]*", // platform | |
121 | largest_type, // test type(s) | |
122 | "[^|]*large.*", // test data group | |
92f5a8d4 | 123 | ".*", 3300, 200); // test function |
7c673cae FG |
124 | add_expected_result( |
125 | "[^|]*", // compiler | |
126 | "[^|]*", // stdlib | |
127 | "[^|]*", // platform | |
128 | largest_type, // test type(s) | |
129 | "[^|]*", // test data group | |
130 | ".*", 300, 100); // test function | |
131 | // | |
132 | // Finish off by printing out the compiler/stdlib/platform names, | |
133 | // we do this to make it easier to mark up expected error rates. | |
134 | // | |
92f5a8d4 | 135 | std::cout << "Tests run with " << BOOST_COMPILER << ", " |
7c673cae FG |
136 | << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; |
137 | } | |
138 | ||
139 | BOOST_AUTO_TEST_CASE( test_main ) | |
140 | { | |
141 | expected_results(); | |
142 | BOOST_MATH_CONTROL_FP; | |
143 | #ifdef TEST_GSL | |
144 | gsl_set_error_handler_off(); | |
145 | #endif | |
146 | #ifdef TEST_FLOAT | |
147 | test_spots(0.0F); | |
148 | #endif | |
149 | #ifdef TEST_DOUBLE | |
150 | test_spots(0.0); | |
151 | #endif | |
152 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
153 | #ifdef TEST_LDOUBLE | |
154 | test_spots(0.0L); | |
155 | #endif | |
156 | #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) | |
157 | #ifdef TEST_REAL_CONCEPT | |
158 | test_spots(boost::math::concepts::real_concept(0.1)); | |
159 | #endif | |
160 | #endif | |
161 | #endif | |
162 | ||
163 | #ifdef TEST_FLOAT | |
164 | test_beta(0.1F, "float"); | |
165 | #endif | |
166 | #ifdef TEST_DOUBLE | |
167 | test_beta(0.1, "double"); | |
168 | #endif | |
169 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
170 | #ifdef TEST_LDOUBLE | |
171 | test_beta(0.1L, "long double"); | |
172 | #endif | |
173 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
174 | #ifdef TEST_REAL_CONCEPT | |
175 | test_beta(boost::math::concepts::real_concept(0.1), "real_concept"); | |
176 | #endif | |
177 | #endif | |
178 | #else | |
179 | std::cout << "<note>The long double tests have been disabled on this platform " | |
180 | "either because the long double overloads of the usual math functions are " | |
181 | "not available at all, or because they are too inaccurate for these tests " | |
182 | "to pass.</note>" << std::endl; | |
183 | #endif | |
7c673cae | 184 | |
92f5a8d4 TL |
185 | } |
186 | #if defined(__GNUC__) | |
187 | #pragma GCC diagnostic pop | |
188 | #endif |