Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
ckormanyos committed May 1, 2024
1 parent 618889c commit 214d730
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions include/boost/decimal/detail/cmath/impl/taylor_series_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@ constexpr auto taylor_series_result(T x, const Array &coeffs) noexcept
return result;
}

template <typename Array>
constexpr auto taylor_series_result(boost::decimal::decimal128 x, const Array &coeffs) noexcept
{
const std::size_t N = coeffs.size();

auto result = coeffs[N - 1];

auto my_own_fma =
[](boost::decimal::decimal128 x, boost::decimal::decimal128 y, boost::decimal::decimal128 z)
{
return (x * y) + z;
};

for (std::size_t i = N - 1; i-- > 0;)
{
result = my_own_fma(result, x, coeffs[i]);
}

return result;
}

} //namespace detail
} //namespace decimal
} //namespace boost
Expand Down
8 changes: 7 additions & 1 deletion include/boost/decimal/detail/cmath/tgamma.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,14 @@ constexpr auto tgamma_impl(T x) noexcept
z = z - nx;
}

auto my_own_fma =
[](T x, T y, T z)
{
return (x * y) + z;
};

result = detail::tgamma_series_expansion(z);
result = one / (z * fma(result, z, one));
result = one / (z * my_own_fma(result, z, one));

if (x_is_gt_one)
{
Expand Down

0 comments on commit 214d730

Please sign in to comment.