70 lines · plain
1 2///////////////////////////////////////////////////////////////////////////////3// Copyright 2014 Anton Bikineev4// Copyright 2014 Christopher Kormanyos5// Copyright 2014 John Maddock6// Copyright 2014 Paul Bristow7// Distributed under the Boost8// Software License, Version 1.0. (See accompanying file9// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)10 11#ifndef BOOST_MATH_HYPERGEOMETRIC_1F0_HPP12#define BOOST_MATH_HYPERGEOMETRIC_1F0_HPP13 14#include <boost/math/policies/policy.hpp>15#include <boost/math/policies/error_handling.hpp>16#include <boost/math/tools/promotion.hpp>17 18 19namespace boost { namespace math { namespace detail {20 21template <class T, class Policy>22inline T hypergeometric_1F0_imp(const T& a, const T& z, const Policy& pol)23{24 static const char* function = "boost::math::hypergeometric_1F0<%1%,%1%>(%1%, %1%)";25 BOOST_MATH_STD_USING // pow26 27 if (z == 1)28 return policies::raise_pole_error<T>(function, "Evaluation of 1F0 with z = %1%.", z, pol);29 if (1 - z < 0)30 {31 if (floor(a) != a)32 return policies::raise_domain_error<T>(function, "Result is complex when a is non-integral and z > 1, but got z = %1%", z, pol);33 }34 // more naive and convergent method than series35 return pow(T(1 - z), T(-a));36}37 38} // namespace detail39 40template <class T1, class T2, class Policy>41inline typename tools::promote_args<T1, T2>::type hypergeometric_1F0(T1 a, T2 z, const Policy&)42{43 BOOST_FPU_EXCEPTION_GUARD44 typedef typename tools::promote_args<T1, T2>::type result_type;45 typedef typename policies::evaluation<result_type, Policy>::type value_type;46 typedef typename policies::normalise<47 Policy,48 policies::promote_float<false>,49 policies::promote_double<false>,50 policies::discrete_quantile<>,51 policies::assert_undefined<> >::type forwarding_policy;52 return policies::checked_narrowing_cast<result_type, Policy>(53 detail::hypergeometric_1F0_imp<value_type>(54 static_cast<value_type>(a),55 static_cast<value_type>(z),56 forwarding_policy()),57 "boost::math::hypergeometric_1F0<%1%>(%1%,%1%)");58}59 60template <class T1, class T2>61inline typename tools::promote_args<T1, T2>::type hypergeometric_1F0(T1 a, T2 z)62{63 return hypergeometric_1F0(a, z, policies::policy<>());64}65 66 67 } } // namespace boost::math68 69#endif // BOOST_MATH_HYPERGEOMETRIC_1F0_HPP70