1 // Copyright John Maddock 2006.
2 // Copyright Paul A. Bristow 2010
3
4 // Use, modification and distribution are subject to the
5 // Boost Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8 #ifdef _MSC_VER
9 # pragma warning (disable : 4224)
10 #endif
11
12 #include <pch_light.hpp> // include /libs/math/src/
13 #include "test_cbrt.hpp"
14
15 #include <boost/math/special_functions/cbrt.hpp> // Added to avoid link failure missing cbrt variants.
16 // Assumes special functions library built rather than included?
17
18 //
19 // DESCRIPTION:
20 // ~~~~~~~~~~~~
21 //
22 // This file tests the function cbrt. The accuracy tests
23 // use values generated with NTL::RR at 1000-bit precision
24 // and our generic versions of these functions.
25 //
26 // Note that when this file is first run on a new platform many of
27 // these tests will fail: the default accuracy is 1 epsilon which
28 // is too tight for most platforms. In this situation you will
29 // need to cast a human eye over the error rates reported and make
30 // a judgement as to whether they are acceptable. Either way please
31 // report the results to the Boost mailing list. Acceptable rates of
32 // error are marked up below as a series of regular expressions that
33 // identify the compiler/stdlib/platform/data-type/test-data/test-function
34 // along with the maximum expected peek and RMS mean errors for that
35 // test.
36 //
37
expected_results()38 void expected_results()
39 {
40 //
41 // Define the max and mean errors expected for
42 // various compilers and platforms.
43 //
44 const char* largest_type;
45 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
46 if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
47 {
48 largest_type = "(long\\s+)?double|real_concept";
49 }
50 else
51 {
52 largest_type = "long double|real_concept";
53 }
54 #else
55 largest_type = "(long\\s+)?double|real_concept";
56 #endif
57 add_expected_result(
58 "Borland.*", // compiler
59 ".*", // stdlib
60 ".*", // platform
61 "long double", // test type(s)
62 ".*", // test data group
63 ".*", 10, 6); // test function
64 add_expected_result(
65 ".*", // compiler
66 ".*", // stdlib
67 ".*", // platform
68 largest_type, // test type(s)
69 ".*", // test data group
70 ".*", 2, 2); // test function
71 //
72 // Finish off by printing out the compiler/stdlib/platform names,
73 // we do this to make it easier to mark up expected error rates.
74 //
75 std::cout << "Tests run with " << BOOST_COMPILER << ", "
76 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
77 }
78
BOOST_AUTO_TEST_CASE(test_main)79 BOOST_AUTO_TEST_CASE( test_main )
80 {
81 expected_results();
82 BOOST_MATH_CONTROL_FP;
83 test_cbrt(0.1F, "float");
84 test_cbrt(0.1, "double");
85 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
86 test_cbrt(0.1L, "long double");
87 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
88 test_cbrt(boost::math::concepts::real_concept(0.1), "real_concept");
89 #endif
90 #endif
91 }
92
93