From 2fae4d7a775421487a4da1e1c0fef870644294bb Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Sat, 15 Jun 2024 20:02:28 +0000 Subject: [PATCH] Revert "fix scalar pselect" --- Eigen/src/Core/GenericPacketMath.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h index 8bf8f9035..e1347b985 100644 --- a/Eigen/src/Core/GenericPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -580,13 +580,21 @@ EIGEN_DEVICE_FUNC inline Packet pandnot(const Packet& a, const Packet& b) { } // In the general case, use bitwise select. -template +template struct pselect_impl { static EIGEN_DEVICE_FUNC inline Packet run(const Packet& mask, const Packet& a, const Packet& b) { return por(pand(a, mask), pandnot(b, mask)); } }; +// For scalars, use ternary select. +template +struct pselect_impl::value>> { + static EIGEN_DEVICE_FUNC inline Packet run(const Packet& mask, const Packet& a, const Packet& b) { + return numext::equal_strict(mask, Packet(0)) ? b : a; + } +}; + /** \internal \returns \a or \b for each field in packet according to \mask */ template EIGEN_DEVICE_FUNC inline Packet pselect(const Packet& mask, const Packet& a, const Packet& b) {