1 // (C) Copyright John Maddock 2006.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_MATH_POWM1
7 #define BOOST_MATH_POWM1
13 #include <boost/math/special_functions/log1p.hpp>
14 #include <boost/math/special_functions/expm1.hpp>
15 #include <boost/math/special_functions/math_fwd.hpp>
16 #include <boost/assert.hpp>
18 namespace boost{ namespace math{ namespace detail{
20 template <class T, class Policy>
21 inline T powm1_imp(const T a, const T z, const Policy& pol)
25 if((fabs(a) < 1) || (fabs(z) < 1))
29 return boost::math::expm1(p, pol);
30 // otherwise fall though:
37 template <class T1, class T2>
38 inline typename tools::promote_args<T1, T2>::type
39 powm1(const T1 a, const T2 z)
41 typedef typename tools::promote_args<T1, T2>::type result_type;
42 return detail::powm1_imp(static_cast<result_type>(a), static_cast<result_type>(z), policies::policy<>());
45 template <class T1, class T2, class Policy>
46 inline typename tools::promote_args<T1, T2>::type
47 powm1(const T1 a, const T2 z, const Policy& pol)
49 typedef typename tools::promote_args<T1, T2>::type result_type;
50 return detail::powm1_imp(static_cast<result_type>(a), static_cast<result_type>(z), pol);
56 #endif // BOOST_MATH_POWM1