1 // unit test file sinc.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)
15 #include <boost/math/special_functions/sinc.hpp>
17 #define BOOST_TEST_MAIN
18 #include <boost/test/unit_test.hpp>
21 BOOST_TEST_CASE_TEMPLATE_FUNCTION(sinc_pi_test, T)
25 using ::std::numeric_limits;
27 using ::boost::math::sinc_pi;
30 BOOST_TEST_MESSAGE("Testing sinc_pi in the real domain for "
31 << string_type_name<T>::_() << ".");
33 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
34 (abs(sinc_pi<T>(static_cast<T>(0))-static_cast<T>(1)))
35 (numeric_limits<T>::epsilon()));
39 BOOST_TEST_CASE_TEMPLATE_FUNCTION(sinc_pi_complex_test, T)
44 using ::std::numeric_limits;
46 using ::boost::math::sinc_pi;
49 BOOST_TEST_MESSAGE("Testing sinc_pi in the complex domain for "
50 << string_type_name<T>::_() << ".");
52 BOOST_CHECK_PREDICATE(::std::less_equal<T>(),
53 (abs(sinc_pi<T>(::std::complex<T>(0, 1))-
54 ::std::complex<T>(sinh(static_cast<T>(1)))))
55 (numeric_limits<T>::epsilon()));
59 void sinc_pi_manual_check()
61 using ::boost::math::sinc_pi;
64 BOOST_TEST_MESSAGE(" ");
65 BOOST_TEST_MESSAGE("sinc_pi");
67 for (int i = 0; i <= 100; i++)
69 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
70 BOOST_TEST_MESSAGE( ::std::setw(15)
71 << sinc_pi<float>(static_cast<float>(i-50)/
72 static_cast<float>(50))
74 << sinc_pi<double>(static_cast<double>(i-50)/
75 static_cast<double>(50))
77 << sinc_pi<long double>(static_cast<long double>(i-50)/
78 static_cast<long double>(50)));
80 BOOST_TEST_MESSAGE( ::std::setw(15)
81 << sinc_pi<float>(static_cast<float>(i-50)/
82 static_cast<float>(50))
84 << sinc_pi<double>(static_cast<double>(i-50)/
85 static_cast<double>(50)));
89 BOOST_TEST_MESSAGE(" ");