Skip to content

Commit

Permalink
Complex log1p return value is properly initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
ndgrigorian committed May 30, 2023
1 parent 909d894 commit 190e5d3
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ template <typename argT, typename resT> struct Log1pFunctor
// imaginary part of result
const realT res_im = std::atan2(y, x + 1);

if (std::max(std::abs(x), std::abs(y)) < realT(.1)) {
if (std::max(std::abs(x), std::abs(y)) < realT{.1}) {
const realT v = x * (2 + x) + y * y;
return {std::log1p(v) / 2, res_im};
return resT{std::log1p(v) / 2, res_im};
}
else {
// when not close to zero,
// prevent overflow
const realT m = std::hypot(x + 1, y);
return {std::log(m), res_im};
return resT{std::log(m), res_im};
}
}
else {
Expand Down

0 comments on commit 190e5d3

Please sign in to comment.