From 820e8a45fb9b8305aeffba63956ac3a6091db4df Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Sun, 13 Oct 2024 17:55:56 +0000 Subject: [PATCH] add compile time info to reverse in place --- Eigen/src/Core/Reverse.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Eigen/src/Core/Reverse.h b/Eigen/src/Core/Reverse.h index 66116aa4e..eb06fff57 100644 --- a/Eigen/src/Core/Reverse.h +++ b/Eigen/src/Core/Reverse.h @@ -127,19 +127,25 @@ EIGEN_DEVICE_FUNC inline typename DenseBase::ReverseReturnType DenseBas * \sa VectorwiseOp::reverseInPlace(), reverse() */ template EIGEN_DEVICE_FUNC inline void DenseBase::reverseInPlace() { + constexpr int HalfRowsAtCompileTime = RowsAtCompileTime == Dynamic ? Dynamic : RowsAtCompileTime / 2; + constexpr int HalfColsAtCompileTime = ColsAtCompileTime == Dynamic ? Dynamic : ColsAtCompileTime / 2; if (cols() > rows()) { Index half = cols() / 2; - leftCols(half).swap(rightCols(half).reverse()); + this->template leftCols(half).swap( + this->template rightCols(half).reverse()); if ((cols() % 2) == 1) { Index half2 = rows() / 2; - col(half).head(half2).swap(col(half).tail(half2).reverse()); + col(half).template head(half2).swap( + col(half).template tail(half2).reverse()); } } else { Index half = rows() / 2; - topRows(half).swap(bottomRows(half).reverse()); + this->template topRows(half).swap( + this->template bottomRows(half).reverse()); if ((rows() % 2) == 1) { Index half2 = cols() / 2; - row(half).head(half2).swap(row(half).tail(half2).reverse()); + row(half).template head(half2).swap( + row(half).template tail(half2).reverse()); } } }