diff options
author | Gael Guennebaud <g.gael@free.fr> | 2017-07-20 10:13:48 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2017-07-20 10:13:48 +0200 |
commit | 1f4b24d2df6200c1074c2fca45d3905a33c54a3b (patch) | |
tree | 6ada4207618e9c92fa297ead2df465d3d98f2bb2 | |
parent | d580a90c9ab5ed5521a79670f73bcea5ee755fe0 (diff) |
Do not preallocate more space than the matrix size (when the sparse matrix boils down to a vector
-rw-r--r-- | Eigen/src/SparseCore/SparseAssign.h | 4 |
1 files changed, 2 insertions, 2 deletions
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<outerEvaluationSize; ++j) { dst.startVec(j); @@ -107,7 +107,7 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src) DstXprType temp(src.rows(), src.cols()); - temp.reserve((std::max)(src.rows(),src.cols())*2); + temp.reserve((std::min)(src.rows()*src.cols(), (std::max)(src.rows(),src.cols())*2)); for (Index j=0; j<outerEvaluationSize; ++j) { temp.startVec(j); |