// Copyright John Maddock 2006. // Copyright Paul A. Bristow 2007, 2009 // 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 #define BOOST_TEST_MAIN #include #include #include #include #include #include "functor.hpp" #include #include #include #include "handle_test_result.hpp" #include "table_type.hpp" #ifndef SC_ #define SC_(x) static_cast::type>(BOOST_JOIN(x, L)) #endif template T binomial_wrapper(T n, T k) { #ifdef BINOMIAL_FUNCTION_TO_TEST return BINOMIAL_FUNCTION_TO_TEST( boost::math::itrunc(n), boost::math::itrunc(k)); #else return boost::math::binomial_coefficient( boost::math::itrunc(n), boost::math::itrunc(k)); #endif } template void test_binomial(T, const char* type_name) { #if !(defined(ERROR_REPORTING_MODE) && !defined(BINOMIAL_FUNCTION_TO_TEST)) using namespace std; typedef T (*func_t)(T, T); #if defined(BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS) func_t f = &binomial_wrapper; #else func_t f = &binomial_wrapper; #endif #include "binomial_data.ipp" boost::math::tools::test_result result = boost::math::tools::test_hetero( binomial_data, bind_func(f, 0, 1), extract_result(2)); std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" "Test results for small arguments and type " << type_name << std::endl << std::endl; std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; handle_test_result(result, binomial_data[result.worst()], result.worst(), type_name, "binomial_coefficient", "Binomials: small arguments"); std::cout << std::endl; #include "binomial_large_data.ipp" result = boost::math::tools::test_hetero( binomial_large_data, bind_func(f, 0, 1), extract_result(2)); std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" "Test results for large arguments and type " << type_name << std::endl << std::endl; std::cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"; handle_test_result(result, binomial_large_data[result.worst()], result.worst(), type_name, "binomial_coefficient", "Binomials: large arguments"); std::cout << std::endl; #endif }