/////////////////////////////////////////////////////////////////////////////// // Copyright 2014 Anton Bikineev // Copyright 2014 Christopher Kormanyos // Copyright 2014 John Maddock // Copyright 2014 Paul Bristow // Distributed under 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) #ifndef BOOST_MATH_HYPERGEOMETRIC_1F0_HPP #define BOOST_MATH_HYPERGEOMETRIC_1F0_HPP #include #include namespace boost { namespace math { namespace detail { template inline T hypergeometric_1F0_imp(const T& a, const T& z, const Policy& pol) { static const char* function = "boost::math::hypergeometric_1F0<%1%,%1%>(%1%, %1%)"; BOOST_MATH_STD_USING // pow if (z == 1) return policies::raise_pole_error( function, "Evaluation of 1F0 with z = %1%.", z, pol); if (1 - z < 0) { if (floor(a) != a) return policies::raise_domain_error(function, "Result is complex when a is non-integral and z > 1, but got z = %1%", z, pol); } // more naive and convergent method than series return pow(T(1 - z), T(-a)); } } // namespace detail template inline typename tools::promote_args::type hypergeometric_1F0(T1 a, T2 z, const Policy&) { BOOST_FPU_EXCEPTION_GUARD typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; typedef typename policies::normalise< Policy, policies::promote_float, policies::promote_double, policies::discrete_quantile<>, policies::assert_undefined<> >::type forwarding_policy; return policies::checked_narrowing_cast( detail::hypergeometric_1F0_imp( static_cast(a), static_cast(z), forwarding_policy()), "boost::math::hypergeometric_1F0<%1%>(%1%,%1%)"); } template inline typename tools::promote_args::type hypergeometric_1F0(T1 a, T2 z) { return hypergeometric_1F0(a, z, policies::policy<>()); } } } // namespace boost::math #endif // BOOST_MATH_HYPERGEOMETRIC_1F0_HPP