Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ > Class Template Reference

#include <CompressedStorage.h>

Public Types

typedef Scalar_ Scalar
 
typedef StorageIndex_ StorageIndex
 

Public Member Functions

 CompressedStorage ()
 
 CompressedStorage (Index size)
 
 CompressedStorage (const CompressedStorage &other)
 
CompressedStorageoperator= (const CompressedStorage &other)
 
void swap (CompressedStorage &other)
 
 ~CompressedStorage ()
 
void reserve (Index size)
 
void squeeze ()
 
void resize (Index size, double reserveSizeFactor=0)
 
void append (const Scalar &v, Index i)
 
Index size () const
 
Index allocatedSize () const
 
void clear ()
 
const ScalarvaluePtr () const
 
ScalarvaluePtr ()
 
const StorageIndexindexPtr () const
 
StorageIndexindexPtr ()
 
Scalarvalue (Index i)
 
const Scalarvalue (Index i) const
 
StorageIndexindex (Index i)
 
const StorageIndexindex (Index i) const
 
Index searchLowerIndex (Index key) const
 
Index searchLowerIndex (Index start, Index end, Index key) const
 
Scalar at (Index key, const Scalar &defaultValue=Scalar(0)) const
 
Scalar atInRange (Index start, Index end, Index key, const Scalar &defaultValue=Scalar(0)) const
 
ScalaratWithInsertion (Index key, const Scalar &defaultValue=Scalar(0))
 
void moveChunk (Index from, Index to, Index chunkSize)
 

Protected Types

typedef NumTraits< Scalar >::Real RealScalar
 

Protected Member Functions

void reallocate (Index size)
 

Protected Attributes

Scalarm_values
 
StorageIndexm_indices
 
Index m_size
 
Index m_allocatedSize
 

Detailed Description

template<typename Scalar_, typename StorageIndex_>
class Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >

Stores a sparse set of values as a list of values and a list of indices.

Member Typedef Documentation

◆ RealScalar

template<typename Scalar_ , typename StorageIndex_ >
typedef NumTraits<Scalar>::Real Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::RealScalar
protected

◆ Scalar

template<typename Scalar_ , typename StorageIndex_ >
typedef Scalar_ Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::Scalar

◆ StorageIndex

template<typename Scalar_ , typename StorageIndex_ >
typedef StorageIndex_ Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::StorageIndex

Constructor & Destructor Documentation

◆ CompressedStorage() [1/3]

template<typename Scalar_ , typename StorageIndex_ >
Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::CompressedStorage ( )
inline
34 : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) {}
Index m_size
Definition: CompressedStorage.h:198
StorageIndex * m_indices
Definition: CompressedStorage.h:197
Scalar * m_values
Definition: CompressedStorage.h:196
Index m_allocatedSize
Definition: CompressedStorage.h:199

◆ CompressedStorage() [2/3]

template<typename Scalar_ , typename StorageIndex_ >
Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::CompressedStorage ( Index  size)
inlineexplicit
36 : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) { resize(size); }
Index size() const
Definition: CompressedStorage.h:94
void resize(Index size, double reserveSizeFactor=0)
Definition: CompressedStorage.h:72

References Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::resize(), and Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::size().

◆ CompressedStorage() [3/3]

template<typename Scalar_ , typename StorageIndex_ >
Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::CompressedStorage ( const CompressedStorage< Scalar_, StorageIndex_ > &  other)
inline
38  : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) {
39  *this = other;
40  }

◆ ~CompressedStorage()

template<typename Scalar_ , typename StorageIndex_ >
Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::~CompressedStorage ( )
inline

Member Function Documentation

◆ allocatedSize()

◆ append()

template<typename Scalar_ , typename StorageIndex_ >
void Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::append ( const Scalar v,
Index  i 
)
inline
87  {
88  Index id = m_size;
89  resize(m_size + 1, 1);
90  m_values[id] = v;
91  m_indices[id] = internal::convert_index<StorageIndex>(i);
92  }
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83

References i, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_indices, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_size, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_values, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::resize(), and v.

Referenced by Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::insertBackByOuterInner(), and Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::insertBackByOuterInnerUnordered().

◆ at()

template<typename Scalar_ , typename StorageIndex_ >
Scalar Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::at ( Index  key,
const Scalar defaultValue = Scalar(0) 
) const
inline
Returns
the stored value at index key If the value does not exist, then the value defaultValue is returned without any insertion.
131  {
132  if (m_size == 0)
133  return defaultValue;
134  else if (key == m_indices[m_size - 1])
135  return m_values[m_size - 1];
136  // ^^ optimization: let's first check if it is the last coefficient
137  // (very common in high level algorithms)
138  const Index id = searchLowerIndex(0, m_size - 1, key);
139  return ((id < m_size) && (m_indices[id] == key)) ? m_values[id] : defaultValue;
140  }
Index searchLowerIndex(Index key) const
Definition: CompressedStorage.h:122

References Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_indices, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_size, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_values, and Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::searchLowerIndex().

◆ atInRange()

template<typename Scalar_ , typename StorageIndex_ >
Scalar Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::atInRange ( Index  start,
Index  end,
Index  key,
const Scalar defaultValue = Scalar(0) 
) const
inline

Like at(), but the search is performed in the range [start,end)

143  {
144  if (start >= end)
145  return defaultValue;
146  else if (end > start && key == m_indices[end - 1])
147  return m_values[end - 1];
148  // ^^ optimization: let's first check if it is the last coefficient
149  // (very common in high level algorithms)
150  const Index id = searchLowerIndex(start, end - 1, key);
151  return ((id < end) && (m_indices[id] == key)) ? m_values[id] : defaultValue;
152  }
static constexpr lastp1_t end
Definition: IndexedViewHelper.h:79
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243

