From 502f7179801a9b6ae5f6d6df60e72d5064702925 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 16 Jan 2019 14:33:45 +0100 Subject: [PATCH] bug #1646: disable aliasing detection for empty and 1x1 expression --- Eigen/src/Core/Transpose.h | 3 ++- test/adjoint.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index d7c204579..6255a2f6d 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -392,7 +392,8 @@ struct checkTransposeAliasing_impl template void check_for_aliasing(const Dst &dst, const Src &src) { - internal::checkTransposeAliasing_impl::run(dst, src); + if(src.size()>1) + internal::checkTransposeAliasing_impl::run(dst, src); } } // end namespace internal diff --git a/test/adjoint.cpp b/test/adjoint.cpp index 4e1e4b5e8..7c8081ec4 100644 --- a/test/adjoint.cpp +++ b/test/adjoint.cpp @@ -171,6 +171,17 @@ void adjoint_extra() c = MatrixXd::Ones(10,10) * 1.0 + c; c = c + MatrixXd::Ones(10,10) .cwiseProduct( MatrixXd::Zero(10,10) ); c = MatrixXd::Ones(10,10) * MatrixXd::Zero(10,10); + + // regression for bug 1646 + for (int j = 0; j < 10; ++j) { + c.col(j).head(j) = c.row(j).head(j); + } + + a.conservativeResize(1,1); + a = a.transpose(); + + a.conservativeResize(0,0); + a = a.transpose(); } EIGEN_DECLARE_TEST(adjoint)