Restore ABI compatibility for conj with 3.3, fix conflict with boost.

The boost library unfortunately specializes `conj` for various types and
assumes the original two-template-parameter version.  This changes
restores the second parameter.  This also restores ABI compatibility.

The specialization for `std::complex` is because `std::conj` is not
a device function. For custom complex scalar types, users should provide
their own `conj` implementation.

We may consider removing the unnecessary second parameter in the future - but
this will require modifying boost as well.

Fixes #2112.
This commit is contained in:
Antonio Sanchez 2021-05-06 19:49:49 -07:00 committed by Rasmus Munk Larsen
parent 0eba8a1fe3
commit c0eb5f89a4

View File

@ -260,16 +260,17 @@ struct conj_default_impl<Scalar,true>
}
};
template<typename Scalar> struct conj_impl : conj_default_impl<Scalar> {};
template<typename Scalar, bool IsComplex = NumTraits<Scalar>::IsComplex>
struct conj_impl : conj_default_impl<Scalar, IsComplex> {};
#if defined(EIGEN_GPU_COMPILE_PHASE)
template<typename T>
struct conj_impl<std::complex<T> >
struct conj_impl<std::complex<T>, true>
{
EIGEN_DEVICE_FUNC
static inline std::complex<T> run(const std::complex<T>& x)
{
return std::complex<T>(x.real(), -x.imag());
return std::complex<T>(numext::real(x), -numext::imag(x));
}
};
#endif