Fix MSVC atan2 test.

This commit is contained in:
Antonio Sánchez 2023-02-14 18:30:58 +00:00 committed by Rasmus Munk Larsen
parent 2dfbf1b251
commit c15b386203

View File

@ -100,7 +100,18 @@ void binary_ops_test() {
[](const auto& x, const auto& y) { return std::pow(x, y); });
binary_op_test<Scalar>("atan2",
[](const auto& x, const auto& y) { return Eigen::atan2(x, y); },
[](const auto& x, const auto& y) { return std::atan2(x, y); });
[](const auto& x, const auto& y) {
auto t = std::atan2(x, y);
#if EIGEN_COMP_MSVC
// Work around MSVC return value on underflow.
// |atan(y/x)| is bounded above by |y/x|, so on underflow return y/x according to POSIX spec.
// MSVC otherwise returns denorm_min.
if (EIGEN_PREDICT_FALSE(std::abs(t) == std::numeric_limits<decltype(t)>::denorm_min())) {
return x/y;
}
#endif
return t;
});
}
template <typename Scalar>