Polymake Template Library (PTL) 4.13
polymake::SparseVector< E > Class Template Reference

#include <SparseVector.h>

Inheritance diagram for polymake::SparseVector< E >:
Collaboration diagram for polymake::SparseVector< E >:

Public Types

using element_type
 element type
 
using element_type
 element type
 
using element_type
 element type
 
using persistent_type
 persistent type
 
using persistent_type
 persistent type
 
using persistent_type
 persistent type
 
using generic_type
 generic type
 
using generic_type
 generic type
 
using generic_type
 generic type
 

Public Member Functions

Int dim () const
 tell the current vector dimension, i.e., the number of non-zero elements (may differ from size)
 
 SparseVector ()
 create as empty
 
 SparseVector (Int dim_arg)
 create vector of length n, (implicitly) initialize all elements with 0
 
template<typename Iterator, bool enabled = construct_sparse_iterator<Iterator, E>::enabled>
 SparseVector (Int dim_arg, Iterator &&src)
 
 SparseVector (const GenericVector< SparseVector > &v)
 Copy of a disguised SparseVector object.
 
template<typename Vector2>
 SparseVector (const GenericVector< Vector2, E > &v)
 Create a vector as a copy of another vector of the same element type.
 
template<typename Vector2, typename E2>
 SparseVector (const GenericVector< Vector2, E2 > &v, std::enable_if_t< can_initialize< E2, E >::value, std::nullptr_t >=nullptr)
 Create a vector as a copy of another vector with a different element type.
 
template<typename E2, typename = std::enable_if_t<can_initialize<E2, E>::value>>
 SparseVector (std::initializer_list< E2 > l)
 
 SparseVector (Int d, std::initializer_list< std::pair< Int, E > > l)
 
void clear ()
 truncate to zero size
 
void resize (Int n)
 change the size, initialize appended elements with default constructor
 
reference operator[] (Int i)
 random access, may cost O(log(n)) time; Performance Comparison of Vector Classes
 
const E & operator[] (Int i) const
 constant random access, may cost O(log(n)) time; Performance Comparison of Vector Classes
 
template<typename Vector2, typename E2, typename = std::enable_if_t<can_initialize<E2, E>::value>>
SparseVectoroperator|= (const GenericVector< Vector2, E2 > &v)
 append a GenericVector
 
template<typename E2, typename = std::enable_if_t<can_initialize<E2, E>::value>>
SparseVectoroperator|= (E2 &&r)
 append an element
 
template<typename E2, typename = std::enable_if_t<can_initialize<E2, E>::value>>
SparseVectoroperator|= (std::initializer_list< E2 > l)
 
void remove0s ()
 remove all zero elements which might have been overseen in some previous operation
 
void remove0s ()
 remove all zero elements which might have been overseen in some previous operation
 
void remove0s ()
 remove all zero elements which might have been overseen in some previous operation
 
top_type & negate ()
 negate elements in place
 
top_type & negate ()
 negate elements in place
 
top_type & negate ()
 negate elements in place
 
top_type & dehomogenize ()
 divide by the first element
 
top_type & dehomogenize ()
 divide by the first element
 
top_type & dehomogenize ()
 divide by the first element
 
top_type & dehomogenize_trop ()
 subtracts first element
 
top_type & dehomogenize_trop ()
 subtracts first element
 
top_type & dehomogenize_trop ()
 subtracts first element
 
IndexedSlice< const typename Unwary< SparseVector< E > >::type &, typename final_index_set< IndexSetRef >::type > slice (IndexSetRef &&indices, std::enable_if_t< isomorphic_to_container_of< pure_type_t< IndexSetRef >, Int >::value, std::nullptr_t >=nullptr) const &
 
IndexedSlice< const typename Unwary< SparseVector< E > >::type &, typename final_index_set< IndexSetRef >::type > slice (IndexSetRef &&indices, std::enable_if_t< isomorphic_to_container_of< pure_type_t< IndexSetRef >, Int >::value, std::nullptr_t >=nullptr) const &
 
