remora::compressed_vector< T, I > Class Template Reference

Compressed array based sparse vector. More...

#include <shark/LinAlg/BLAS/vector_sparse.hpp>

+ Inheritance diagram for remora::compressed_vector< T, I >:

Classes

class  reference
 

Public Types

typedef const T & const_reference
 
typedef elementwise< sparse_tag > evaluation_category
 
typedef iterators::compressed_storage_iterator< value_type const, size_type const > const_iterator
 
typedef iterators::compressed_storage_iterator< value_type, size_type const > iterator
 

Public Member Functions

 compressed_vector ()
 
 compressed_vector (size_type size, value_type value=value_type(), size_type non_zeros=0)
 
template<class AE >
 compressed_vector (vector_expression< AE, cpu_tag > const &ae, size_type non_zeros=0)
 
size_type size () const
 
size_type nnz_capacity () const
 
size_type nnz () const
 
void set_filled (size_type filled)
 
storage_type raw_storage ()
 Returns the underlying storage structure for low level access. More...
 
const_storage_type raw_storage () const
 Returns the underlying storage structure for low level access. More...
 
device_traits< cpu_tag >::queue_type & queue ()
 
void resize (size_type size)
 
void reserve (size_type non_zeros)
 
const_reference operator() (size_type i) const
 
reference operator() (size_type i)
 
const_reference operator[] (size_type i) const
 
reference operator[] (size_type i)
 
void clear ()
 
compressed_vectoroperator= (compressed_vector const &v)
 
template<class C >
compressed_vectoroperator= (vector_container< C, cpu_tag > const &v)
 
template<class AE >
compressed_vectoroperator= (vector_expression< AE, cpu_tag > const &ae)
 
void swap (compressed_vector &v)
 
const_iterator begin () const
 
const_iterator end () const
 
iterator begin ()
 
iterator end ()
 
iterator set_element (iterator pos, size_type index, value_type value)
 
iterator clear_range (iterator start, iterator end)
 
iterator clear_element (iterator pos)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int)
 
- Public Member Functions inherited from remora::vector_container< compressed_vector< T, I >, cpu_tag >
const container_type & operator() () const
 
container_type & operator() ()
 
- Public Member Functions inherited from remora::vector_expression< compressed_vector< T, I >, cpu_tag >
const expression_type & operator() () const
 
expression_type & operator() ()
 

Friends

void swap (compressed_vector &v1, compressed_vector &v2)
 

Detailed Description

template<class T, class I = std::size_t>
class remora::compressed_vector< T, I >

Compressed array based sparse vector.

a sparse vector of values of type T of variable size. The non zero values are stored as two seperate arrays: an index array and a value array. The index array is always sorted and there is at most one entry for each index. Inserting an element can be time consuming. If the vector contains a few zero entries, then it is better to have a normal vector. If the vector has a very high dimension with a few non-zero values, then this vector is very memory efficient (at the cost of a few more computations).

For a \(n\)-dimensional compressed vector and \(0 \leq i < n\) the non-zero elements \(v_i\) are mapped to consecutive elements of the index and value container, i.e. for elements \(k = v_{i_1}\) and \(k + 1 = v_{i_2}\) of these containers holds \(i_1 < i_2\).

Supported parameters for the adapted array (indices and values) are unbounded_array<> , bounded_array<> and std::vector<>.

Template Parameters
Tthe type of object stored in the vector (like double, float, complex, etc...)
Ithe indices stored in the vector

Definition at line 60 of file vector_sparse.hpp.

Member Typedef Documentation

◆ const_iterator

template<class T , class I = std::size_t>
typedef iterators::compressed_storage_iterator<value_type const, size_type const> remora::compressed_vector< T, I >::const_iterator

Definition at line 251 of file vector_sparse.hpp.

◆ const_reference

template<class T , class I = std::size_t>
typedef const T& remora::compressed_vector< T, I >::const_reference

Definition at line 66 of file vector_sparse.hpp.

◆ evaluation_category

template<class T , class I = std::size_t>
typedef elementwise<sparse_tag> remora::compressed_vector< T, I >::evaluation_category

Definition at line 138 of file vector_sparse.hpp.

◆ iterator

template<class T , class I = std::size_t>
typedef iterators::compressed_storage_iterator<value_type, size_type const> remora::compressed_vector< T, I >::iterator

Definition at line 252 of file vector_sparse.hpp.

Constructor & Destructor Documentation

◆ compressed_vector() [1/3]

template<class T , class I = std::size_t>
remora::compressed_vector< T, I >::compressed_vector ( )
inline

Definition at line 141 of file vector_sparse.hpp.

◆ compressed_vector() [2/3]

template<class T , class I = std::size_t>
remora::compressed_vector< T, I >::compressed_vector ( size_type  size,
value_type  value = value_type(),
size_type  non_zeros = 0 
)
inlineexplicit

Definition at line 142 of file vector_sparse.hpp.

◆ compressed_vector() [3/3]

