From 4293a4d1af0221ae4a9b19e28d118951ff56400b Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 8 Mar 2010 10:34:59 -0500 Subject: [PATCH] * let a = foo() work when a is a row-vector xpr and foo() returns a ReturnByValue col-vector * remove a few useless resize() in evalTo() implementations --- Eigen/src/Core/DenseStorageBase.h | 12 +++++++----- Eigen/src/LU/PartialPivLU.h | 2 -- Eigen/src/QR/ColPivHouseholderQR.h | 1 - Eigen/src/QR/FullPivHouseholderQR.h | 1 - Eigen/src/QR/HouseholderQR.h | 1 - 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index dac2142a4..58579b3d3 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -232,17 +232,19 @@ class DenseStorageBase : public _Base * remain row-vectors and vectors remain vectors. */ template - EIGEN_STRONG_INLINE void resizeLike(const DenseBase& other) + EIGEN_STRONG_INLINE void resizeLike(const EigenBase& _other) { + const OtherDerived& other = _other.derived(); + const int othersize = other.rows()*other.cols(); if(RowsAtCompileTime == 1) { ei_assert(other.rows() == 1 || other.cols() == 1); - resize(1, other.size()); + resize(1, othersize); } else if(ColsAtCompileTime == 1) { ei_assert(other.rows() == 1 || other.cols() == 1); - resize(other.size(), 1); + resize(othersize, 1); } else resize(other.rows(), other.cols()); } @@ -343,7 +345,7 @@ class DenseStorageBase : public _Base template EIGEN_STRONG_INLINE Derived& operator=(const EigenBase &other) { - resize(other.derived().rows(), other.derived().cols()); + _resize_to_match(other); Base::operator=(other.derived()); return this->derived(); } @@ -424,7 +426,7 @@ class DenseStorageBase : public _Base * remain row-vectors and vectors remain vectors. */ template - EIGEN_STRONG_INLINE void _resize_to_match(const DenseBase& other) + EIGEN_STRONG_INLINE void _resize_to_match(const EigenBase& other) { #ifdef EIGEN_NO_AUTOMATIC_RESIZING ei_assert((this->size()==0 || (IsVectorAtCompileTime ? (this->size() == other.size()) diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index df36cb04d..0dc2d0857 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -439,8 +439,6 @@ struct ei_solve_retval, Rhs> const int size = dec().matrixLU().rows(); ei_assert(rhs().rows() == size); - dst.resize(size, rhs().cols()); - // Step 1 dst = dec().permutationP() * rhs(); diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index 1219f1918..be1b22979 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -432,7 +432,6 @@ struct ei_solve_retval, Rhs> { const int rows = dec().rows(), cols = dec().cols(), nonzero_pivots = dec().nonzeroPivots(); - dst.resize(cols, rhs().cols()); ei_assert(rhs().rows() == rows); if(nonzero_pivots == 0) diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h index 07be47f47..6ba0f45f8 100644 --- a/Eigen/src/QR/FullPivHouseholderQR.h +++ b/Eigen/src/QR/FullPivHouseholderQR.h @@ -341,7 +341,6 @@ struct ei_solve_retval, Rhs> template void evalTo(Dest& dst) const { const int rows = dec().rows(), cols = dec().cols(); - dst.resize(cols, rhs().cols()); ei_assert(rhs().rows() == rows); // FIXME introduce nonzeroPivots() and use it here. and more generally, diff --git a/Eigen/src/QR/HouseholderQR.h b/Eigen/src/QR/HouseholderQR.h index 4709e4b77..79d1ea6a0 100644 --- a/Eigen/src/QR/HouseholderQR.h +++ b/Eigen/src/QR/HouseholderQR.h @@ -217,7 +217,6 @@ struct ei_solve_retval, Rhs> template void evalTo(Dest& dst) const { const int rows = dec().rows(), cols = dec().cols(); - dst.resize(cols, rhs().cols()); const int rank = std::min(rows, cols); ei_assert(rhs().rows() == rows);