mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Bit shifting functions
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
9700fc847a
commit
8e47971789
@@ -1746,6 +1746,23 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE double fmod(const double& a, const double&
|
||||
#undef SYCL_SPECIALIZE_BINARY_FUNC
|
||||
#endif
|
||||
|
||||
template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_left(const Scalar& a, int n) {
|
||||
return a << n;
|
||||
}
|
||||
|
||||
template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar logical_shift_right(const Scalar& a, int n) {
|
||||
using UnsignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::unsigned_type;
|
||||
return bit_cast<Scalar, UnsignedScalar>(bit_cast<UnsignedScalar, Scalar>(a) >> n);
|
||||
}
|
||||
|
||||
template <typename Scalar, typename Enable = std::enable_if_t<std::is_integral<Scalar>::value>>
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar arithmetic_shift_right(const Scalar& a, int n) {
|
||||
using SignedScalar = typename numext::get_integer_by_size<sizeof(Scalar)>::signed_type;
|
||||
return bit_cast<Scalar, SignedScalar>(bit_cast<SignedScalar, Scalar>(a) >> n);
|
||||
}
|
||||
|
||||
} // end namespace numext
|
||||
|
||||
namespace internal {
|
||||
|
||||
Reference in New Issue
Block a user