mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-23 21:34:30 +08:00
fix #10: the reallocateSparse function was half coded
(transplanted from 55de162cf6fa3e666ef6b07223c18ae9cd1f1a30 )
This commit is contained in:
parent
eb1df142a3
commit
e43d630d80
@ -99,6 +99,8 @@ template<typename _Scalar> class AmbiVector
|
|||||||
allocSize = allocSize/sizeof(Scalar) + (allocSize%sizeof(Scalar)>0?1:0);
|
allocSize = allocSize/sizeof(Scalar) + (allocSize%sizeof(Scalar)>0?1:0);
|
||||||
Scalar* newBuffer = new Scalar[allocSize];
|
Scalar* newBuffer = new Scalar[allocSize];
|
||||||
memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl));
|
memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl));
|
||||||
|
delete[] m_buffer;
|
||||||
|
m_buffer = newBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -238,8 +240,11 @@ Scalar& AmbiVector<Scalar>::coeffRef(int i)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_llSize>=m_allocatedElements)
|
if (m_llSize>=m_allocatedElements)
|
||||||
|
{
|
||||||
reallocateSparse();
|
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
|
// let's insert a new coefficient
|
||||||
ListEl& el = llElements[m_llSize];
|
ListEl& el = llElements[m_llSize];
|
||||||
el.value = Scalar(0);
|
el.value = Scalar(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user