Add shift_left<N> and shift_right<N> coefficient-wise unary Array functions

This commit is contained in:
Joel Holdsworth
2020-03-19 17:24:06 +00:00
committed by Rasmus Munk Larsen
parent 54aa8fa186
commit 232f904082
9 changed files with 208 additions and 64 deletions

View File

@@ -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)