aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hauke Heibel <hauke.heibel@gmail.com>2009-09-25 14:44:48 +0200
committerGravatar Hauke Heibel <hauke.heibel@gmail.com>2009-09-25 14:44:48 +0200
commit21d2533723ae31bb7b979239dd45af8489e65397 (patch)
tree3230ce99c347e702cbba568c313aecbccb7fe605
parent04dc63776a63e5d0ec0237706cb440152d57769e (diff)
Matrix::conservativeResize, resize only when necessary.
-rw-r--r--Eigen/src/Core/Matrix.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 2e2826205..027e6bb70 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -707,6 +707,8 @@ struct ei_conservative_resize_like_impl
{
static void run(MatrixBase<Derived>& _this, const MatrixBase<OtherDerived>& other)
{
+ if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
+
// Note: Here is space for improvement. Basically, for conservativeResize(int,int),
// neither RowsAtCompileTime or ColsAtCompileTime must be Dynamic. If only one of the
// dimensions is dynamic, one could use either conservativeResize(int rows, NoChange_t) or
@@ -728,6 +730,8 @@ struct ei_conservative_resize_like_impl<Derived,OtherDerived,true>
{
static void run(MatrixBase<Derived>& _this, const MatrixBase<OtherDerived>& other)
{
+ if (_this.rows() == other.rows() && _this.cols() == other.cols()) return;
+
// segment(...) will check whether Derived/OtherDerived are vectors!
typename MatrixBase<Derived>::PlainMatrixType tmp(other);
const int common_size = std::min<int>(_this.size(),tmp.size());