Skip to content

Commit 769c65d

Browse files
authored
Merge pull request #1385 from boostorg/1384
Potential proposal for 1384
2 parents e995162 + 07ddae7 commit 769c65d

16 files changed

Lines changed: 117 additions & 29 deletions

File tree

include/boost/decimal/cmath.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef BOOST_DECIMAL_CMATH_HPP
66
#define BOOST_DECIMAL_CMATH_HPP
77

8+
#include <boost/decimal/detail/fwd_log.hpp>
89
#include <boost/decimal/detail/promotion.hpp>
910
#include <boost/decimal/decimal32_t.hpp>
1011
#include <boost/decimal/decimal64_t.hpp>

include/boost/decimal/detail/cmath/acosh.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ constexpr auto acosh_impl(const T x) noexcept
7676
{
7777
// http://functions.wolfram.com/ElementaryFunctions/ArcCosh/06/01/06/01/0001/
7878
// approximation by laurent series in 1/x at 0+ order from -1 to 0
79-
result = log(x) + numbers::ln2_v<T>;
79+
result = ::boost::decimal::log(x) + numbers::ln2_v<T>;
8080
}
8181
else if (x < T { 15, -1 })
8282
{
@@ -85,12 +85,12 @@ constexpr auto acosh_impl(const T x) noexcept
8585

8686
const auto two_y = y + y;
8787

88-
result = log1p(y + sqrt((y * y) + two_y));
88+
result = ::boost::decimal::log1p(y + sqrt((y * y) + two_y));
8989
}
9090
else
9191
{
9292
// http://functions.wolfram.com/ElementaryFunctions/ArcCosh/02/
93-
return(log(x + sqrt((x * x) - one)));
93+
return(::boost::decimal::log(x + sqrt((x * x) - one)));
9494
}
9595
}
9696
else

include/boost/decimal/detail/cmath/asinh.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ constexpr auto asinh_impl(const T x) noexcept
5252
{
5353
// http://functions.wolfram.com/ElementaryFunctions/ArcSinh/06/01/06/01/0001/
5454
// approximation by laurent series in 1/x at 0+ order from -1 to 1
55-
result = numbers::ln2_v<T> + log(x) + one / (T { 4, 0 } * xsq);
55+
result = numbers::ln2_v<T> + ::boost::decimal::log(x) + one / (T { 4, 0 } * xsq);
5656
}
5757
else if(x >= T { 5 , -1 })
5858
{
5959
// http://functions.wolfram.com/ElementaryFunctions/ArcSinh/02/
60-
result = log(x + sqrt(xsq + one));
60+
result = ::boost::decimal::log(x + sqrt(xsq + one));
6161
}
6262
else if (x >= fourth_root_epsilon)
6363
{
6464
// As below, but rearranged to preserve digits:
65-
result = log1p(x + (sqrt(one + xsq) - one));
65+
result = ::boost::decimal::log1p(x + (sqrt(one + xsq) - one));
6666
}
6767
else
6868
{

include/boost/decimal/detail/cmath/atanh.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ constexpr auto atanh_impl(const T x) noexcept
6262

6363
if(xx < half)
6464
{
65-
result = (log1p(xx) - log1p(-xx)) / 2;
65+
result = (::boost::decimal::log1p(xx) - ::boost::decimal::log1p(-xx)) / 2;
6666
}
6767
else
6868
{
69-
result = (log((one + xx) / (one - xx)) / 2);
69+
result = (::boost::decimal::log((one + xx) / (one - xx)) / 2);
7070
}
7171
}
7272
else

include/boost/decimal/detail/cmath/impl/ellint_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ constexpr auto agm(T phi,
7777

7878
const T sp { sin(phi) };
7979

80-
Fpm = phi_is_pi_half ? std::numeric_limits<T>::quiet_NaN() : log((one + sp) / (one - sp)) / 2;
80+
Fpm = phi_is_pi_half ? std::numeric_limits<T>::quiet_NaN() : ::boost::decimal::log((one + sp) / (one - sp)) / 2;
8181

8282
if(has_e)
8383
{

include/boost/decimal/detail/cmath/lgamma.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ constexpr auto lgamma_impl(const T x) noexcept
8181

8282
const auto phase = sin(numbers::pi_v<T> * za);
8383

84-
result = log(numbers::pi_v<T>) - log(abs(phase)) - lgamma(za);
84+
result = ::boost::decimal::log(numbers::pi_v<T>) - ::boost::decimal::log(abs(phase)) - lgamma(za);
8585
}
8686
else
8787
{
@@ -97,11 +97,11 @@ constexpr auto lgamma_impl(const T x) noexcept
9797
// Perform the Taylor series expansion.
9898

9999
result = (x * fma(detail::lgamma_taylor_series_expansion(x), x, -numbers::egamma_v<T>))
100-
- log(x);
100+
- ::boost::decimal::log(x);
101101
}
102102
else if (x < T { asymp_cutoff })
103103
{
104-
result = log(tgamma(x));
104+
result = ::boost::decimal::log(tgamma(x));
105105
}
106106
else
107107
{
@@ -111,7 +111,7 @@ constexpr auto lgamma_impl(const T x) noexcept
111111

112112
constexpr T half { 5, -1 };
113113

114-
result = (((x - half) * (log(x)) - x)) + log(detail::tgamma_series_expansion_asymp(one / x));
114+
result = (((x - half) * (::boost::decimal::log(x)) - x)) + ::boost::decimal::log(detail::tgamma_series_expansion_asymp(one / x));
115115
}
116116
}
117117
}

include/boost/decimal/detail/cmath/log.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ constexpr auto log_impl(const T x) noexcept
5353
else if (x < one)
5454
{
5555
// Handle reflection.
56-
result = -log(one / x);
56+
result = -::boost::decimal::log(one / x);
5757
}
5858
else if(x > one)
5959
{
60-
// Use the implementation of log10 in order to compute the natural
60+
// Use the implementation of ::boost::decimal::log10 in order to compute the natural
6161
// logarithm. The base of the boost::decimal library is, in fact,
6262
// base-10. And so, somewhat uncommonly, the fastest and most accurate
6363
// logarithm in this system is log10 in base-10.

include/boost/decimal/detail/cmath/log10.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ constexpr auto log10_impl(const T x) noexcept
7979
if (x < one)
8080
{
8181
// Handle reflection.
82-
result = -log10(one / x);
82+
result = -::boost::decimal::log10(one / x);
8383
}
8484
else if(x > one)
8585
{

include/boost/decimal/detail/cmath/log1p.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ constexpr auto log1p_impl(const T x) noexcept
6161
{
6262
if (x > T { 5, -1 })
6363
{
64-
result = log(x + one);
64+
result = ::boost::decimal::log(x + one);
6565
}
6666
else
6767
{

include/boost/decimal/detail/cmath/log2.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ template <typename T>
2727
constexpr auto log2_impl(const T x) noexcept
2828
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
2929
{
30-
return log(x) / numbers::ln2_v<T>;
30+
return ::boost::decimal::log(x) / numbers::ln2_v<T>;
3131
}
3232

3333
} //namespace detail

0 commit comments

Comments
 (0)