Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
Eigen::internal::CompressedStorage< _Scalar, _Index > Class Template Reference

Public Types

typedef _Scalar Scalar
 
typedef _Index Index
 

Public Member Functions

 CompressedStorage (size_t size)
 
 CompressedStorage (const CompressedStorage &other)
 
CompressedStorageoperator= (const CompressedStorage &other)
 
void swap (CompressedStorage &other)
 
void reserve (size_t size)
 
void squeeze ()
 
void resize (size_t size, float reserveSizeFactor=0)
 
void append (const Scalar &v, Index i)
 
size_t size () const
 
size_t allocatedSize () const
 
void clear ()
 
Scalar & value (size_t i)
 
const Scalar & value (size_t i) const
 
Index & index (size_t i)
 
const Index & index (size_t i) const
 
Index searchLowerIndex (Index key) const
 
Index searchLowerIndex (size_t start, size_t end, Index key) const
 
Scalar at (Index key, const Scalar &defaultValue=Scalar(0)) const
 
Scalar atInRange (size_t start, size_t end, Index key, const Scalar &defaultValue=Scalar(0)) const
 
Scalar & atWithInsertion (Index key, const Scalar &defaultValue=Scalar(0))
 
void prune (const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())
 

Static Public Member Functions

static CompressedStorage Map (Index *indices, Scalar *values, size_t size)
 

Protected Types

typedef NumTraits< Scalar >::Real RealScalar
 

Protected Member Functions

void reallocate (size_t size)
 

Protected Attributes

Scalar * m_values
 
Index * m_indices
 
size_t m_size
 
size_t m_allocatedSize
 

Detailed Description

template<typename _Scalar, typename _Index>
class Eigen::internal::CompressedStorage< _Scalar, _Index >

Definition at line 22 of file CompressedStorage.h.

Member Function Documentation

template<typename _Scalar, typename _Index>
Scalar Eigen::internal::CompressedStorage< _Scalar, _Index >::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.

Definition at line 142 of file CompressedStorage.h.

143  {
144  if (m_size==0)
145  return defaultValue;
146  else if (key==m_indices[m_size-1])
147  return m_values[m_size-1];
148  // ^^ optimization: let's first check if it is the last coefficient
149  // (very common in high level algorithms)
150  const size_t id = searchLowerIndex(0,m_size-1,key);
151  return ((id<m_size) && (m_indices[id]==key)) ? m_values[id] : defaultValue;
152  }
Index searchLowerIndex(Index key) const
template<typename _Scalar, typename _Index>
Scalar Eigen::internal::CompressedStorage< _Scalar, _Index >::atInRange ( size_t  start,
size_t  end,
Index  key,
const Scalar &  defaultValue = Scalar(0) 
) const
inline

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

Definition at line 155 of file CompressedStorage.h.

156  {
157  if (start>=end)
158  return Scalar(0);
159  else if (end>start && key==m_indices[end-1])
160  return m_values[end-1];
161  // ^^ optimization: let's first check if it is the last coefficient
162  // (very common in high level algorithms)
163  const size_t id = searchLowerIndex(start,end-1,key);
164  return ((id<end) && (m_indices[id]==key)) ? m_values[id] : defaultValue;
165  }
Index searchLowerIndex(Index key) const
template<typename _Scalar, typename _Index>
Scalar& Eigen::internal::CompressedStorage< _Scalar, _Index >::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.

Definition at line 170 of file CompressedStorage.h.

171  {
172  size_t id = searchLowerIndex(0,m_size,key);
173  if (id>=m_size || m_indices[id]!=key)
174  {
175  resize(m_size+1,1);
176  for (size_t j=m_size-1; j>id; --j)
177  {
178  m_indices[j] = m_indices[j-1];
179  m_values[j] = m_values[j-1];
180  }
181  m_indices[id] = key;
182  m_values[id] = defaultValue;
183  }
184  return m_values[id];
185  }
Index searchLowerIndex(Index key) const
template<typename _Scalar, typename _Index>
Index Eigen::internal::CompressedStorage< _Scalar, _Index >::searchLowerIndex ( Index  key) const
inline
Returns
the largest k such that for all j in [0,k) index[j]<key

Definition at line 121 of file CompressedStorage.h.

122  {
123  return searchLowerIndex(0, m_size, key);
124  }
Index searchLowerIndex(Index key) const
template<typename _Scalar, typename _Index>
Index Eigen::internal::CompressedStorage< _Scalar, _Index >::searchLowerIndex ( size_t  start,
size_t  end,
Index  key 
) const
inline
Returns
the largest k in [start,end) such that for all j in [start,k) index[j]<key

Definition at line 127 of file CompressedStorage.h.

128  {
129  while(end>start)
130  {
131  size_t mid = (end+start)>>1;
132  if (m_indices[mid]<key)
133  start = mid+1;
134  else
135  end = mid;
136  }
137  return static_cast<Index>(start);
138  }

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