]>
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) | |
5 | ||
6 | #include <pch_light.hpp> | |
7 | #include "test_tgamma_ratio.hpp" | |
8 | ||
9 | // | |
10 | // DESCRIPTION: | |
11 | // ~~~~~~~~~~~~ | |
12 | // | |
13 | // This file tests the gamma ratio functions tgamma_ratio, | |
14 | // and tgamma_delta_ratio. The accuracy tests | |
15 | // use values generated with NTL::RR at 1000-bit precision | |
16 | // and our generic versions of these functions. | |
17 | // | |
18 | // Note that when this file is first run on a new platform many of | |
19 | // these tests will fail: the default accuracy is 1 epsilon which | |
20 | // is too tight for most platforms. In this situation you will | |
21 | // need to cast a human eye over the error rates reported and make | |
22 | // a judgement as to whether they are acceptable. Either way please | |
23 | // report the results to the Boost mailing list. Acceptable rates of | |
24 | // error are marked up below as a series of regular expressions that | |
25 | // identify the compiler/stdlib/platform/data-type/test-data/test-function | |
26 | // along with the maximum expected peek and RMS mean errors for that | |
27 | // test. | |
28 | // | |
29 | ||
30 | void expected_results() | |
31 | { | |
32 | // | |
33 | // Define the max and mean errors expected for | |
34 | // various compilers and platforms. | |
35 | // | |
36 | const char* largest_type; | |
37 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
38 | if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >()) | |
39 | { | |
40 | largest_type = "(long\\s+)?double"; | |
41 | } | |
42 | else | |
43 | { | |
44 | largest_type = "long double"; | |
45 | } | |
46 | #else | |
47 | largest_type = "(long\\s+)?double"; | |
48 | #endif | |
49 | // | |
50 | // HP-UX | |
51 | // This is a weird one, HP-UX and Mac OS X show up errors at float | |
52 | // precision, that don't show up on other platforms. | |
53 | // There appears to be some kind of rounding issue going on (not enough | |
54 | // precision in the input to get the answer right): | |
55 | // | |
56 | add_expected_result( | |
57 | "[^|]*", // compiler | |
58 | "[^|]*", // stdlib | |
59 | "HP-UX|Mac OS|linux|.*(bsd|BSD).*", // platform | |
60 | "float", // test type(s) | |
61 | "[^|]*", // test data group | |
62 | "tgamma_ratio[^|]*", 35, 8); // test function | |
63 | // | |
64 | // Linux AMD x86em64 has slightly higher rates: | |
65 | // | |
66 | add_expected_result( | |
67 | "[^|]*", // compiler | |
68 | "[^|]*", // stdlib | |
69 | "linux.*", // platform | |
70 | largest_type, // test type(s) | |
71 | "[^|]*", // test data group | |
72 | "tgamma_ratio[^|]*", 300, 100); // test function | |
73 | add_expected_result( | |
74 | "[^|]*", // compiler | |
75 | "[^|]*", // stdlib | |
76 | "linux.*", // platform | |
77 | "real_concept", // test type(s) | |
78 | "[^|]*", // test data group | |
79 | "tgamma_ratio[^|]*", 300, 100); // test function | |
80 | ||
81 | add_expected_result( | |
82 | "GNU.*", // compiler | |
83 | "[^|]*", // stdlib | |
84 | "Win32.*", // platform | |
85 | largest_type, // test type(s) | |
86 | "[^|]*", // test data group | |
87 | "tgamma_ratio[^|]*", 300, 100); // test function | |
88 | // | |
1e59de90 TL |
89 | // Cygwin |
90 | // | |
91 | add_expected_result( | |
92 | "GNU.*", // compiler | |
93 | "[^|]*", // stdlib | |
94 | "Cygwin*", // platform | |
95 | largest_type, // test type(s) | |
96 | "[^|]*", // test data group | |
97 | "tgamma_ratio[^|]*", 300, 100); // test function | |
98 | // | |
7c673cae FG |
99 | // Solaris: |
100 | // | |
101 | add_expected_result( | |
102 | "[^|]*", // compiler | |
103 | "[^|]*", // stdlib | |
104 | ".*Solaris.*", // platform | |
105 | largest_type, // test type(s) | |
106 | "[^|]*", // test data group | |
107 | "tgamma_ratio[^|]*", 200, 100); // test function | |
108 | // | |
109 | // Catch all cases come last: | |
110 | // | |
111 | add_expected_result( | |
112 | "[^|]*", // compiler | |
113 | "[^|]*", // stdlib | |
114 | "[^|]*", // platform | |
115 | largest_type, // test type(s) | |
116 | "[^|]*", // test data group | |
117 | "tgamma_delta_ratio[^|]*", 30, 20); // test function | |
118 | add_expected_result( | |
119 | "[^|]*", // compiler | |
120 | "[^|]*", // stdlib | |
121 | "[^|]*", // platform | |
122 | largest_type, // test type(s) | |
123 | "[^|]*", // test data group | |
124 | "tgamma_ratio[^|]*", 100, 50); // test function | |
125 | add_expected_result( | |
126 | "[^|]*", // compiler | |
127 | "[^|]*", // stdlib | |
128 | "[^|]*", // platform | |
129 | "real_concept", // test type(s) | |
130 | "[^|]*", // test data group | |
92f5a8d4 | 131 | "tgamma_delta_ratio[^|]*", 50, 20); // test function |
7c673cae FG |
132 | add_expected_result( |
133 | "[^|]*", // compiler | |
134 | "[^|]*", // stdlib | |
135 | "[^|]*", // platform | |
136 | "real_concept", // test type(s) | |
137 | "[^|]*", // test data group | |
138 | "[^|]*", 250, 150); // test function | |
139 | ||
140 | // | |
141 | // Finish off by printing out the compiler/stdlib/platform names, | |
142 | // we do this to make it easier to mark up expected error rates. | |
143 | // | |
144 | std::cout << "Tests run with " << BOOST_COMPILER << ", " | |
145 | << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; | |
146 | } | |
147 | ||
148 | BOOST_AUTO_TEST_CASE( test_main ) | |
149 | { | |
150 | BOOST_MATH_CONTROL_FP; | |
151 | expected_results(); | |
152 | ||
153 | #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS | |
154 | test_tgamma_ratio(0.1F, "float"); | |
155 | #endif | |
156 | test_tgamma_ratio(0.1, "double"); | |
157 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
158 | test_tgamma_ratio(0.1L, "long double"); | |
159 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
1e59de90 | 160 | #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582)) && !defined(BOOST_MATH_NO_REAL_CONCEPT_TESTS) |
7c673cae FG |
161 | test_tgamma_ratio(boost::math::concepts::real_concept(0.1), "real_concept"); |
162 | #endif | |
163 | #endif | |
164 | #else | |
165 | std::cout << "<note>The long double tests have been disabled on this platform " | |
166 | "either because the long double overloads of the usual math functions are " | |
167 | "not available at all, or because they are too inaccurate for these tests " | |
168 | "to pass.</note>" << std::endl; | |
169 | #endif | |
170 | ||
171 | #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS | |
172 | test_spots(0.1F, "float"); | |
173 | #endif | |
174 | test_spots(0.1, "double"); | |
175 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
176 | test_spots(0.1L, "long double"); | |
177 | #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS | |
20effc67 | 178 | #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582)) |
7c673cae FG |
179 | test_spots(boost::math::concepts::real_concept(0.1), "real_concept"); |
180 | #endif | |
181 | #endif | |
182 | #else | |
183 | std::cout << "<note>The long double tests have been disabled on this platform " | |
184 | "either because the long double overloads of the usual math functions are " | |
185 | "not available at all, or because they are too inaccurate for these tests " | |
186 | "to pass.</note>" << std::endl; | |
187 | #endif | |
188 | } | |
189 | ||
190 |