1 // unit test file acosh.hpp for the special functions test suite
3 // (C) Copyright Hubert Holin 2003.
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
13 #define BOOST_TEST_MAiN
14 #include <boost/math/special_functions/acosh.hpp>
17 #include <boost/test/unit_test.hpp>
21 T acosh_error_evaluator(T x)
27 using ::std::numeric_limits;
29 using ::boost::math::acosh;
32 static T const epsilon = numeric_limits<float>::epsilon();
37 T absolute_error = abs(z-abs(x));
38 T relative_error = absolute_error*abs(sinh(x));
39 T scaled_error = relative_error/epsilon;
45 BOOST_TEST_CASE_TEMPLATE_FUNCTION(acosh_test, T)
47 BOOST_TEST_MESSAGE("Testing acosh in the real domain for "
48 << string_type_name<T>::_() << ".");
50 for (int i = 0; i <= 100; i++)
52 T x = static_cast<T>(i-50)/static_cast<T>(5);
54 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
55 (acosh_error_evaluator(x))
58 // special cases for bug report: https://svn.boost.org/trac/boost/ticket/5113
60 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
61 (acosh_error_evaluator(x))
64 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
65 (acosh_error_evaluator(x))
68 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
69 (acosh_error_evaluator(x))
72 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
73 (acosh_error_evaluator(x))
76 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
77 (acosh_error_evaluator(x))
82 if(std::numeric_limits<T>::has_infinity)
84 T inf = std::numeric_limits<T>::infinity();
85 boost::math::policies::policy<boost::math::policies::overflow_error<boost::math::policies::ignore_error> > pol;
86 BOOST_CHECK_EQUAL(boost::math::asinh(inf, pol), inf);
91 void acosh_manual_check()
93 BOOST_TEST_MESSAGE(" ");
94 BOOST_TEST_MESSAGE("acosh");
96 for (int i = 0; i <= 100; i++)
98 float xf = static_cast<float>(i-50)/static_cast<float>(5);
99 double xd = static_cast<double>(i-50)/static_cast<double>(5);
101 static_cast<long double>(i-50)/static_cast<long double>(5);
103 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
104 BOOST_TEST_MESSAGE( ::std::setw(15)
105 << acosh_error_evaluator(xf)
107 << acosh_error_evaluator(xd)
109 << acosh_error_evaluator(xl));
111 BOOST_TEST_MESSAGE( ::std::setw(15)
112 << acosh_error_evaluator(xf)
114 << acosh_error_evaluator(xd));
118 BOOST_TEST_MESSAGE(" ");