IndexedSlice< const typename Unwary< SparseVector< E > >::type &, typename final_index_set< IndexSetRef >::type > slice (IndexSetRef &&indices, std::enable_if_t< isomorphic_to_container_of< pure_type_t< IndexSetRef >, Int >::value, std::nullptr_t >=nullptr) const &
 

Static Public Attributes

static constexpr bool is_sparse
 determine if the persistent type is sparse
 
static constexpr bool is_sparse
 determine if the persistent type is sparse
 
static constexpr bool is_sparse
 determine if the persistent type is sparse
 

Detailed Description

template<typename E>
class polymake::SparseVector< E >

Vector type class which is an associative container with element indices (coordinates) as keys; elements equal to the default value (ElementType(), which is 0 for most numerical types) are not stored, but implicitly encoded by the gaps in the key set. It is based on an AVL tree.

Constructor & Destructor Documentation

◆ SparseVector() [1/3]

template<typename E>
template<typename Iterator, bool enabled = construct_sparse_iterator<Iterator, E>::enabled>
pm::SparseVector< E >::SparseVector ( Int dim_arg,
Iterator && src )
inline

Create a vector of dimension n, initialize the elements from a data sequence. Iterator can be either indexed, or supply index-value pairs, e.g. std::pair<Int, ElementType> or a plain sequence of data items. In the latter case zero elements are filtered out.

◆ SparseVector() [2/3]

template<typename E>
template<typename E2, typename = std::enable_if_t<can_initialize<E2, E>::value>>
pm::SparseVector< E >::SparseVector ( std::initializer_list< E2 > l)
inline

Create a vector from a list of values. Zeroes are filtered out automatically.

◆ SparseVector() [3/3]

template<typename E>
pm::SparseVector< E >::SparseVector ( Int d,
std::initializer_list< std::pair< Int, E > > l )
inline

Create a vector from a list of (index, value) pairs. Parameter d specifies the dimension. Indices don't have to come in ascending order; zero values are not detected.

Member Function Documentation

◆ operator|=()

template<typename E>
template<typename E2, typename = std::enable_if_t<can_initialize<E2, E>::value>>
SparseVector & pm::SparseVector< E >::operator|= ( std::initializer_list< E2 > l)
inline

append a list of elements zeroes are filtered out automatically

◆ slice() [1/3]

IndexedSlice< const typename Unwary< SparseVector< E > >::type &, typename final_index_set< IndexSetRef >::type > pm::GenericVector< SparseVector< E >, E >::slice ( IndexSetRef && indices,
std::enable_if_t< isomorphic_to_container_of< pure_type_t< IndexSetRef >, Int >::value, std::nullptr_t > = nullptr ) const &
inlineinherited

Select a vector slice consisting of elements with given indices. The last variant selects a contiguous range of indices beginning with start. size==-1 means up to the end of the vector. The const variants of these methods create immutable slice objects. The indices must lie in the valid range.

◆ slice() [2/3]

IndexedSlice< const typename Unwary< SparseVector< E > >::type &, typename final_index_set< IndexSetRef >::type > pm::GenericVector< SparseVector< E >, E >::slice ( IndexSetRef && indices,
std::enable_if_t< isomorphic_to_container_of< pure_type_t< IndexSetRef >, Int >::value, std::nullptr_t > = nullptr ) const &
inlineinherited

Select a vector slice consisting of elements with given indices. The last variant selects a contiguous range of indices beginning with start. size==-1 means up to the end of the vector. The const variants of these methods create immutable slice objects. The indices must lie in the valid range.

◆ slice() [3/3]

IndexedSlice< const typename Unwary< SparseVector< E > >::type &, typename final_index_set< IndexSetRef >::type > pm::GenericVector< SparseVector< E >, E >::slice ( IndexSetRef && indices,
std::enable_if_t< isomorphic_to_container_of< pure_type_t< IndexSetRef >, Int >::value, std::nullptr_t > = nullptr ) const &
inlineinherited

Select a vector slice consisting of elements with given indices. The last variant selects a contiguous range of indices beginning with start. size==-1 means up to the end of the vector. The const variants of these methods create immutable slice objects. The indices must lie in the valid range.


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