1 //  Copyright John Maddock 2014.
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_trig.hpp"
8 
9 //
10 // DESCRIPTION:
11 // ~~~~~~~~~~~~
12 //
13 // This file tests the functions sin_pi, cos_pi, with test data
14 // generated at high precision naively using sin(pi*x) rather than
15 // our routines.
16 //
17 
expected_results()18 void expected_results()
19 {
20    //
21    // Define the max and mean errors expected for
22    // various compilers and platforms.
23    //
24    const char* largest_type;
25 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
26    if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
27    {
28       largest_type = "(long\\s+)?double|real_concept";
29    }
30    else
31    {
32       largest_type = "long double|real_concept";
33    }
34 #else
35    largest_type = "(long\\s+)?double";
36 #endif
37    //
38    // On MacOS X erfc has much higher error levels than
39    // expected: given that the implementation is basically
40    // just a rational function evaluation combined with
41    // exponentiation, we conclude that exp and pow are less
42    // accurate on this platform, especially when the result
43    // is outside the range of a double.
44    //
45    add_expected_result(
46       ".*",                          // compiler
47       ".*",                          // stdlib
48       ".*",                          // platform
49       largest_type,                // test type(s)
50       ".*",                          // test data group
51       ".*", 2, 1);                   // test function
52 
53    //
54    // Finish off by printing out the compiler/stdlib/platform names,
55    // we do this to make it easier to mark up expected error rates.
56    //
57    std::cout << "Tests run with " << BOOST_COMPILER << ", "
58       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
59 }
60 
BOOST_AUTO_TEST_CASE(test_main)61 BOOST_AUTO_TEST_CASE( test_main )
62 {
63    BOOST_MATH_CONTROL_FP;
64    expected_results();
65 
66    test_trig(0.1F, "float");
67    test_trig(0.1, "double");
68 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
69    test_trig(0.1L, "long double");
70 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
71 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
72    test_trig(boost::math::concepts::real_concept(0.1), "real_concept");
73 #endif
74 #endif
75 #else
76    std::cout << "<note>The long double tests have been disabled on this platform "
77       "either because the long double overloads of the usual math functions are "
78       "not available at all, or because they are too inaccurate for these tests "
79       "to pass.</note>" << std::cout;
80 #endif
81 }
82 
83