Skip to content

Commit 214d730

Browse files
committed
no message
1 parent 618889c commit 214d730

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ constexpr auto taylor_series_result(T x, const Array &coeffs) noexcept
2727
return result;
2828
}
2929

30+
template <typename Array>
31+
constexpr auto taylor_series_result(boost::decimal::decimal128 x, const Array &coeffs) noexcept
32+
{
33+
const std::size_t N = coeffs.size();
34+
35+
auto result = coeffs[N - 1];
36+
37+
auto my_own_fma =
38+
[](boost::decimal::decimal128 x, boost::decimal::decimal128 y, boost::decimal::decimal128 z)
39+
{
40+
return (x * y) + z;
41+
};
42+
43+
for (std::size_t i = N - 1; i-- > 0;)
44+
{
45+
result = my_own_fma(result, x, coeffs[i]);
46+
}
47+
48+
return result;
49+
}
50+
3051
} //namespace detail
3152
} //namespace decimal
3253
} //namespace boost

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ constexpr auto tgamma_impl(T x) noexcept
9999
z = z - nx;
100100
}
101101

102+
auto my_own_fma =
103+
[](T x, T y, T z)
104+
{
105+
return (x * y) + z;
106+
};
107+
102108
result = detail::tgamma_series_expansion(z);
103-
result = one / (z * fma(result, z, one));
109+
result = one / (z * my_own_fma(result, z, one));
104110

105111
if (x_is_gt_one)
106112
{

0 commit comments

Comments
 (0)