Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/math/special_functions/sqrt1pm1.hpp @ 125:34e428693f5d vext
Vext -> Repoint
author | Chris Cannam |
---|---|
date | Thu, 14 Jun 2018 11:15:39 +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_SQRT1PM1 |
Chris@16 | 7 #define BOOST_MATH_SQRT1PM1 |
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 |
Chris@16 | 17 // |
Chris@16 | 18 // This algorithm computes sqrt(1+x)-1 for small x: |
Chris@16 | 19 // |
Chris@16 | 20 |
Chris@16 | 21 namespace boost{ namespace math{ |
Chris@16 | 22 |
Chris@16 | 23 template <class T, class Policy> |
Chris@16 | 24 inline typename tools::promote_args<T>::type sqrt1pm1(const T& val, const Policy& pol) |
Chris@16 | 25 { |
Chris@16 | 26 typedef typename tools::promote_args<T>::type result_type; |
Chris@16 | 27 BOOST_MATH_STD_USING |
Chris@16 | 28 |
Chris@16 | 29 if(fabs(result_type(val)) > 0.75) |
Chris@16 | 30 return sqrt(1 + result_type(val)) - 1; |
Chris@16 | 31 return boost::math::expm1(boost::math::log1p(val, pol) / 2, pol); |
Chris@16 | 32 } |
Chris@16 | 33 |
Chris@16 | 34 template <class T> |
Chris@16 | 35 inline typename tools::promote_args<T>::type sqrt1pm1(const T& val) |
Chris@16 | 36 { |
Chris@16 | 37 return sqrt1pm1(val, policies::policy<>()); |
Chris@16 | 38 } |
Chris@16 | 39 |
Chris@16 | 40 } // namespace math |
Chris@16 | 41 } // namespace boost |
Chris@16 | 42 |
Chris@16 | 43 #endif // BOOST_MATH_SQRT1PM1 |
Chris@16 | 44 |
Chris@16 | 45 |
Chris@16 | 46 |
Chris@16 | 47 |
Chris@16 | 48 |