aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Reverse.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2019-02-21 22:44:40 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2019-02-21 22:44:40 +0100
commit42c23f14acbfc9fbc00db7e34fcd39de60dfe4e2 (patch)
tree575edeec646a1a3b344abf1869bbb45bba4076e9 /Eigen/src/Core/Reverse.h
parent4d7f31710299fd869def962f2070c252ae1aaa67 (diff)
Speed up col/row-wise reverse for fixed size matrices by propagating compile-time sizes.
Diffstat (limited to 'Eigen/src/Core/Reverse.h')
-rw-r--r--Eigen/src/Core/Reverse.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h
index 711dbcf9a..853093923 100644
--- a/Eigen/src/Core/Reverse.h
+++ b/Eigen/src/Core/Reverse.h
@@ -171,8 +171,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 +184,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());
}
};