diff options
author | Joel Holdsworth <joel@airwebreathe.org.uk> | 2020-03-19 17:24:06 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-03-19 17:24:06 +0000 |
commit | 232f9040821db526d28b9d93aaeb45c907dbf06b (patch) | |
tree | ef6385880742496420cb4718e11d84baeacfed5f /Eigen/src/plugins/CommonCwiseUnaryOps.h | |
parent | 54aa8fa186e84bc6985f70f9aa43490709f345b7 (diff) |
Add shift_left<N> and shift_right<N> coefficient-wise unary Array functions
Diffstat (limited to 'Eigen/src/plugins/CommonCwiseUnaryOps.h')
-rw-r--r-- | Eigen/src/plugins/CommonCwiseUnaryOps.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Eigen/src/plugins/CommonCwiseUnaryOps.h b/Eigen/src/plugins/CommonCwiseUnaryOps.h index 5418dc415..42ff901ca 100644 --- a/Eigen/src/plugins/CommonCwiseUnaryOps.h +++ b/Eigen/src/plugins/CommonCwiseUnaryOps.h @@ -64,6 +64,49 @@ cast() const return typename CastXpr<NewType>::Type(derived()); } +template<int N> struct ShiftRightXpr { + typedef CwiseUnaryOp<internal::scalar_shift_right_op<Scalar, N>, const Derived> Type; +}; + +/// \returns an expression of \c *this with the \a Scalar type arithmetically +/// shifted right by \a N bit positions. +/// +/// The template parameter \a N specifies the number of bit positions to shift. +/// +EIGEN_DOC_UNARY_ADDONS(cast,conversion function) +/// +/// \sa class CwiseUnaryOp +/// +template<int N> +EIGEN_DEVICE_FUNC +typename ShiftRightXpr<N>::Type +shift_right() const +{ + return typename ShiftRightXpr<N>::Type(derived()); +} + + +template<int N> struct ShiftLeftXpr { + typedef CwiseUnaryOp<internal::scalar_shift_left_op<Scalar, N>, const Derived> Type; +}; + +/// \returns an expression of \c *this with the \a Scalar type logically +/// shifted left by \a N bit positions. +/// +/// The template parameter \a N specifies the number of bit positions to shift. +/// +EIGEN_DOC_UNARY_ADDONS(cast,conversion function) +/// +/// \sa class CwiseUnaryOp +/// +template<int N> +EIGEN_DEVICE_FUNC +typename ShiftLeftXpr<N>::Type +shift_left() const +{ + return typename ShiftLeftXpr<N>::Type(derived()); +} + /// \returns an expression of the complex conjugate of \c *this. /// EIGEN_DOC_UNARY_ADDONS(conjugate,complex conjugate) |