10 #ifndef EIGEN_SPARSE_COMPRESSED_BASE_H
11 #define EIGEN_SPARSE_COMPRESSED_BASE_H
18 template <
typename Derived>
19 class SparseCompressedBase;
23 template <
typename Derived>
26 template <
typename Derived,
class Comp,
bool IsVector>
42 template <
typename Derived>
47 using Base::operator=;
143 template <
class Comp = std::less<>>
151 template <
class Comp = std::less<>>
159 template <
class Comp = std::less<>>
168 template <
class Comp = std::less<>>
185 const Index outer = Derived::IsRowMajor ?
row :
col;
186 const Index inner = Derived::IsRowMajor ?
col :
row;
191 eigen_assert(
end >=
start &&
"you are using a non finalized sparse matrix or written coefficient does not exist");
202 template <
typename OtherDerived>
206 template <
typename Derived>
209 InnerIterator() : m_values(0), m_indices(0), m_outer(0), m_id(0), m_end(0) {}
212 : m_values(other.m_values),
213 m_indices(other.m_indices),
214 m_outer(other.m_outer),
216 m_end(other.m_end) {}
273 inline operator bool()
const {
return (m_id < m_end); }
287 template <
typename T>
291 template <
typename Derived>
341 inline operator bool()
const {
return (m_id > m_start); }
356 template <
typename Scalar,
typename StorageIndex>
358 template <
typename Scalar,
typename StorageIndex>
360 template <
typename Scalar,
typename StorageIndex>
361 class CompressedStorageIterator;
364 template <
typename Scalar,
typename StorageIndex>
388 template <
typename Scalar,
typename StorageIndex>
408 std::iter_swap(
a.keyPtr(),
b.keyPtr());
409 std::iter_swap(
a.valuePtr(),
b.valuePtr());
438 template <
typename Scalar,
typename StorageIndex>
484 #define MAKE_COMP(OP) \
485 inline bool operator OP(const CompressedStorageIterator& other) const { return m_index OP other.m_index; }
499 template <
typename Derived,
class Comp,
bool IsVector>
505 for (
Index outer = begin; outer <
end; outer++) {
510 std::sort(begin_it, end_it, Comp());
515 for (
Index outer = begin; outer <
end; outer++) {
526 template <
typename Derived,
class Comp>
531 Index begin_offset = 0;
535 std::sort(begin_it, end_it, Comp());
538 Index begin_offset = 0;
546 template <
typename Derived>
558 operator Derived&() {
return m_matrix->const_cast_derived(); }
559 operator const Derived&()
const {
return *m_matrix; }
568 return m_matrix->const_cast_derived().valuePtr()[
p];
574 return m_matrix->const_cast_derived().valuePtr()[
p];
int i
Definition: BiCGSTAB_step_by_step.cpp:9
#define eigen_internal_assert(x)
Definition: Macros.h:916
#define eigen_assert(x)
Definition: Macros.h:910
int data[]
Definition: Map_placement_new.cpp:1
#define MAKE_COMP(OP)
Definition: SparseCompressedBase.h:484
#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
Definition: SparseUtil.h:39
#define EIGEN_INTERNAL_CHECK_COST_VALUE(C)
Definition: StaticAssert.h:101
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
float * p
Definition: Tutorial_Map_using.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Definition: ForwardDeclarations.h:63
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:96
static ConstMapType Map(const Scalar *data)
Definition: PlainObjectBase.h:595
Definition: SparseCompressedBase.h:207
InnerIterator(const InnerIterator &other)
Definition: SparseCompressedBase.h:211
Scalar & valueRef()
Definition: SparseCompressedBase.h:266
InnerIterator(const SparseCompressedBase &mat)
Definition: SparseCompressedBase.h:241
Index m_end
Definition: SparseCompressedBase.h:281
InnerIterator(const SparseMatrixBase< T > &, Index outer)
InnerIterator()
Definition: SparseCompressedBase.h:209
const Scalar & value() const
Definition: SparseCompressedBase.h:265
const OuterType m_outer
Definition: SparseCompressedBase.h:279
InnerIterator & operator+=(Index i)
Definition: SparseCompressedBase.h:254
Index col() const
Definition: SparseCompressedBase.h:271
InnerIterator & operator=(const InnerIterator &other)
Definition: SparseCompressedBase.h:218
Index m_id
Definition: SparseCompressedBase.h:280
InnerIterator & operator++()
Definition: SparseCompressedBase.h:250
StorageIndex index() const
Definition: SparseCompressedBase.h:268
const Scalar * m_values
Definition: SparseCompressedBase.h:276
internal::variable_if_dynamic< Index, Derived::IsVectorAtCompileTime ? 0 :Dynamic > OuterType
Definition: SparseCompressedBase.h:278
Index row() const
Definition: SparseCompressedBase.h:270
InnerIterator operator+(Index i)
Definition: SparseCompressedBase.h:259
const StorageIndex * m_indices
Definition: SparseCompressedBase.h:277
InnerIterator(const SparseCompressedBase &mat, Index outer)
Definition: SparseCompressedBase.h:227
InnerIterator(const internal::CompressedStorage< Scalar, StorageIndex > &data)
Definition: SparseCompressedBase.h:245
Index outer() const
Definition: SparseCompressedBase.h:269
Definition: SparseCompressedBase.h:292
Index m_id
Definition: SparseCompressedBase.h:349
StorageIndex index() const
Definition: SparseCompressedBase.h:336
Index row() const
Definition: SparseCompressedBase.h:338
Index outer() const
Definition: SparseCompressedBase.h:337
internal::variable_if_dynamic< Index, Derived::IsVectorAtCompileTime ? 0 :Dynamic > OuterType
Definition: SparseCompressedBase.h:346
const StorageIndex * m_indices
Definition: SparseCompressedBase.h:345
ReverseInnerIterator & operator--()
Definition: SparseCompressedBase.h:318
const Scalar & value() const
Definition: SparseCompressedBase.h:333
Index m_start
Definition: SparseCompressedBase.h:348
Scalar & valueRef()
Definition: SparseCompressedBase.h:334
const Scalar * m_values
Definition: SparseCompressedBase.h:344
const OuterType m_outer
Definition: SparseCompressedBase.h:347
ReverseInnerIterator operator-(Index i)
Definition: SparseCompressedBase.h:327
Index col() const
Definition: SparseCompressedBase.h:339
ReverseInnerIterator(const internal::CompressedStorage< Scalar, StorageIndex > &data)
Definition: SparseCompressedBase.h:313
ReverseInnerIterator(const SparseCompressedBase &mat)
Definition: SparseCompressedBase.h:308
ReverseInnerIterator & operator-=(Index i)
Definition: SparseCompressedBase.h:322
ReverseInnerIterator(const SparseCompressedBase &mat, Index outer)
Definition: SparseCompressedBase.h:294
Common base class for sparse [compressed]-{row|column}-storage format.
Definition: SparseCompressedBase.h:43
Index nonZeros() const
Definition: SparseCompressedBase.h:64
Index innerIndicesAreSorted() const
Definition: SparseCompressedBase.h:169
Scalar * valuePtr()
Definition: SparseCompressedBase.h:82
const Scalar * valuePtr() const
Definition: SparseCompressedBase.h:78
StorageIndex * innerIndexPtr()
Definition: SparseCompressedBase.h:91
const StorageIndex * outerIndexPtr() const
Definition: SparseCompressedBase.h:97
StorageIndex * innerNonZeroPtr()
Definition: SparseCompressedBase.h:111
void sortInnerIndices()
Definition: SparseCompressedBase.h:160
SparseMatrixBase< Derived > Base
Definition: SparseCompressedBase.h:45
StorageIndex * outerIndexPtr()
Definition: SparseCompressedBase.h:102
internal::LowerBoundIndex lower_bound(Index row, Index col) const
Definition: SparseCompressedBase.h:182
Index innerIndicesAreSorted(Index begin, Index end) const
Definition: SparseCompressedBase.h:152
const Eigen::Map< const IndexVector > innerNonZeros() const
Definition: SparseCompressedBase.h:58
const Map< const Array< Scalar, Dynamic, 1 > > coeffs() const
Definition: SparseCompressedBase.h:121
bool isCompressed() const
Definition: SparseCompressedBase.h:114
Map< Array< Scalar, Dynamic, 1 > > coeffs()
Definition: SparseCompressedBase.h:136
const StorageIndex * innerIndexPtr() const
Definition: SparseCompressedBase.h:87
void sortInnerIndices(Index begin, Index end)
Definition: SparseCompressedBase.h:144
SparseCompressedBase(const SparseCompressedBase< OtherDerived > &)
Base::IndexVector IndexVector
Definition: SparseCompressedBase.h:51
@ IsRowMajor
Definition: SparseMatrixBase.h:99
SparseCompressedBase()
Definition: SparseCompressedBase.h:177
const StorageIndex * innerNonZeroPtr() const
Definition: SparseCompressedBase.h:107
Eigen::Map< IndexVector > innerNonZeros()
Definition: SparseCompressedBase.h:55
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
internal::traits< Derived >::StorageIndex StorageIndex
Definition: SparseMatrixBase.h:44
Index size() const
Definition: SparseMatrixBase.h:187
Index rows() const
Definition: SparseMatrixBase.h:182
internal::traits< Derived >::Scalar Scalar
Definition: SparseMatrixBase.h:32
const Derived & derived() const
Definition: SparseMatrixBase.h:144
Index outerSize() const
Definition: SparseMatrixBase.h:195
Index cols() const
Definition: SparseMatrixBase.h:184
@ IsRowMajor
Definition: SparseMatrixBase.h:99
Index nonZeros() const
Definition: SparseCompressedBase.h:64
const StorageIndex * innerNonZeroPtr() const
Definition: SparseMatrix.h:198
bool isCompressed() const
Definition: SparseCompressedBase.h:114
const StorageIndex * outerIndexPtr() const
Definition: SparseMatrix.h:189
Definition: SparseCompressedBase.h:439
CompressedStorageIterator & operator=(const CompressedStorageIterator &other)
Definition: SparseCompressedBase.h:453
reference m_data
Definition: SparseCompressedBase.h:496
StorageRef< Scalar, StorageIndex > reference
Definition: SparseCompressedBase.h:442
reference operator*() const
Definition: SparseCompressedBase.h:482
value_type * pointer
Definition: SparseCompressedBase.h:445
CompressedStorageIterator()=delete
CompressedStorageIterator(difference_type index, reference data)
Definition: SparseCompressedBase.h:450
CompressedStorageIterator & operator--()
Definition: SparseCompressedBase.h:470
CompressedStorageIterator(CompressedStorageIterator &&other)=default
CompressedStorageIterator & operator-=(difference_type offset)
Definition: SparseCompressedBase.h:478
Index difference_type
Definition: SparseCompressedBase.h:443
CompressedStorageIterator operator-(difference_type offset) const
Definition: SparseCompressedBase.h:462
CompressedStorageIterator & operator+=(difference_type offset)
Definition: SparseCompressedBase.h:474
CompressedStorageIterator operator+(difference_type offset) const
Definition: SparseCompressedBase.h:459
CompressedStorageIterator(const CompressedStorageIterator &other)
Definition: SparseCompressedBase.h:451
difference_type operator-(const CompressedStorageIterator &other) const
Definition: SparseCompressedBase.h:465
std::random_access_iterator_tag iterator_category
Definition: SparseCompressedBase.h:441
difference_type m_index
Definition: SparseCompressedBase.h:495
typename reference::value_type value_type
Definition: SparseCompressedBase.h:444
CompressedStorageIterator(difference_type index, StorageIndex *innerIndexPtr, Scalar *valuePtr)
Definition: SparseCompressedBase.h:448
CompressedStorageIterator & operator++()
Definition: SparseCompressedBase.h:466
Definition: SparseCompressedBase.h:389
StorageIndex * m_innerIndexIterator
Definition: SparseCompressedBase.h:423
StorageIndex * keyPtr() const
Definition: SparseCompressedBase.h:416
StorageRef & operator=(const StorageRef &other)
Definition: SparseCompressedBase.h:396
StorageVal< Scalar, StorageIndex > value_type
Definition: SparseCompressedBase.h:391
const StorageIndex & key() const
Definition: SparseCompressedBase.h:412
StorageRef & operator=(const value_type &other)
Definition: SparseCompressedBase.h:401
Scalar & value()
Definition: SparseCompressedBase.h:415
StorageIndex & key()
Definition: SparseCompressedBase.h:413
Scalar * valuePtr() const
Definition: SparseCompressedBase.h:417
friend void swap(const StorageRef &a, const StorageRef &b)
Definition: SparseCompressedBase.h:407
Scalar * m_valueIterator
Definition: SparseCompressedBase.h:424
StorageRef(StorageIndex *innerIndexIterator, Scalar *valueIterator)
Definition: SparseCompressedBase.h:429
const Scalar & value() const
Definition: SparseCompressedBase.h:414
StorageRef(StorageRef &&other)=default
Definition: SparseCompressedBase.h:365
Scalar & value()
Definition: SparseCompressedBase.h:374
const StorageIndex & key() const
Definition: SparseCompressedBase.h:371
StorageIndex & key()
Definition: SparseCompressedBase.h:372
StorageVal(const StorageIndex &innerIndex, const Scalar &value)
Definition: SparseCompressedBase.h:367
const Scalar & value() const
Definition: SparseCompressedBase.h:373
Scalar m_value
Definition: SparseCompressedBase.h:381
StorageIndex m_innerIndex
Definition: SparseCompressedBase.h:380
StorageVal(StorageVal &&other)=default
StorageVal(const StorageVal &other)
Definition: SparseCompressedBase.h:368
Definition: XprHelper.h:154
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR T value()
Definition: XprHelper.h:161
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
const Scalar * a
Definition: level2_cplx_impl.h:32
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
Extend namespace for flags.
Definition: fsi_chan_precond_driver.cc:56
Definition: Eigen_Colamd.h:49
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
bool is_sorted(const T &mat)
Definition: sparse_permutations.cpp:35
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:43
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:217
Definition: SparseUtil.h:169
bool found
Definition: SparseUtil.h:173
Index value
Definition: SparseUtil.h:172
DenseCoeffsBase< Derived, ReadOnlyAccessors >::CoeffReturnType CoeffReturnType
Definition: SparseCompressedBase.h:561
Derived::Scalar Scalar
Definition: SparseCompressedBase.h:548
Index find(Index row, Index col) const
Definition: SparseCompressedBase.h:578
evaluator()
Definition: SparseCompressedBase.h:553
const Scalar & coeff(Index row, Index col) const
Definition: SparseCompressedBase.h:562
Index nonZerosEstimate() const
Definition: SparseCompressedBase.h:556
const Derived * m_matrix
Definition: SparseCompressedBase.h:583
evaluator(const Derived &mat)
Definition: SparseCompressedBase.h:554
const Scalar m_zero
Definition: SparseCompressedBase.h:584
Derived::InnerIterator InnerIterator
Definition: SparseCompressedBase.h:549
Scalar & coeffRef(Index row, Index col)
Definition: SparseCompressedBase.h:571
Definition: CoreEvaluators.h:118
Definition: CoreEvaluators.h:104
static Index check(const SparseCompressedBase< Derived > &obj, Index, Index)
Definition: SparseCompressedBase.h:537
static void run(SparseCompressedBase< Derived > &obj, Index, Index)
Definition: SparseCompressedBase.h:530
Derived::StorageIndex StorageIndex
Definition: SparseCompressedBase.h:529
Derived::Scalar Scalar
Definition: SparseCompressedBase.h:528
Definition: SparseCompressedBase.h:500
static Index check(const SparseCompressedBase< Derived > &obj, Index begin, Index end)
Definition: SparseCompressedBase.h:513
Derived::Scalar Scalar
Definition: SparseCompressedBase.h:501
static void run(SparseCompressedBase< Derived > &obj, Index begin, Index end)
Definition: SparseCompressedBase.h:503
Derived::StorageIndex StorageIndex
Definition: SparseCompressedBase.h:502
Definition: ForwardDeclarations.h:21