diff options
Diffstat (limited to 'src/boost/libs/math/test/test_trig.cpp')
-rw-r--r-- | src/boost/libs/math/test/test_trig.cpp | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/boost/libs/math/test/test_trig.cpp b/src/boost/libs/math/test/test_trig.cpp new file mode 100644 index 00000000..2ad1ad5e --- /dev/null +++ b/src/boost/libs/math/test/test_trig.cpp @@ -0,0 +1,82 @@ +// Copyright John Maddock 2014. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#include <pch_light.hpp> +#include "test_trig.hpp" + +// +// DESCRIPTION: +// ~~~~~~~~~~~~ +// +// This file tests the functions sin_pi, cos_pi, with test data +// generated at high precision naively using sin(pi*x) rather than +// our routines. +// + +void expected_results() +{ + // + // Define the max and mean errors expected for + // various compilers and platforms. + // + const char* largest_type; +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >()) + { + largest_type = "(long\\s+)?double|real_concept"; + } + else + { + largest_type = "long double|real_concept"; + } +#else + largest_type = "(long\\s+)?double"; +#endif + // + // On MacOS X erfc has much higher error levels than + // expected: given that the implementation is basically + // just a rational function evaluation combined with + // exponentiation, we conclude that exp and pow are less + // accurate on this platform, especially when the result + // is outside the range of a double. + // + add_expected_result( + ".*", // compiler + ".*", // stdlib + ".*", // platform + largest_type, // test type(s) + ".*", // test data group + ".*", 2, 1); // test function + + // + // Finish off by printing out the compiler/stdlib/platform names, + // we do this to make it easier to mark up expected error rates. + // + std::cout << "Tests run with " << BOOST_COMPILER << ", " + << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl; +} + +BOOST_AUTO_TEST_CASE( test_main ) +{ + BOOST_MATH_CONTROL_FP; + expected_results(); + + test_trig(0.1F, "float"); + test_trig(0.1, "double"); +#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS + test_trig(0.1L, "long double"); +#ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) + test_trig(boost::math::concepts::real_concept(0.1), "real_concept"); +#endif +#endif +#else + std::cout << "<note>The long double tests have been disabled on this platform " + "either because the long double overloads of the usual math functions are " + "not available at all, or because they are too inaccurate for these tests " + "to pass.</note>" << std::endl; +#endif +} + |