Fix MSVC complex sqrt and packetmath test.

MSVC incorrectly handles `inf` cases for `std::sqrt<std::complex<T>>`.
Here we replace it with a custom version (currently used on GPU).

Also fixed the `packetmath` test, which previously skipped several
corner cases since `CHECK_CWISE1` only tests the first `PacketSize`
elements.
This commit is contained in:
Antonio Sanchez
2021-01-07 09:39:05 -08:00
committed by Rasmus Munk Larsen
parent 8d9cfba799
commit f149e0ebc3
5 changed files with 84 additions and 47 deletions

View File

@@ -338,6 +338,22 @@ struct sqrt_impl
}
};
// Complex sqrt defined in MathFunctionsImpl.h.
template<typename T> std::complex<T> complex_sqrt(const std::complex<T>& a_x);
// MSVC incorrectly handles inf cases.
#if EIGEN_COMP_MSVC > 0
template<typename T>
struct sqrt_impl<std::complex<T> >
{
EIGEN_DEVICE_FUNC
static EIGEN_ALWAYS_INLINE std::complex<T> run(const std::complex<T>& x)
{
return complex_sqrt<T>(x);
}
};
#endif
template<typename Scalar>
struct sqrt_retval
{