10 #ifndef EIGEN_AMBIVECTOR_H
11 #define EIGEN_AMBIVECTOR_H
25 template <
typename Scalar_,
typename StorageIndex_>
37 void init(
double estimatedDensity);
89 allocSize = (allocSize +
sizeof(
Scalar) - 1) /
sizeof(
Scalar);
121 template <
typename Scalar_,
typename StorageIndex_>
126 return m_end - m_start;
129 template <
typename Scalar_,
typename StorageIndex_>
131 if (estimatedDensity > 0.1)
137 template <
typename Scalar_,
typename StorageIndex_>
153 template <
typename Scalar_,
typename StorageIndex_>
155 m_llCurrent = m_llStart;
159 template <
typename Scalar_,
typename StorageIndex_>
170 template <
typename Scalar_,
typename StorageIndex_>
183 llElements[0].value =
Scalar(0);
185 llElements[0].next = -1;
186 return llElements[0].value;
187 }
else if (
i < llElements[m_llStart].index) {
193 m_llStart = m_llSize;
195 m_llCurrent = m_llStart;
200 "you must call restart() before inserting an element with lower or equal index");
201 while (nextel >= 0 && llElements[nextel].index <=
i) {
202 m_llCurrent = nextel;
203 nextel = llElements[nextel].next;
206 if (llElements[m_llCurrent].index ==
i) {
208 return llElements[m_llCurrent].value;
210 if (m_llSize >= m_allocatedElements) {
212 llElements =
reinterpret_cast<ListEl*
>(m_buffer);
219 el.next = llElements[m_llCurrent].next;
220 llElements[m_llCurrent].next = m_llSize;
228 template <
typename Scalar_,
typename StorageIndex_>
235 if ((m_llSize == 0) || (
i < llElements[m_llStart].index)) {
238 Index elid = m_llStart;
239 while (elid >= 0 && llElements[elid].index <
i) elid = llElements[elid].next;
241 if (llElements[elid].index ==
i)
242 return llElements[m_llCurrent].value;
250 template <
typename Scalar_,
typename StorageIndex_>
265 m_isDense = m_vector.m_mode ==
IsDense;
269 m_cachedIndex = m_vector.m_start - 1;
273 m_currentEl = m_vector.m_llStart;
274 while (m_currentEl >= 0 &&
abs(llElements[m_currentEl].
value) <= m_epsilon)
275 m_currentEl = llElements[m_currentEl].next;
276 if (m_currentEl < 0) {
280 m_cachedIndex = llElements[m_currentEl].
index;
281 m_cachedValue = llElements[m_currentEl].value;
289 operator bool()
const {
return m_cachedIndex >= 0; }
296 }
while (m_cachedIndex < m_vector.m_end &&
abs(m_vector.m_buffer[m_cachedIndex]) <= m_epsilon);
297 if (m_cachedIndex < m_vector.m_end)
298 m_cachedValue = m_vector.m_buffer[m_cachedIndex];
304 m_currentEl = llElements[m_currentEl].
next;
305 }
while (m_currentEl >= 0 &&
abs(llElements[m_currentEl].
value) <= m_epsilon);
306 if (m_currentEl < 0) {
309 m_cachedIndex = llElements[m_currentEl].index;
310 m_cachedValue = llElements[m_currentEl].value;
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define EIGEN_RESTRICT
Definition: Macros.h:1067
#define eigen_internal_assert(x)
Definition: Macros.h:916
#define eigen_assert(x)
Definition: Macros.h:910
SCALAR Scalar
Definition: bench_gemm.cpp:45
Definition: AmbiVector.h:251
StorageIndex m_cachedIndex
Definition: AmbiVector.h:320
const AmbiVector & m_vector
Definition: AmbiVector.h:317
StorageIndex index() const
Definition: AmbiVector.h:286
Iterator & operator++()
Definition: AmbiVector.h:291
Scalar m_cachedValue
Definition: AmbiVector.h:321
bool m_isDense
Definition: AmbiVector.h:322
NumTraits< Scalar >::Real RealScalar
Definition: AmbiVector.h:254
Iterator(const AmbiVector &vec, const RealScalar &epsilon=0)
Definition: AmbiVector.h:262
StorageIndex m_currentEl
Definition: AmbiVector.h:318
RealScalar m_epsilon
Definition: AmbiVector.h:319
Scalar value() const
Definition: AmbiVector.h:287
Scalar_ Scalar
Definition: AmbiVector.h:253
Definition: AmbiVector.h:26
void reallocateSparse()
Definition: AmbiVector.h:85
Index nonZeros() const
Definition: AmbiVector.h:122
StorageIndex m_allocatedSize
Definition: AmbiVector.h:110
StorageIndex m_allocatedElements
Definition: AmbiVector.h:111
StorageIndex m_end
Definition: AmbiVector.h:109
StorageIndex m_llCurrent
Definition: AmbiVector.h:116
StorageIndex m_size
Definition: AmbiVector.h:107
StorageIndex m_start
Definition: AmbiVector.h:108
StorageIndex size() const
Definition: AmbiVector.h:63
Scalar & coeffRef(Index i)
Definition: AmbiVector.h:171
void reallocate(Index size)
Definition: AmbiVector.h:68
Scalar m_zero
Definition: AmbiVector.h:106
StorageIndex m_llSize
Definition: AmbiVector.h:117
Scalar * m_buffer
Definition: AmbiVector.h:105
StorageIndex convert_index(Index idx)
Definition: AmbiVector.h:66
void setZero()
Definition: AmbiVector.h:160
StorageIndex m_mode
Definition: AmbiVector.h:112
void init(double estimatedDensity)
Definition: AmbiVector.h:130
~AmbiVector()
Definition: AmbiVector.h:56
void resize(Index size)
Definition: AmbiVector.h:58
Scalar_ Scalar
Definition: AmbiVector.h:28
Scalar & coeff(Index i)
Definition: AmbiVector.h:229
void restart()
Definition: AmbiVector.h:154
StorageIndex m_llStart
Definition: AmbiVector.h:115
AmbiVector(Index size)
Definition: AmbiVector.h:32
void setBounds(Index start, Index end)
Definition: AmbiVector.h:43
NumTraits< Scalar >::Real RealScalar
Definition: AmbiVector.h:30
StorageIndex_ StorageIndex
Definition: AmbiVector.h:29
#define min(a, b)
Definition: datatypes.h:22
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
@ IsDense
Definition: Constants.h:365
@ IsSparse
Definition: Constants.h:365
double el
Definition: crbond_bessel.cc:27
EIGEN_DEVICE_FUNC IndexDest convert_index(const IndexSrc &idx)
Definition: XprHelper.h:63
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
squared absolute value
Definition: GlobalFunctions.h:87
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
Definition: Eigen_Colamd.h:49
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: AmbiVector.h:98
StorageIndex index
Definition: AmbiVector.h:100
StorageIndex next
Definition: AmbiVector.h:99
Scalar value
Definition: AmbiVector.h:101
Definition: TutorialInplaceLU.cpp:2