MOAB  4.9.3pre
Eigen::internal::CompressedStorage< _Scalar, _StorageIndex > Class Template Reference

#include <CompressedStorage.h>

Inheritance diagram for Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >:

List of all members.

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 prune (const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())

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.

Definition at line 22 of file CompressedStorage.h.


Member Typedef Documentation

template<typename _Scalar, typename _StorageIndex>
typedef NumTraits<Scalar>::Real Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::RealScalar [protected]

Definition at line 31 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
typedef _Scalar Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::Scalar

Definition at line 26 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
typedef _StorageIndex Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::StorageIndex

Definition at line 27 of file CompressedStorage.h.


Constructor & Destructor Documentation

template<typename _Scalar, typename _StorageIndex>
Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::CompressedStorage ( ) [inline]

Definition at line 35 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::CompressedStorage ( Index  size) [inline, explicit]

Definition at line 39 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::CompressedStorage ( const CompressedStorage< _Scalar, _StorageIndex > &  other) [inline]

Definition at line 45 of file CompressedStorage.h.

      : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)
    {
      *this = other;
    }
template<typename _Scalar, typename _StorageIndex>
Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::~CompressedStorage ( ) [inline]

Definition at line 70 of file CompressedStorage.h.

    {
      delete[] m_values;
      delete[] m_indices;
    }

Member Function Documentation

template<typename _Scalar, typename _StorageIndex>
Index Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::allocatedSize ( ) const [inline]

Definition at line 110 of file CompressedStorage.h.

{ return m_allocatedSize; }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::append ( const Scalar v,
Index  i 
) [inline]

Definition at line 101 of file CompressedStorage.h.

    {
      Index id = m_size;
      resize(m_size+1, 1);
      m_values[id] = v;
      m_indices[id] = internal::convert_index<StorageIndex>(i);
    }
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.

Definition at line 146 of file CompressedStorage.h.

    {
      if (m_size==0)
        return defaultValue;
      else if (key==m_indices[m_size-1])
        return m_values[m_size-1];
      // ^^  optimization: let's first check if it is the last coefficient
      // (very common in high level algorithms)
      const Index id = searchLowerIndex(0,m_size-1,key);
      return ((id<m_size) && (m_indices[id]==key)) ? m_values[id] : defaultValue;
    }
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)

Definition at line 159 of file CompressedStorage.h.

    {
      if (start>=end)
        return defaultValue;
      else if (end>start && key==m_indices[end-1])
        return m_values[end-1];
      // ^^  optimization: let's first check if it is the last coefficient
      // (very common in high level algorithms)
      const Index id = searchLowerIndex(start,end-1,key);
      return ((id<end) && (m_indices[id]==key)) ? m_values[id] : defaultValue;
    }
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.

Definition at line 174 of file CompressedStorage.h.

    {
      Index id = searchLowerIndex(0,m_size,key);
      if (id>=m_size || m_indices[id]!=key)
      {
        if (m_allocatedSize<m_size+1)
        {
          m_allocatedSize = 2*(m_size+1);
          internal::scoped_array<Scalar> newValues(m_allocatedSize);
          internal::scoped_array<StorageIndex> newIndices(m_allocatedSize);

          // copy first chunk
          internal::smart_copy(m_values,  m_values +id, newValues.ptr());
          internal::smart_copy(m_indices, m_indices+id, newIndices.ptr());

          // copy the rest
          if(m_size>id)
          {
            internal::smart_copy(m_values +id,  m_values +m_size, newValues.ptr() +id+1);
            internal::smart_copy(m_indices+id,  m_indices+m_size, newIndices.ptr()+id+1);
          }
          std::swap(m_values,newValues.ptr());
          std::swap(m_indices,newIndices.ptr());
        }
        else if(m_size>id)
        {
          internal::smart_memmove(m_values +id, m_values +m_size, m_values +id+1);
          internal::smart_memmove(m_indices+id, m_indices+m_size, m_indices+id+1);
        }
        m_size++;
        m_indices[id] = internal::convert_index<StorageIndex>(key);
        m_values[id] = defaultValue;
      }
      return m_values[id];
    }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::clear ( ) [inline]

Definition at line 111 of file CompressedStorage.h.

{ m_size = 0; }
template<typename _Scalar, typename _StorageIndex>
StorageIndex& Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::index ( Index  i) [inline]

Definition at line 121 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
const StorageIndex& Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::index ( Index  i) const [inline]

Definition at line 122 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
const StorageIndex* Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::indexPtr ( ) const [inline]

Definition at line 115 of file CompressedStorage.h.

{ return m_indices; }
template<typename _Scalar, typename _StorageIndex>
StorageIndex* Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::indexPtr ( ) [inline]

