Fix EIGEN_NO_AUTOMATIC_RESIZING not resizing empty destinations

libeigen/eigen!2219

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-02-26 07:54:27 -08:00
parent 064d686c57
commit 1b1b7e347d
5 changed files with 112 additions and 0 deletions

View File

@@ -810,6 +810,9 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize_if_allowed(DstXprTyp
(dst.size() == 0 || (DstXprType::IsVectorAtCompileTime ? (dst.size() == src.size())
: (dst.rows() == dstRows && dst.cols() == dstCols))) &&
"Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
if (dst.size() == 0) {
dst.resize(dstRows, dstCols);
}
#else
dst.resize(dstRows, dstCols);
eigen_assert(dst.rows() == dstRows && dst.cols() == dstCols);

View File

@@ -685,6 +685,7 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type {
eigen_assert((this->size() == 0 || (IsVectorAtCompileTime ? (this->size() == other.size())
: (rows() == other.rows() && cols() == other.cols()))) &&
"Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
if (this->size() == 0) resizeLike(other);
EIGEN_ONLY_USED_FOR_DEBUG(other);
#else
resizeLike(other);