From 232f9040821db526d28b9d93aaeb45c907dbf06b Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 19 Mar 2020 17:24:06 +0000 Subject: Add shift_left and shift_right coefficient-wise unary Array functions --- Eigen/src/Core/GenericPacketMath.h | 41 ++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'Eigen/src/Core/GenericPacketMath.h') diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h index 146d34fb5..42d1eb077 100644 --- a/Eigen/src/Core/GenericPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -44,19 +44,20 @@ struct default_packet_traits enum { HasHalfPacket = 0, - HasAdd = 1, - HasSub = 1, - HasMul = 1, - HasNegate = 1, - HasAbs = 1, - HasArg = 0, - HasAbs2 = 1, - HasMin = 1, - HasMax = 1, - HasConj = 1, + HasAdd = 1, + HasSub = 1, + HasShift = 1, + HasMul = 1, + HasNegate = 1, + HasAbs = 1, + HasArg = 0, + HasAbs2 = 1, + HasMin = 1, + HasMax = 1, + HasConj = 1, HasSetLinear = 1, - HasBlend = 0, - HasReduxp = 1, + HasBlend = 0, + HasReduxp = 1, HasDiv = 0, HasSqrt = 0, @@ -230,17 +231,23 @@ EIGEN_DEVICE_FUNC inline std::complex ptrue(const std::complex EIGEN_DEVICE_FUNC inline Packet pnot(const Packet& a) { return pxor(ptrue(a), a);} -/** \internal \returns \a a shifted by N bits to the right */ +/** \internal \returns \a a logically shifted by N bits to the right */ template EIGEN_DEVICE_FUNC inline int -pshiftright(const int& a) { return a >> N; } +parithmetic_shift_right(const int& a) { return a >> N; } template EIGEN_DEVICE_FUNC inline long int -pshiftright(const long int& a) { return a >> N; } +parithmetic_shift_right(const long int& a) { return a >> N; } + +/** \internal \returns \a a arithmetically shifted by N bits to the right */ +template EIGEN_DEVICE_FUNC inline int +plogical_shift_right(const int& a) { return static_cast(static_cast(a) >> N); } +template EIGEN_DEVICE_FUNC inline long int +plogical_shift_right(const long int& a) { return static_cast(static_cast(a) >> N); } /** \internal \returns \a a shifted by N bits to the left */ template EIGEN_DEVICE_FUNC inline int -pshiftleft(const int& a) { return a << N; } +plogical_shift_left(const int& a) { return a << N; } template EIGEN_DEVICE_FUNC inline long int -pshiftleft(const long int& a) { return a << N; } +plogical_shift_left(const long int& a) { return a << N; } /** \internal \returns the significant and exponent of the underlying floating point numbers * See https://en.cppreference.com/w/cpp/numeric/math/frexp -- cgit v1.2.3