aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Reverse.h
diff options
context:
space:
mode:
Diffstat (limited to 'Eigen/src/Core/Reverse.h')
-rw-r--r--Eigen/src/Core/Reverse.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h
index 291300a4a..b3fba9704 100644
--- a/Eigen/src/Core/Reverse.h
+++ b/Eigen/src/Core/Reverse.h
@@ -210,7 +210,26 @@ DenseBase<Derived>::reverse() const
template<typename Derived>
inline void DenseBase<Derived>::reverseInPlace()
{
- derived() = derived().reverse().eval();
+ if(cols()>rows())
+ {
+ Index half = cols()/2;
+ leftCols(half).swap(rightCols(half).reverse());
+ if((cols()%2)==1)
+ {
+ Index half2 = rows()/2;
+ col(half).head(half2).swap(col(half).tail(half2).reverse());
+ }
+ }
+ else
+ {
+ Index half = rows()/2;
+ topRows(half).swap(bottomRows(half).reverse());
+ if((rows()%2)==1)
+ {
+ Index half2 = cols()/2;
+ row(half).head(half2).swap(row(half).tail(half2).reverse());
+ }
+ }
}
} // end namespace Eigen