diff options
Diffstat (limited to 'Eigen/src/Core/Reverse.h')
-rw-r--r-- | Eigen/src/Core/Reverse.h | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h index 0640cda2a..28cdd76ac 100644 --- a/Eigen/src/Core/Reverse.h +++ b/Eigen/src/Core/Reverse.h @@ -12,7 +12,7 @@ #ifndef EIGEN_REVERSE_H #define EIGEN_REVERSE_H -namespace Eigen { +namespace Eigen { namespace internal { @@ -44,7 +44,7 @@ template<typename PacketType> struct reverse_packet_cond<PacketType,false> static inline PacketType run(const PacketType& x) { return x; } }; -} // end namespace internal +} // end namespace internal /** \class Reverse * \ingroup Core_Module @@ -89,8 +89,10 @@ template<typename MatrixType, int Direction> class Reverse EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Reverse) - EIGEN_DEVICE_FUNC inline Index rows() const { return m_matrix.rows(); } - EIGEN_DEVICE_FUNC inline Index cols() const { return m_matrix.cols(); } + EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR + inline Index rows() const EIGEN_NOEXCEPT { return m_matrix.rows(); } + EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR + inline Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); } EIGEN_DEVICE_FUNC inline Index innerStride() const { @@ -98,7 +100,7 @@ template<typename MatrixType, int Direction> class Reverse } EIGEN_DEVICE_FUNC const typename internal::remove_all<typename MatrixType::Nested>::type& - nestedExpression() const + nestedExpression() const { return m_matrix; } @@ -114,7 +116,7 @@ template<typename MatrixType, int Direction> class Reverse * */ template<typename Derived> -inline typename DenseBase<Derived>::ReverseReturnType +EIGEN_DEVICE_FUNC inline typename DenseBase<Derived>::ReverseReturnType DenseBase<Derived>::reverse() { return ReverseReturnType(derived()); @@ -136,7 +138,7 @@ DenseBase<Derived>::reverse() * * \sa VectorwiseOp::reverseInPlace(), reverse() */ template<typename Derived> -inline void DenseBase<Derived>::reverseInPlace() +EIGEN_DEVICE_FUNC inline void DenseBase<Derived>::reverseInPlace() { if(cols()>rows()) { @@ -161,7 +163,7 @@ inline void DenseBase<Derived>::reverseInPlace() } namespace internal { - + template<int Direction> struct vectorwise_reverse_inplace_impl; @@ -171,8 +173,10 @@ struct vectorwise_reverse_inplace_impl<Vertical> template<typename ExpressionType> static void run(ExpressionType &xpr) { + const int HalfAtCompileTime = ExpressionType::RowsAtCompileTime==Dynamic?Dynamic:ExpressionType::RowsAtCompileTime/2; Index half = xpr.rows()/2; - xpr.topRows(half).swap(xpr.bottomRows(half).colwise().reverse()); + xpr.topRows(fix<HalfAtCompileTime>(half)) + .swap(xpr.bottomRows(fix<HalfAtCompileTime>(half)).colwise().reverse()); } }; @@ -182,8 +186,10 @@ struct vectorwise_reverse_inplace_impl<Horizontal> template<typename ExpressionType> static void run(ExpressionType &xpr) { + const int HalfAtCompileTime = ExpressionType::ColsAtCompileTime==Dynamic?Dynamic:ExpressionType::ColsAtCompileTime/2; Index half = xpr.cols()/2; - xpr.leftCols(half).swap(xpr.rightCols(half).rowwise().reverse()); + xpr.leftCols(fix<HalfAtCompileTime>(half)) + .swap(xpr.rightCols(fix<HalfAtCompileTime>(half)).rowwise().reverse()); } }; @@ -201,9 +207,9 @@ struct vectorwise_reverse_inplace_impl<Horizontal> * * \sa DenseBase::reverseInPlace(), reverse() */ template<typename ExpressionType, int Direction> -void VectorwiseOp<ExpressionType,Direction>::reverseInPlace() +EIGEN_DEVICE_FUNC void VectorwiseOp<ExpressionType,Direction>::reverseInPlace() { - internal::vectorwise_reverse_inplace_impl<Direction>::run(_expression().const_cast_derived()); + internal::vectorwise_reverse_inplace_impl<Direction>::run(m_matrix); } } // end namespace Eigen |