10 #ifndef EIGEN_AMBIVECTOR_H
11 #define EIGEN_AMBIVECTOR_H
22 template<
typename _Scalar,
typename _StorageIndex>
36 void init(
double estimatedDensity);
66 return internal::convert_index<StorageIndex>(idx);
95 allocSize = (allocSize +
sizeof(
Scalar) - 1)/
sizeof(
Scalar);
128 template<
typename _Scalar,
typename _StorageIndex>
134 return m_end - m_start;
137 template<
typename _Scalar,
typename _StorageIndex>
140 if (estimatedDensity>0.1)
146 template<
typename _Scalar,
typename _StorageIndex>
162 template<
typename _Scalar,
typename _StorageIndex>
165 m_llCurrent = m_llStart;
169 template<
typename _Scalar,
typename _StorageIndex>
174 for (
Index i=m_start; i<m_end; ++i)
185 template<
typename _Scalar,
typename _StorageIndex>
201 llElements[0].value =
Scalar(0);
203 llElements[0].next = -1;
204 return llElements[0].value;
206 else if (i<llElements[m_llStart].index)
209 ListEl& el = llElements[m_llSize];
213 m_llStart = m_llSize;
215 m_llCurrent = m_llStart;
221 eigen_assert(i>=llElements[m_llCurrent].index &&
"you must call restart() before inserting an element with lower or equal index");
222 while (nextel >= 0 && llElements[nextel].index<=i)
224 m_llCurrent = nextel;
225 nextel = llElements[nextel].next;
228 if (llElements[m_llCurrent].index==i)
231 return llElements[m_llCurrent].value;
235 if (m_llSize>=m_allocatedElements)
238 llElements =
reinterpret_cast<ListEl*
>(m_buffer);
242 ListEl& el = llElements[m_llSize];
245 el.
next = llElements[m_llCurrent].next;
246 llElements[m_llCurrent].next = m_llSize;
254 template<
typename _Scalar,
typename _StorageIndex>
263 if ((m_llSize==0) || (i<llElements[m_llStart].index))
269 Index elid = m_llStart;
270 while (elid >= 0 && llElements[elid].index<i)
271 elid = llElements[elid].next;
273 if (llElements[elid].index==i)
274 return llElements[m_llCurrent].value;
282 template<
typename _Scalar,
typename _StorageIndex>
300 m_isDense = m_vector.m_mode==
IsDense;
305 m_cachedIndex = m_vector.m_start-1;
311 m_currentEl = m_vector.m_llStart;
312 while (m_currentEl>=0 &&
abs(llElements[m_currentEl].value)<=m_epsilon)
313 m_currentEl = llElements[m_currentEl].next;
321 m_cachedIndex = llElements[m_currentEl].
index;
322 m_cachedValue = llElements[m_currentEl].value;
330 operator bool()
const {
return m_cachedIndex>=0; }
339 }
while (m_cachedIndex<m_vector.m_end &&
abs(m_vector.m_buffer[m_cachedIndex])<=m_epsilon);
340 if (m_cachedIndex<m_vector.m_end)
341 m_cachedValue = m_vector.m_buffer[m_cachedIndex];
349 m_currentEl = llElements[m_currentEl].
next;
350 }
while (m_currentEl>=0 &&
abs(llElements[m_currentEl].value)<=m_epsilon);
357 m_cachedIndex = llElements[m_currentEl].index;
358 m_cachedValue = llElements[m_currentEl].value;
377 #endif // EIGEN_AMBIVECTOR_H