template<class T , class I = std::size_t>
template<class AE >
remora::compressed_vector< T, I >::compressed_vector ( vector_expression< AE, cpu_tag > const &  ae,
size_type  non_zeros = 0 
)
inline

Definition at line 145 of file vector_sparse.hpp.

References remora::assign().

Member Function Documentation

◆ begin() [1/2]

◆ begin() [2/2]

template<class T , class I = std::size_t>
iterator remora::compressed_vector< T, I >::begin ( )
inline

Definition at line 262 of file vector_sparse.hpp.

◆ clear()

template<class T , class I = std::size_t>
void remora::compressed_vector< T, I >::clear ( )
inline

Definition at line 213 of file vector_sparse.hpp.

◆ clear_element()

template<class T , class I = std::size_t>
iterator remora::compressed_vector< T, I >::clear_element ( iterator  pos)
inline

◆ clear_range()

template<class T , class I = std::size_t>
iterator remora::compressed_vector< T, I >::clear_range ( iterator  start,
iterator  end 
)
inline

Definition at line 300 of file vector_sparse.hpp.

References remora::compressed_vector< T, I >::begin().

◆ end() [1/2]

◆ end() [2/2]

template<class T , class I = std::size_t>
iterator remora::compressed_vector< T, I >::end ( )
inline

Definition at line 266 of file vector_sparse.hpp.

References remora::compressed_vector< T, I >::nnz().

◆ nnz()

template<class T , class I = std::size_t>
size_type remora::compressed_vector< T, I >::nnz ( ) const
inline

◆ nnz_capacity()

◆ operator()() [1/2]

template<class T , class I = std::size_t>
const_reference remora::compressed_vector< T, I >::operator() ( size_type  i) const
inline

Definition at line 193 of file vector_sparse.hpp.

References remora::compressed_vector< T, I >::nnz().

◆ operator()() [2/2]

template<class T , class I = std::size_t>
reference remora::compressed_vector< T, I >::operator() ( size_type  i)
inline

◆ operator=() [1/3]

template<class T , class I = std::size_t>
compressed_vector& remora::compressed_vector< T, I >::operator= ( compressed_vector< T, I > const &  v)
inline

Definition at line 218 of file vector_sparse.hpp.

◆ operator=() [2/3]

template<class T , class I = std::size_t>
template<class C >
compressed_vector& remora::compressed_vector< T, I >::operator= ( vector_container< C, cpu_tag > const &  v)
inline

◆ operator=() [3/3]

template<class T , class I = std::size_t>
template<class AE >
compressed_vector& remora::compressed_vector< T, I >::operator= ( vector_expression< AE, cpu_tag > const &  ae)
inline

◆ operator[]() [1/2]

template<class T , class I = std::size_t>
const_reference remora::compressed_vector< T, I >::operator[] ( size_type  i) const
inline

Definition at line 205 of file vector_sparse.hpp.

◆ operator[]() [2/2]

template<class T , class I = std::size_t>
reference remora::compressed_vector< T, I >::operator[] ( size_type  i)
inline

Definition at line 208 of file vector_sparse.hpp.

◆ queue()

template<class T , class I = std::size_t>
device_traits<cpu_tag>::queue_type& remora::compressed_vector< T, I >::queue ( )
inline

Definition at line 177 of file vector_sparse.hpp.

◆ raw_storage() [1/2]

template<class T , class I = std::size_t>
storage_type remora::compressed_vector< T, I >::raw_storage ( )
inline

Returns the underlying storage structure for low level access.

Definition at line 168 of file vector_sparse.hpp.

◆ raw_storage() [2/2]

template<class T , class I = std::size_t>
const_storage_type remora::compressed_vector< T, I >::raw_storage ( ) const
inline

Returns the underlying storage structure for low level access.

Definition at line 173 of file vector_sparse.hpp.

◆ reserve()

template<class T , class I = std::size_t>
void remora::compressed_vector< T, I >::reserve ( size_type  non_zeros)
inline

◆ resize()

template<class T , class I = std::size_t>
void remora::compressed_vector< T, I >::resize ( size_type  size)
inline

◆ serialize()

template<class T , class I = std::size_t>
template<class Archive >
void remora::compressed_vector< T, I >::serialize ( Archive &  ar,
const unsigned  int 
)
inline

◆ set_element()

◆ set_filled()

template<class T , class I = std::size_t>
void remora::compressed_vector< T, I >::set_filled ( size_type  filled)
inline

◆ size()

template<class T , class I = std::size_t>
size_type remora::compressed_vector< T, I >::size ( ) const
inline

◆ swap()

template<class T , class I = std::size_t>
void remora::compressed_vector< T, I >::swap ( compressed_vector< T, I > &  v)
inline

Definition at line 239 of file vector_sparse.hpp.

References shark::swap().

Referenced by remora::compressed_vector< T, I >::operator=().

Friends And Related Function Documentation

◆ swap

template<class T , class I = std::size_t>
void swap ( compressed_vector< T, I > &  v1,
compressed_vector< T, I > &  v2 
)
friend

Definition at line 246 of file vector_sparse.hpp.


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