From 1f4b24d2df6200c1074c2fca45d3905a33c54a3b Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Thu, 20 Jul 2017 10:13:48 +0200 Subject: Do not preallocate more space than the matrix size (when the sparse matrix boils down to a vector --- Eigen/src/SparseCore/SparseAssign.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Eigen/src/SparseCore') diff --git a/Eigen/src/SparseCore/SparseAssign.h b/Eigen/src/SparseCore/SparseAssign.h index 18352a847..113463258 100644 --- a/Eigen/src/SparseCore/SparseAssign.h +++ b/Eigen/src/SparseCore/SparseAssign.h @@ -83,7 +83,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src) // eval without temporary dst.resize(src.rows(), src.cols()); dst.setZero(); - dst.reserve((std::max)(src.rows(),src.cols())*2); + dst.reserve((std::min)(src.rows()*src.cols(), (std::max)(src.rows(),src.cols())*2)); for (Index j=0; j