2 ///////////////////////////////////////////////////////////////////////////////
3 // Copyright 2014 Anton Bikineev
4 // Copyright 2014 Christopher Kormanyos
5 // Copyright 2014 John Maddock
6 // Copyright 2014 Paul Bristow
7 // Distributed under the Boost
8 // Software License, Version 1.0. (See accompanying file
9 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_MATH_HYPERGEOMETRIC_1F0_HPP
12 #define BOOST_MATH_HYPERGEOMETRIC_1F0_HPP
14 #include <boost/math/policies/policy.hpp>
15 #include <boost/math/policies/error_handling.hpp>
18 namespace boost { namespace math { namespace detail {
20 template <class T, class Policy>
21 inline T hypergeometric_1F0_imp(const T& a, const T& z, const Policy& pol)
23 static const char* function = "boost::math::hypergeometric_1F0<%1%,%1%>(%1%, %1%)";
24 BOOST_MATH_STD_USING // pow
27 return policies::raise_pole_error<T>(
29 "Evaluation of 1F0 with z = %1%.",
35 return policies::raise_domain_error<T>(function,
36 "Result is complex when a is non-integral and z > 1, but got z = %1%", z, pol);
38 // more naive and convergent method than series
39 return pow(T(1 - z), T(-a));
44 template <class T1, class T2, class Policy>
45 inline typename tools::promote_args<T1, T2>::type hypergeometric_1F0(T1 a, T2 z, const Policy&)
47 BOOST_FPU_EXCEPTION_GUARD
48 typedef typename tools::promote_args<T1, T2>::type result_type;
49 typedef typename policies::evaluation<result_type, Policy>::type value_type;
50 typedef typename policies::normalise<
52 policies::promote_float<false>,
53 policies::promote_double<false>,
54 policies::discrete_quantile<>,
55 policies::assert_undefined<> >::type forwarding_policy;
56 return policies::checked_narrowing_cast<result_type, Policy>(
57 detail::hypergeometric_1F0_imp<value_type>(
58 static_cast<value_type>(a),
59 static_cast<value_type>(z),
61 "boost::math::hypergeometric_1F0<%1%>(%1%,%1%)");
64 template <class T1, class T2>
65 inline typename tools::promote_args<T1, T2>::type hypergeometric_1F0(T1 a, T2 z)
67 return hypergeometric_1F0(a, z, policies::policy<>());
71 } } // namespace boost::math
73 #endif // BOOST_MATH_HYPERGEOMETRIC_1F0_HPP