aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SparseCore/SparseMatrix.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-03-13 21:00:21 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-03-13 21:00:21 +0100
commita9df28c95b42401fe4ac86313b85872200d05e4c (patch)
treef5f023717a046ba51f38d6fba0a50c1265af43a9 /Eigen/src/SparseCore/SparseMatrix.h
parent5ffe29cb9f260f35f1ae0f878885a77d42a29d8b (diff)
SparseMatrix::insert: switch to a fully uncompressed mode if sequential insertion is not possible (otherwise an arbitrary large amount of memory was preallocated in some cases)
Diffstat (limited to 'Eigen/src/SparseCore/SparseMatrix.h')
-rw-r--r--Eigen/src/SparseCore/SparseMatrix.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h
index 0ba7e111a..4c3a47959 100644
--- a/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -1172,8 +1172,12 @@ typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& SparseMatrix<_Scalar,_Op
return (m_data.value(p) = 0);
}
- // make sure the matrix is compatible to random un-compressed insertion:
- m_data.resize(m_data.allocatedSize());
+ if(m_data.size() != m_data.allocatedSize())
+ {
+ // make sure the matrix is compatible to random un-compressed insertion:
+ m_data.resize(m_data.allocatedSize());
+ this->reserveInnerVectors(Array<StorageIndex,Dynamic,1>::Constant(2*m_outerSize, convert_index(m_outerSize)));
+ }
return insertUncompressed(row,col);
}