add a smart realloc algorithm when filling a sparse matrix

This commit is contained in:
Gael Guennebaud
2009-01-18 18:00:19 +00:00
parent 0c7974dd4d
commit d58bb54e7f
3 changed files with 20 additions and 8 deletions

View File

@@ -151,7 +151,7 @@ class SparseVector
{
int startId = 0;
int id = m_data.size() - 1;
m_data.resize(id+2);
m_data.resize(id+2,1);
while ( (id >= startId) && (m_data.index(id) > i) )
{
@@ -172,7 +172,7 @@ class SparseVector
void resizeNonZeros(int size) { m_data.resize(size); }
inline SparseVector() : m_size(0) { resize(0, 0); }
inline SparseVector() : m_size(0) { resize(0); }
inline SparseVector(int size) : m_size(0) { resize(size); }