Skip to content

Commit 30f16d3

Browse files
committed
Restore mistakenly removed promotions
1 parent 9ea4614 commit 30f16d3

File tree

4 files changed

+84
-6
lines changed

4 files changed

+84
-6
lines changed

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
namespace boost {
2222
namespace decimal {
2323

24-
BOOST_DECIMAL_EXPORT template <typename T>
25-
constexpr auto log(T x) noexcept
24+
namespace detail {
25+
26+
template <typename T>
27+
constexpr auto log_impl(T x) noexcept
2628
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
2729
{
2830
constexpr T zero { 0, 0 };
@@ -93,6 +95,29 @@ constexpr auto log(T x) noexcept
9395
return result;
9496
}
9597

98+
} //namespace detail
99+
100+
BOOST_DECIMAL_EXPORT template <typename T>
101+
constexpr auto log(T x) noexcept
102+
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
103+
{
104+
#if BOOST_DECIMAL_DEC_EVAL_METHOD == 0
105+
106+
using evaluation_type = T;
107+
108+
#elif BOOST_DECIMAL_DEC_EVAL_METHOD == 1
109+
110+
using evaluation_type = detail::promote_args_t<T, decimal64>;
111+
112+
#else // BOOST_DECIMAL_DEC_EVAL_METHOD == 2
113+
114+
using evaluation_type = detail::promote_args_t<T, decimal128>;
115+
116+
#endif
117+
118+
return static_cast<T>(detail::log_impl(static_cast<evaluation_type>(x)));
119+
}
120+
96121
} // namespace decimal
97122
} // namespace boost
98123

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ constexpr auto log10_impl(T x) noexcept
3434
// TODO(ckormanyos) Put in a basic check for pure powers of 10, resulting
3535
// in an exact result.
3636

37+
// Starting point: See implementation of log() and adapt to the following series.
38+
// Series[Log[10] Log[10, (1 + (z/2))/(1 - (z/2))], {z, 0, 17}]
39+
3740
return log(x) / numbers::ln10_v<T>;
3841
}
3942

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
namespace boost {
2222
namespace decimal {
2323

24-
BOOST_DECIMAL_EXPORT template <typename T>
25-
constexpr auto log1p(T x) noexcept
24+
namespace detail {
25+
26+
template <typename T>
27+
constexpr auto log1p_impl(T x) noexcept
2628
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
2729
{
2830
constexpr T one { 1, 0 };
@@ -64,6 +66,29 @@ constexpr auto log1p(T x) noexcept
6466
return result;
6567
}
6668

69+
} // namespace detail
70+
71+
BOOST_DECIMAL_EXPORT template <typename T>
72+
constexpr auto log1p(T x) noexcept
73+
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
74+
{
75+
#if BOOST_DECIMAL_DEC_EVAL_METHOD == 0
76+
77+
using evaluation_type = T;
78+
79+
#elif BOOST_DECIMAL_DEC_EVAL_METHOD == 1
80+
81+
using evaluation_type = detail::promote_args_t<T, decimal64>;
82+
83+
#else // BOOST_DECIMAL_DEC_EVAL_METHOD == 2
84+
85+
using evaluation_type = detail::promote_args_t<T, decimal128>;
86+
87+
#endif
88+
89+
return static_cast<T>(detail::log1p_impl(static_cast<evaluation_type>(x)));
90+
}
91+
6792
} // namespace decimal
6893
} // namespace boost
6994

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
namespace boost {
2222
namespace decimal {
2323

24-
BOOST_DECIMAL_EXPORT template <typename T>
25-
constexpr auto sinh(T x) noexcept
24+
namespace detail {
25+
26+
template <typename T>
27+
constexpr auto sinh_impl(T x) noexcept
2628
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
2729
{
2830
const auto fpc = fpclassify(x);
@@ -78,6 +80,29 @@ constexpr auto sinh(T x) noexcept
7880
return result;
7981
}
8082

83+
} // namespace detail
84+
85+
BOOST_DECIMAL_EXPORT template <typename T>
86+
constexpr auto sinh(T x) noexcept
87+
BOOST_DECIMAL_REQUIRES(detail::is_decimal_floating_point_v, T)
88+
{
89+
#if BOOST_DECIMAL_DEC_EVAL_METHOD == 0
90+
91+
using evaluation_type = T;
92+
93+
#elif BOOST_DECIMAL_DEC_EVAL_METHOD == 1
94+
95+
using evaluation_type = detail::promote_args_t<T, decimal64>;
96+
97+
#else // BOOST_DECIMAL_DEC_EVAL_METHOD == 2
98+
99+
using evaluation_type = detail::promote_args_t<T, decimal128>;
100+
101+
#endif
102+
103+
return static_cast<T>(detail::sinh_impl(static_cast<evaluation_type>(x)));
104+
}
105+
81106
} // namespace decimal
82107
} // namespace boost
83108

0 commit comments

Comments
 (0)