Feature Selection Toolbox FST4
UTIA · Czech Academy of Sciences
Loading...
Searching...
No Matches
FST::Indexed_Vector< DATATYPE, DIMTYPE, SUBSET > Class Template Reference

Vector representation and operations, allows operation in selected subspace. Also serves as the helper structure for passing matrix-operation intermediate data between higher-level matrix objects and functions. More...

#include <indexed_vector.hpp>

Public Types

typedef std::shared_ptr< SUBSET > PSubset
 shared pointer to a feature subset (the narrowing selector)

Public Member Functions

 Indexed_Vector (const DIMTYPE n)
 allocates for n features via reset(); starts unnarrowed (get_n()==get_d()==n)
 Indexed_Vector (const Indexed_Vector &iv)
 copy-constructor (deep-copies the raw buffer and the index map)
Indexed_Vector & operator= (Indexed_Vector const &iv)
 deep-copy assignment (reallocates only if iv's capacity differs)
void reset (const DIMTYPE n_max)
 (re)allocates for n_max features and resets to full, unnarrowed dimensionality (get_n()==get_d()==n_max, identity index map)
void redim (const DIMTYPE n=0)
 keeps the existing allocation (reset() must have run already), resets to an unnarrowed identity index map, and sets get_n()==get_d()==n (n==0 means the full allocated capacity)
DATATYPE & operator[] (const DIMTYPE i)
 raw (unindexed) element access, i in [0,get_n())
DATATYPE & at_raw (const DIMTYPE i)
 raw (unindexed) element access, i in [0,get_n()) – same as operator[]
DATATYPE & at (const DIMTYPE i)
 indexed access through the narrow_to() subset map, i in [0,get_d())
DATATYPE * get_raw ()
 raw pointer to the underlying buffer (get_n() valid entries)
const DATATYPE & operator[] (const DIMTYPE i) const
 read-only raw (unindexed) element access, i in [0,get_n())
const DATATYPE & at_raw (const DIMTYPE i) const
 read-only raw (unindexed) element access – same as the const operator[]
const DATATYPE & at (const DIMTYPE i) const
 read-only indexed access through the narrow_to() subset map, i in [0,get_d())
const DATATYPE * get_raw () const
 read-only raw pointer to the underlying buffer (get_n() valid entries)
void narrow_to (const PSubset sub)
 fill _index[] -> access to data is then mapped to sub-vector; get_d() becomes the subset size.
void denarrow ()
 reset _index[] -> access is reset to the full vector (identity map, get_d()==get_n())
DIMTYPE get_n () const
 the full ("raw") dimensionality set by reset()/redim()
DIMTYPE get_d () const
 the current virtual (narrow_to()'d) dimensionality, get_d()<=get_n()
void set_all_raw_to (const DATATYPE val)
 sets all get_n() raw entries to val (ignores the index map)
void subtract_raw (const Indexed_Vector &vr)
 this -= vr, elementwise over the raw get_n() entries (requires vr.get_n()==get_n())
void copy_raw (const Indexed_Vector &vr)
 this = vr, elementwise over the raw get_n() entries (requires vr.get_n()==get_n())

Protected Attributes

DIMTYPE _n_max
 allocated capacity: _data/_index can hold up to _n_max elements
DIMTYPE _n
 full ("raw") dimensionality currently in use, _n<=_n_max; see get_n()
std::unique_ptr< DATATYPE[]> _data
 raw vector data buffer (_n_max entries allocated)
DIMTYPE _d
 current virtual (narrow_to()'d) sub-vector dimensionality, _d<=_n; see get_d()
std::unique_ptr< DIMTYPE[]> _index
 maps virtual sub-vector _d dimensions to original _n dimensions (identity after reset()/redim()/denarrow(), set by narrow_to())

Friends

class Indexed_Matrix< DATATYPE, DIMTYPE, SUBSET >
std::ostream & operator<< (std::ostream &os, const Indexed_Vector &tdb)
 grants operator<< access to print this object's contents (see the out-of-class definition below)

Detailed Description

template<typename DATATYPE, typename DIMTYPE, class SUBSET>
class FST::Indexed_Vector< DATATYPE, DIMTYPE, SUBSET >

Vector representation and operations, allows operation in selected subspace. Also serves as the helper structure for passing matrix-operation intermediate data between higher-level matrix objects and functions.

Member Function Documentation

◆ narrow_to()

template<typename DATATYPE, typename DIMTYPE, class SUBSET>
void FST::Indexed_Vector< DATATYPE, DIMTYPE, SUBSET >::narrow_to ( const PSubset sub)

fill _index[] -> access to data is then mapped to sub-vector; get_d() becomes the subset size.

Precondition
reset()/redim() has run and get_n() is at least the subset size; sub selects at least one feature. Only at() follows the map - the raw accessors and the *_raw() operations keep addressing all get_n() entries.

◆ operator<<

template<typename DATATYPE, typename DIMTYPE, class SUBSET>
std::ostream & operator<< ( std::ostream & os,
const Indexed_Vector< DATATYPE, DIMTYPE, SUBSET > & tdb )
friend

grants operator<< access to print this object's contents (see the out-of-class definition below)

Note
The printed data row applies the _index map (tdb._data[tdb._index[j]]), the same convention as Indexed_Matrix's operator<< – what is printed is genuinely the narrow_to()'d sub-vector, so the two printed rows are "index -> value" pairs. Debug-only: neither this operator<< nor the matrix one is invoked anywhere in the library, they exist for interactive debugging.

The documentation for this class was generated from the following files:
Copyright © 2000–present ÚTIA, Institute of Information Theory and Automation of the Czech Academy of Sciences · Contacts · This site sets no cookies and uses no analytics.