Definition at line 116 of file CompressedStorage.h.

{ return m_indices; }
template<typename _Scalar, typename _StorageIndex>
CompressedStorage& Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::operator= ( const CompressedStorage< _Scalar, _StorageIndex > &  other) [inline]

Definition at line 51 of file CompressedStorage.h.

    {
      resize(other.size());
      if(other.size()>0)
      {
        internal::smart_copy(other.m_values,  other.m_values  + m_size, m_values);
        internal::smart_copy(other.m_indices, other.m_indices + m_size, m_indices);
      }
      return *this;
    }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::prune ( const Scalar reference,
const RealScalar epsilon = NumTraits<RealScalar>::dummy_precision() 
) [inline]

Definition at line 210 of file CompressedStorage.h.

    {
      Index k = 0;
      Index n = size();
      for (Index i=0; i<n; ++i)
      {
        if (!internal::isMuchSmallerThan(value(i), reference, epsilon))
        {
          value(k) = value(i);
          index(k) = index(i);
          ++k;
        }
      }
      resize(k,0);
    }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::reallocate ( Index  size) [inline, protected]

Definition at line 228 of file CompressedStorage.h.

    {
      #ifdef EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN
        EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN
      #endif
      eigen_internal_assert(size!=m_allocatedSize);
      internal::scoped_array<Scalar> newValues(size);
      internal::scoped_array<StorageIndex> newIndices(size);
      Index copySize = (std::min)(size, m_size);
      if (copySize>0) {
        internal::smart_copy(m_values, m_values+copySize, newValues.ptr());
        internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr());
      }
      std::swap(m_values,newValues.ptr());
      std::swap(m_indices,newIndices.ptr());
      m_allocatedSize = size;
    }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::reserve ( Index  size) [inline]

Definition at line 76 of file CompressedStorage.h.

    {
      Index newAllocatedSize = m_size + size;
      if (newAllocatedSize > m_allocatedSize)
        reallocate(newAllocatedSize);
    }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::resize ( Index  size,
double  reserveSizeFactor = 0 
) [inline]

Definition at line 89 of file CompressedStorage.h.

    {
      if (m_allocatedSize<size)
      {
        Index realloc_size = (std::min<Index>)(NumTraits<StorageIndex>::highest(),  size + Index(reserveSizeFactor*double(size)));
        if(realloc_size<size)
          internal::throw_std_bad_alloc();
        reallocate(realloc_size);
      }
      m_size = size;
    }
template<typename _Scalar, typename _StorageIndex>
Index Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::searchLowerIndex ( Index  key) const [inline]
Returns:
the largest k such that for all j in [0,k) index[j]<key

Definition at line 125 of file CompressedStorage.h.

    {
      return searchLowerIndex(0, m_size, key);
    }
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

Definition at line 131 of file CompressedStorage.h.

    {
      while(end>start)
      {
        Index mid = (end+start)>>1;
        if (m_indices[mid]<key)
          start = mid+1;
        else
          end = mid;
      }
      return start;
    }
template<typename _Scalar, typename _StorageIndex>
Index Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::size ( ) const [inline]

Definition at line 109 of file CompressedStorage.h.

{ return m_size; }
template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::squeeze ( ) [inline]

Definition at line 83 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
void Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::swap ( CompressedStorage< _Scalar, _StorageIndex > &  other) [inline]

Definition at line 62 of file CompressedStorage.h.

    {
      std::swap(m_values, other.m_values);
      std::swap(m_indices, other.m_indices);
      std::swap(m_size, other.m_size);
      std::swap(m_allocatedSize, other.m_allocatedSize);
    }
template<typename _Scalar, typename _StorageIndex>
Scalar& Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::value ( Index  i) [inline]

Definition at line 118 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
const Scalar& Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::value ( Index  i) const [inline]

Definition at line 119 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
const Scalar* Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::valuePtr ( ) const [inline]

Definition at line 113 of file CompressedStorage.h.

{ return m_values; }
template<typename _Scalar, typename _StorageIndex>
Scalar* Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::valuePtr ( ) [inline]

Definition at line 114 of file CompressedStorage.h.

{ return m_values; }

Member Data Documentation

template<typename _Scalar, typename _StorageIndex>
Index Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::m_allocatedSize [protected]

Definition at line 250 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
StorageIndex* Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::m_indices [protected]

Definition at line 248 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
Index Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::m_size [protected]

Definition at line 249 of file CompressedStorage.h.

template<typename _Scalar, typename _StorageIndex>
Scalar* Eigen::internal::CompressedStorage< _Scalar, _StorageIndex >::m_values [protected]

Definition at line 247 of file CompressedStorage.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines