annotate DEPENDENCIES/generic/include/boost/math/special_functions/powm1.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 // (C) Copyright John Maddock 2006.
Chris@16 2 // Use, modification and distribution are subject to the
Chris@16 3 // Boost Software License, Version 1.0. (See accompanying file
Chris@16 4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5
Chris@16 6 #ifndef BOOST_MATH_POWM1
Chris@16 7 #define BOOST_MATH_POWM1
Chris@16 8
Chris@16 9 #ifdef _MSC_VER
Chris@16 10 #pragma once
Chris@16 11 #endif
Chris@16 12
Chris@101 13 #include <boost/math/special_functions/math_fwd.hpp>
Chris@16 14 #include <boost/math/special_functions/log1p.hpp>
Chris@16 15 #include <boost/math/special_functions/expm1.hpp>
Chris@16 16 #include <boost/assert.hpp>
Chris@16 17
Chris@16 18 namespace boost{ namespace math{ namespace detail{
Chris@16 19
Chris@16 20 template <class T, class Policy>
Chris@16 21 inline T powm1_imp(const T a, const T z, const Policy& pol)
Chris@16 22 {
Chris@16 23 BOOST_MATH_STD_USING
Chris@16 24
Chris@16 25 if((fabs(a) < 1) || (fabs(z) < 1))
Chris@16 26 {
Chris@16 27 T p = log(a) * z;
Chris@16 28 if(fabs(p) < 2)
Chris@16 29 return boost::math::expm1(p, pol);
Chris@16 30 // otherwise fall though:
Chris@16 31 }
Chris@16 32 return pow(a, z) - 1;
Chris@16 33 }
Chris@16 34
Chris@16 35 } // detail
Chris@16 36
Chris@16 37 template <class T1, class T2>
Chris@16 38 inline typename tools::promote_args<T1, T2>::type
Chris@16 39 powm1(const T1 a, const T2 z)
Chris@16 40 {
Chris@16 41 typedef typename tools::promote_args<T1, T2>::type result_type;
Chris@16 42 return detail::powm1_imp(static_cast<result_type>(a), static_cast<result_type>(z), policies::policy<>());
Chris@16 43 }
Chris@16 44
Chris@16 45 template <class T1, class T2, class Policy>
Chris@16 46 inline typename tools::promote_args<T1, T2>::type
Chris@16 47 powm1(const T1 a, const T2 z, const Policy& pol)
Chris@16 48 {
Chris@16 49 typedef typename tools::promote_args<T1, T2>::type result_type;
Chris@16 50 return detail::powm1_imp(static_cast<result_type>(a), static_cast<result_type>(z), pol);
Chris@16 51 }
Chris@16 52
Chris@16 53 } // namespace math
Chris@16 54 } // namespace boost
Chris@16 55
Chris@16 56 #endif // BOOST_MATH_POWM1
Chris@16 57
Chris@16 58
Chris@16 59
Chris@16 60
Chris@16 61