12 #ifndef EIGEN_REVERSE_H
13 #define EIGEN_REVERSE_H
19 template<
typename MatrixType,
int Direction>
23 typedef typename MatrixType::Scalar Scalar;
27 typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
29 RowsAtCompileTime = MatrixType::RowsAtCompileTime,
30 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
31 MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
32 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
39 static inline PacketType run(
const PacketType& x) {
return preverse(x); }
44 static inline PacketType run(
const PacketType& x) {
return x; }
63 template<
typename MatrixType,
int Direction>
class Reverse
69 EIGEN_DENSE_PUBLIC_INTERFACE(
Reverse)
70 typedef typename internal::remove_all<MatrixType>::type NestedExpression;
71 using Base::IsRowMajor;
76 IsColMajor = !IsRowMajor,
79 OffsetRow = ReverseRow && IsColMajor ? PacketSize : 1,
80 OffsetCol = ReverseCol && IsRowMajor ? PacketSize : 1,
82 || ((Direction ==
Vertical) && IsColMajor)
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>
144 leftCols(
half).swap(rightCols(
half).reverse());
147 Index half2 = rows()/2;
148 col(
half).head(half2).swap(col(
half).tail(half2).reverse());
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>
171 template<
typename ExpressionType>
172 static void run(ExpressionType &xpr)
174 const int HalfAtCompileTime = ExpressionType::RowsAtCompileTime==
Dynamic?
Dynamic:ExpressionType::RowsAtCompileTime/2;
176 xpr.topRows(fix<HalfAtCompileTime>(
half))
177 .swap(xpr.bottomRows(fix<HalfAtCompileTime>(
half)).colwise().reverse());
184 template<
typename ExpressionType>
185 static void run(ExpressionType &xpr)
187 const int HalfAtCompileTime = ExpressionType::ColsAtCompileTime==
Dynamic?
Dynamic:ExpressionType::ColsAtCompileTime/2;
189 xpr.leftCols(fix<HalfAtCompileTime>(
half))
190 .swap(xpr.rightCols(fix<HalfAtCompileTime>(
half)).rowwise().reverse());
207 template<
typename ExpressionType,
int Direction>
215 #endif // EIGEN_REVERSE_H