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>
163 template<
typename _Scalar,
typename _StorageIndex>
166 m_llCurrent = m_llStart;
170 template<
typename _Scalar,
typename _StorageIndex>
175 for (
Index i=m_start; i<m_end; ++i)
186 template<
typename _Scalar,
typename _StorageIndex>
202 llElements[0].value =
Scalar(0);
204 llElements[0].next = -1;
205 return llElements[0].value;
207 else if (i<llElements[m_llStart].index)
210 ListEl& el = llElements[m_llSize];
214 m_llStart = m_llSize;
216 m_llCurrent = m_llStart;
222 eigen_assert(i>=llElements[m_llCurrent].index &&
"you must call restart() before inserting an element with lower or equal index");
223 while (nextel >= 0 && llElements[nextel].index<=i)
225 m_llCurrent = nextel;
226 nextel = llElements[nextel].next;
229 if (llElements[m_llCurrent].index==i)
232 return llElements[m_llCurrent].value;
236 if (m_llSize>=m_allocatedElements)
239 llElements =
reinterpret_cast<ListEl*
>(m_buffer);
243 ListEl& el = llElements[m_llSize];
246 el.
next = llElements[m_llCurrent].next;
247 llElements[m_llCurrent].next = m_llSize;
255 template<
typename _Scalar,
typename _StorageIndex>
264 if ((m_llSize==0) || (i<llElements[m_llStart].index))
270 Index elid = m_llStart;
271 while (elid >= 0 && llElements[elid].index<i)
272 elid = llElements[elid].next;
274 if (llElements[elid].index==i)
275 return llElements[m_llCurrent].value;
283 template<
typename _Scalar,
typename _StorageIndex>
301 m_isDense = m_vector.m_mode==
IsDense;
306 m_cachedIndex = m_vector.m_start-1;
312 m_currentEl = m_vector.m_llStart;
313 while (m_currentEl>=0 &&
abs(llElements[m_currentEl].
value)<=m_epsilon)
314 m_currentEl = llElements[m_currentEl].next;
322 m_cachedIndex = llElements[m_currentEl].
index;
323 m_cachedValue = llElements[m_currentEl].value;
331 operator bool()
const {
return m_cachedIndex>=0; }
340 }
while (m_cachedIndex<m_vector.m_end &&
abs(m_vector.m_buffer[m_cachedIndex])<=m_epsilon);
341 if (m_cachedIndex<m_vector.m_end)
342 m_cachedValue = m_vector.m_buffer[m_cachedIndex];
350 m_currentEl = llElements[m_currentEl].
next;
351 }
while (m_currentEl>=0 &&
abs(llElements[m_currentEl].
value)<=m_epsilon);
358 m_cachedIndex = llElements[m_currentEl].index;
359 m_cachedValue = llElements[m_currentEl].value;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
Definition: ArrayCwiseUnaryOps.h:52
#define EIGEN_RESTRICT
Definition: Macros.h:1160
#define eigen_internal_assert(x)
Definition: Macros.h:1043
#define eigen_assert(x)
Definition: Macros.h:1037
Definition: AmbiVector.h:285
Scalar m_cachedValue
Definition: AmbiVector.h:370
Iterator(const AmbiVector &vec, const RealScalar &epsilon=0)
Definition: AmbiVector.h:296
StorageIndex m_cachedIndex
Definition: AmbiVector.h:369
bool m_isDense
Definition: AmbiVector.h:371
_Scalar Scalar
Definition: AmbiVector.h:287
Iterator & operator++()
Definition: AmbiVector.h:333
StorageIndex index() const
Definition: AmbiVector.h:328
const AmbiVector & m_vector
Definition: AmbiVector.h:366
Scalar value() const
Definition: AmbiVector.h:329
StorageIndex m_currentEl
Definition: AmbiVector.h:367
RealScalar m_epsilon
Definition: AmbiVector.h:368
NumTraits< Scalar >::Real RealScalar
Definition: AmbiVector.h:288
Definition: AmbiVector.h:24
Scalar m_zero
Definition: AmbiVector.h:113
Scalar & coeff(Index i)
Definition: AmbiVector.h:256
void resize(Index size)
Definition: AmbiVector.h:54
StorageIndex size() const
Definition: AmbiVector.h:61
~AmbiVector()
Definition: AmbiVector.h:52
StorageIndex m_size
Definition: AmbiVector.h:114
void restart()
Definition: AmbiVector.h:164
void reallocateSparse()
Definition: AmbiVector.h:90
StorageIndex m_mode
Definition: AmbiVector.h:119
_Scalar Scalar
Definition: AmbiVector.h:26
StorageIndex convert_index(Index idx)
Definition: AmbiVector.h:64
StorageIndex m_llCurrent
Definition: AmbiVector.h:123
StorageIndex m_allocatedSize
Definition: AmbiVector.h:117
NumTraits< Scalar >::Real RealScalar
Definition: AmbiVector.h:28
StorageIndex m_end
Definition: AmbiVector.h:116
_StorageIndex StorageIndex
Definition: AmbiVector.h:27
void init(double estimatedDensity)
Definition: AmbiVector.h:138
void setBounds(Index start, Index end)
Definition: AmbiVector.h:42
Scalar * m_buffer
Definition: AmbiVector.h:112
StorageIndex m_allocatedElements
Definition: AmbiVector.h:118
StorageIndex m_llStart
Definition: AmbiVector.h:122
Scalar & coeffRef(Index i)
Definition: AmbiVector.h:187
StorageIndex m_llSize
Definition: AmbiVector.h:124
Index nonZeros() const
Definition: AmbiVector.h:129
StorageIndex m_start
Definition: AmbiVector.h:115
void reallocate(Index size)
Definition: AmbiVector.h:69
void setZero()
Definition: AmbiVector.h:171
AmbiVector(Index size)
Definition: AmbiVector.h:30
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16() min(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:571
EIGEN_DEVICE_FUNC IndexDest convert_index(const IndexSrc &idx)
Definition: XprHelper.h:31
static EIGEN_DEPRECATED const end_t end
Definition: IndexedViewHelper.h:181
Namespace containing all symbols from the Eigen library.
Definition: LDLT.h:16
@ IsDense
Definition: Constants.h:367
@ IsSparse
Definition: Constants.h:368
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Definition: document.h:416
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1282
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:233
Definition: AmbiVector.h:105
Scalar value
Definition: AmbiVector.h:108
StorageIndex index
Definition: AmbiVector.h:107
StorageIndex next
Definition: AmbiVector.h:106