Turi Create  4.0
turi::vector_index_mapper Class Reference

#include <toolkits/sparse_similarity/index_mapper.hpp>

Public Member Functions

bool is_identity () const
 
size_t set_index_mapping_from_mask (const dense_bitset &is_active_entry)
 
template<typename T >
GL_HOT_FLATTEN void remap_vector (std::vector< T > &data_vect) const
 
template<typename T >
GL_HOT_FLATTEN void remap_sparse_vector (std::vector< std::pair< size_t, T > > &data_vect) const
 
bool is_active (size_t data_idx) const GL_HOT_INLINE_FLATTEN
 
size_t map_data_index_to_internal_index (size_t data_idx) const GL_HOT_INLINE_FLATTEN
 
size_t map_internal_index_to_data_index (size_t internal_idx) const GL_HOT_INLINE_FLATTEN
 

Detailed Description

Index Mapping. Just a simple utility to allow mapping indices to a subset of them based on a bitmask. Upon construction, the index mapping is the identity; after an index mapping is applied, vectors of the original indices can be remapped to other

Definition at line 19 of file index_mapper.hpp.

Member Function Documentation

◆ is_active()

bool turi::vector_index_mapper::is_active ( size_t  data_idx) const
inline

Is a given entry still active?

Definition at line 142 of file index_mapper.hpp.

◆ is_identity()

bool turi::vector_index_mapper::is_identity ( ) const
inline

Is the current mapping the identity?

Definition at line 30 of file index_mapper.hpp.

◆ map_data_index_to_internal_index()

size_t turi::vector_index_mapper::map_data_index_to_internal_index ( size_t  data_idx) const
inline

What's the internal mapped index for the given entry?

Definition at line 148 of file index_mapper.hpp.

◆ map_internal_index_to_data_index()

size_t turi::vector_index_mapper::map_internal_index_to_data_index ( size_t  internal_idx) const
inline

What's the external index here?

Definition at line 159 of file index_mapper.hpp.

◆ remap_sparse_vector()

template<typename T >
GL_HOT_FLATTEN void turi::vector_index_mapper::remap_sparse_vector ( std::vector< std::pair< size_t, T > > &  data_vect) const
inline

Remaps a sparse vector of (index, value) pairs inplace such that only active indices are kept and the rest are discarded. Active indices are remapped.

The vector is unchanged if is_identity() is true.

Definition at line 110 of file index_mapper.hpp.

◆ remap_vector()

template<typename T >
GL_HOT_FLATTEN void turi::vector_index_mapper::remap_vector ( std::vector< T > &  data_vect) const
inline

Remaps a vector inplace such that only active indices are kept, and the rest are discarded. Effectively, this applies the mask given to set_index_mapping_from_mask to this vector. In the new vector, entry i in the original will then be entry map_data_index_to_internal_index(i) in the remapped vector.

The vector is unchanged if is_identity() is true.

Definition at line 82 of file index_mapper.hpp.

◆ set_index_mapping_from_mask()

size_t turi::vector_index_mapper::set_index_mapping_from_mask ( const dense_bitset is_active_entry)
inline

Applies a mapping to the vertices so that only a subset of them are active, and each of these are mapped to a contiguous set of indices, 0, ..., n_active-1.

Definition at line 38 of file index_mapper.hpp.


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