File indexing completed on 2025-01-18 09:40:23
0001
0002
0003
0004
0005
0006 #ifndef BOOST_MATH_SQRT1PM1
0007 #define BOOST_MATH_SQRT1PM1
0008
0009 #ifdef _MSC_VER
0010 #pragma once
0011 #endif
0012
0013 #include <boost/math/special_functions/math_fwd.hpp>
0014 #include <boost/math/special_functions/log1p.hpp>
0015 #include <boost/math/special_functions/expm1.hpp>
0016
0017
0018
0019
0020
0021 namespace boost{ namespace math{
0022
0023 template <class T, class Policy>
0024 inline typename tools::promote_args<T>::type sqrt1pm1(const T& val, const Policy& pol)
0025 {
0026 typedef typename tools::promote_args<T>::type result_type;
0027 BOOST_MATH_STD_USING
0028
0029 if(fabs(result_type(val)) > result_type(0.75))
0030 return sqrt(1 + result_type(val)) - 1;
0031 return boost::math::expm1(boost::math::log1p(val, pol) / 2, pol);
0032 }
0033
0034 template <class T>
0035 inline typename tools::promote_args<T>::type sqrt1pm1(const T& val)
0036 {
0037 return sqrt1pm1(val, policies::policy<>());
0038 }
0039
0040 }
0041 }
0042
0043 #endif
0044
0045
0046
0047
0048