References Eigen::placeholders::end, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_indices, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_values, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::searchLowerIndex(), and oomph::CumulativeTimings::start().

Referenced by Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::coeff().

◆ atWithInsertion()

template<typename Scalar_ , typename StorageIndex_ >
Scalar& Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::atWithInsertion ( Index  key,
const Scalar defaultValue = Scalar(0) 
)
inline
Returns
a reference to the value at index key If the value does not exist, then the value defaultValue is inserted such that the keys are sorted.
157  {
158  Index id = searchLowerIndex(0, m_size, key);
159  if (id >= m_size || m_indices[id] != key) {
160  if (m_allocatedSize < m_size + 1) {
161  Index newAllocatedSize = 2 * (m_size + 1);
162  m_values = conditional_aligned_realloc_new_auto<Scalar, true>(m_values, newAllocatedSize, m_allocatedSize);
163  m_indices =
164  conditional_aligned_realloc_new_auto<StorageIndex, true>(m_indices, newAllocatedSize, m_allocatedSize);
165  m_allocatedSize = newAllocatedSize;
166  }
167  if (m_size > id) {
170  }
171  m_size++;
172  m_indices[id] = internal::convert_index<StorageIndex>(key);
173  m_values[id] = defaultValue;
174  }
175  return m_values[id];
176  }
void smart_memmove(const T *start, const T *end, T *target)
Definition: Memory.h:594

References Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_allocatedSize, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_indices, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_size, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_values, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::searchLowerIndex(), and Eigen::internal::smart_memmove().

◆ clear()

◆ index() [1/2]

◆ index() [2/2]

template<typename Scalar_ , typename StorageIndex_ >
const StorageIndex& Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::index ( Index  i) const
inline

◆ indexPtr() [1/2]

template<typename Scalar_ , typename StorageIndex_ >
StorageIndex* Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::indexPtr ( )
inline

◆ indexPtr() [2/2]

template<typename Scalar_ , typename StorageIndex_ >
const StorageIndex* Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::indexPtr ( ) const
inline

◆ moveChunk()

◆ operator=()

template<typename Scalar_ , typename StorageIndex_ >
CompressedStorage& Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::operator= ( const CompressedStorage< Scalar_, StorageIndex_ > &  other)
inline

◆ reallocate()

◆ reserve()

◆ resize()

template<typename Scalar_ , typename StorageIndex_ >
void Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::resize ( Index  size,
double  reserveSizeFactor = 0 
)
inline
72  {
73  if (m_allocatedSize < size) {
74  // Avoid underflow on the std::min<Index> call by choosing the smaller index type.
75  using SmallerIndexType =
76  typename std::conditional<static_cast<size_t>((std::numeric_limits<Index>::max)()) <
77  static_cast<size_t>((std::numeric_limits<StorageIndex>::max)()),
79  Index realloc_size =
80  (std::min<Index>)(NumTraits<SmallerIndexType>::highest(), size + Index(reserveSizeFactor * double(size)));
81  if (realloc_size < size) internal::throw_std_bad_alloc();
82  reallocate(realloc_size);
83  }
84  m_size = size;
85  }
StorageIndex_ StorageIndex
Definition: CompressedStorage.h:28
#define max(a, b)
Definition: datatypes.h:23
EIGEN_DEVICE_FUNC void throw_std_bad_alloc()
Definition: Memory.h:110
type
Definition: compute_granudrum_aor.py:141

References Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_allocatedSize, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_size, max, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::reallocate(), Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::size(), Eigen::internal::throw_std_bad_alloc(), and compute_granudrum_aor::type.

Referenced by Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::append(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::assignDiagonal(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::collapseDuplicates(), Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::CompressedStorage(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::conservativeResize(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::insertCompressedAtByOuterInner(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::insertUncompressedAtByOuterInner(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::makeCompressed(), Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::operator=(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::operator=(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::prune(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::reserveInnerVectors(), Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::resizeNonZeros(), and Eigen::SparseMatrix< Scalar_, Options_, StorageIndex_ >::setIdentity().

◆ searchLowerIndex() [1/2]

◆ searchLowerIndex() [2/2]

template<typename Scalar_ , typename StorageIndex_ >
Index Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::searchLowerIndex ( Index  start,
Index  end,
Index  key 
) const
inline
Returns
the largest k in [start,end) such that for all j in [start,k) index[j]<key
125  {
126  return static_cast<Index>(std::distance(m_indices, std::lower_bound(m_indices + start, m_indices + end, key)));
127  }

References Eigen::placeholders::end, Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::m_indices, and oomph::CumulativeTimings::start().

◆ size()

◆ squeeze()

◆ swap()

template<typename Scalar_ , typename StorageIndex_ >
void Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::swap ( CompressedStorage< Scalar_, StorageIndex_ > &  other)
inline

◆ value() [1/2]

◆ value() [2/2]

template<typename Scalar_ , typename StorageIndex_ >
const Scalar& Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::value ( Index  i) const
inline

◆ valuePtr() [1/2]

template<typename Scalar_ , typename StorageIndex_ >
Scalar* Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::valuePtr ( )
inline

◆ valuePtr() [2/2]

template<typename Scalar_ , typename StorageIndex_ >
const Scalar* Eigen::internal::CompressedStorage< Scalar_, StorageIndex_ >::valuePtr ( ) const
inline

Member Data Documentation

◆ m_allocatedSize

◆ m_indices

◆ m_size

◆ m_values


The documentation for this class was generated from the following file: