12 #ifndef EIGEN_REVERSE_H 13 #define EIGEN_REVERSE_H 19 template<
typename MatrixType,
int Direction>
20 struct traits<Reverse<MatrixType, Direction> >
23 typedef typename MatrixType::Scalar Scalar;
24 typedef typename traits<MatrixType>::StorageKind StorageKind;
25 typedef typename traits<MatrixType>::XprKind XprKind;
26 typedef typename ref_selector<MatrixType>::type MatrixTypeNested;
27 typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
29 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
30 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
31 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
32 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
37 template<
typename PacketType,
bool ReversePacket>
struct reverse_packet_cond
39 static inline PacketType run(
const PacketType& x) {
return preverse(x); }
42 template<
typename PacketType>
struct reverse_packet_cond<PacketType,false>
44 static inline PacketType run(
const PacketType& x) {
return x; }
63 template<
typename MatrixType,
int Direction>
class Reverse 64 :
public internal::dense_xpr_base< Reverse<MatrixType, Direction> >::type
68 typedef typename internal::dense_xpr_base<Reverse>::type Base;
69 EIGEN_DENSE_PUBLIC_INTERFACE(
Reverse)
70 typedef typename internal::remove_all<MatrixType>::type NestedExpression;
71 using Base::IsRowMajor;
75 PacketSize = internal::packet_traits<Scalar>::size,
76 IsColMajor = !IsRowMajor,
79 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
80 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1,
82 || ((Direction ==
Vertical) && IsColMajor)
85 typedef internal::reverse_packet_cond<PacketScalar,ReversePacket> reverse_packet;
88 EIGEN_DEVICE_FUNC
explicit inline Reverse(
const MatrixType& matrix) : m_matrix(matrix) { }
90 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Reverse)
92 EIGEN_DEVICE_FUNC
inline Index rows()
const {
return m_matrix.rows(); }
93 EIGEN_DEVICE_FUNC
inline Index cols()
const {
return m_matrix.cols(); }
95 EIGEN_DEVICE_FUNC
inline Index innerStride()
const 97 return -m_matrix.innerStride();
100 EIGEN_DEVICE_FUNC
const typename internal::remove_all<typename MatrixType::Nested>::type&
101 nestedExpression()
const 107 typename MatrixType::Nested m_matrix;
116 template<
typename Derived>
138 template<
typename Derived>
143 Index half = cols()/2;
144 leftCols(half).swap(rightCols(half).reverse());
147 Index half2 = rows()/2;
148 col(half).head(half2).swap(col(half).tail(half2).reverse());
153 Index half = rows()/2;
154 topRows(half).swap(bottomRows(half).reverse());
157 Index half2 = cols()/2;
158 row(half).head(half2).swap(row(half).tail(half2).reverse());
165 template<
int Direction>
166 struct vectorwise_reverse_inplace_impl;
169 struct vectorwise_reverse_inplace_impl<Vertical>
171 template<
typename ExpressionType>
172 static void run(ExpressionType &xpr)
174 Index half = xpr.rows()/2;
175 xpr.topRows(half).swap(xpr.bottomRows(half).colwise().reverse());
180 struct vectorwise_reverse_inplace_impl<Horizontal>
182 template<
typename ExpressionType>
183 static void run(ExpressionType &xpr)
185 Index half = xpr.cols()/2;
186 xpr.leftCols(half).swap(xpr.rightCols(half).rowwise().reverse());
203 template<
typename ExpressionType,
int Direction>
206 internal::vectorwise_reverse_inplace_impl<Direction>::run(_expression().const_cast_derived());
211 #endif // EIGEN_REVERSE_H Definition: Constants.h:265
void reverseInPlace()
Definition: Reverse.h:204
const unsigned int LvalueBit
Definition: Constants.h:139
Namespace containing all symbols from the Eigen library.
Definition: Core:287
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:38
const unsigned int RowMajorBit
Definition: Constants.h:61
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
ReverseReturnType reverse()
Definition: Reverse.h:118
Definition: Constants.h:268
Definition: Constants.h:271
Definition: Eigen_Colamd.h:50
void reverseInPlace()
Definition: Reverse.h:139
Expression of the reverse of a vector or matrix.
Definition: Reverse.h:63