Skip to content

Commit 64282d6

Browse files
committed
Tweaks to expm1 complex special case logic
1 parent ccc4050 commit 64282d6

File tree

1 file changed

+6
-6
lines changed
  • dpctl/tensor/libtensor/include/kernels/elementwise_functions

1 file changed

+6
-6
lines changed

dpctl/tensor/libtensor/include/kernels/elementwise_functions/expm1.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ template <typename argT, typename resT> struct Expm1Functor
8585
return in;
8686
}
8787
else {
88-
return (std::numeric_limits<realT>::infinity() *
89-
resT{std::cos(y), std::sin(y)} -
90-
realT(1));
88+
return (x * resT{std::cos(y), std::sin(y)});
9189
}
9290
}
9391
else {
9492
// negative infinity cases
9593
if (!std::isfinite(y)) {
96-
return resT{-1, 0};
94+
// copy sign of y to guarantee
95+
// conj(expm1(x)) == expm1(conj(x))
96+
return resT{realT(-1), std::copysign(realT(0), y)};
9797
}
9898
else {
99-
return (realT(0) * resT{std::cos(y), std::sin(y)} -
100-
realT(1));
99+
return resT{realT(-1),
100+
std::copysign(realT(0), std::sin(y))};
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)