diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-06-08 14:05:23 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-06-08 14:05:23 +0200 |
commit | 55de162cf6fa3e666ef6b07223c18ae9cd1f1a30 (patch) | |
tree | ffb2a86d72acf5ccfbf6b79d3c06d89d3db52d4f /Eigen/src | |
parent | c49d1fd2b5d3ef6a71c385a84755df94434eb4b3 (diff) |
fix #10: the reallocateSparse function was half coded
Diffstat (limited to 'Eigen/src')
-rw-r--r-- | Eigen/src/Sparse/AmbiVector.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Eigen/src/Sparse/AmbiVector.h b/Eigen/src/Sparse/AmbiVector.h index 4e9d99910..974e5c6c4 100644 --- a/Eigen/src/Sparse/AmbiVector.h +++ b/Eigen/src/Sparse/AmbiVector.h @@ -99,6 +99,8 @@ template<typename _Scalar> class AmbiVector allocSize = allocSize/sizeof(Scalar) + (allocSize%sizeof(Scalar)>0?1:0); Scalar* newBuffer = new Scalar[allocSize]; memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl)); + delete[] m_buffer; + m_buffer = newBuffer; } protected: @@ -239,8 +241,11 @@ Scalar& AmbiVector<Scalar>::coeffRef(int i) else { if (m_llSize>=m_allocatedElements) + { reallocateSparse(); - ei_internal_assert(m_llSize<m_size && "internal error: overflow in sparse mode"); + llElements = reinterpret_cast<ListEl*>(m_buffer); + } + ei_internal_assert(m_llSize<m_allocatedElements && "internal error: overflow in sparse mode"); // let's insert a new coefficient ListEl& el = llElements[m_llSize]; el.value = Scalar(0); |