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)
6 #include <pch_light.hpp>
7 #include "test_tgamma_ratio.hpp"
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.
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
30 void expected_results()
33 // Define the max and mean errors expected for
34 // various compilers and platforms.
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<> >())
40 largest_type = "(long\\s+)?double";
44 largest_type = "long double";
47 largest_type = "(long\\s+)?double";
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):
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
64 // Linux AMD x86em64 has slightly higher rates:
69 "linux.*", // platform
70 largest_type, // test type(s)
71 "[^|]*", // test data group
72 "tgamma_ratio[^|]*", 300, 100); // test function
76 "linux.*", // platform
77 "real_concept", // test type(s)
78 "[^|]*", // test data group
79 "tgamma_ratio[^|]*", 300, 100); // test function
84 "Win32.*", // platform
85 largest_type, // test type(s)
86 "[^|]*", // test data group
87 "tgamma_ratio[^|]*", 300, 100); // test function
94 ".*Solaris.*", // platform
95 largest_type, // test type(s)
96 "[^|]*", // test data group
97 "tgamma_ratio[^|]*", 200, 100); // test function
99 // Catch all cases come last:
105 largest_type, // test type(s)
106 "[^|]*", // test data group
107 "tgamma_delta_ratio[^|]*", 30, 20); // test function
112 largest_type, // test type(s)
113 "[^|]*", // test data group
114 "tgamma_ratio[^|]*", 100, 50); // test function
119 "real_concept", // test type(s)
120 "[^|]*", // test data group
121 "tgamma_delta_ratio[^|]*", 50, 20); // test function
126 "real_concept", // test type(s)
127 "[^|]*", // test data group
128 "[^|]*", 250, 150); // test function
131 // Finish off by printing out the compiler/stdlib/platform names,
132 // we do this to make it easier to mark up expected error rates.
134 std::cout << "Tests run with " << BOOST_COMPILER << ", "
135 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
138 BOOST_AUTO_TEST_CASE( test_main )
140 BOOST_MATH_CONTROL_FP;
143 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
144 test_tgamma_ratio(0.1F, "float");
146 test_tgamma_ratio(0.1, "double");
147 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
148 test_tgamma_ratio(0.1L, "long double");
149 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
150 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
151 test_tgamma_ratio(boost::math::concepts::real_concept(0.1), "real_concept");
155 std::cout << "<note>The long double tests have been disabled on this platform "
156 "either because the long double overloads of the usual math functions are "
157 "not available at all, or because they are too inaccurate for these tests "
158 "to pass.</note>" << std::endl;
161 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
162 test_spots(0.1F, "float");
164 test_spots(0.1, "double");
165 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
166 test_spots(0.1L, "long double");
167 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
168 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
169 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
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;