Implements a container class for multi-indexed objects with an arbitrary number of indices. More...
#include <MultiIndex.h>
Classes | |
| class | const_noconst_iterator |
| MultiIndex container iterator. More... | |
Public Types | |
| typedef T | value_type |
| container related types and categories More... | |
| typedef std::vector< unsigned int > | size_type |
| using | iterator = const_noconst_iterator< false > |
| using | const_iterator = const_noconst_iterator< true > |
Public Member Functions | |
| MultiIndex (const size_type &shape) | |
| construct zero initialized container of a given shape More... | |
| MultiIndex (const size_type &shape, const std::vector< T > &data) | |
| construct container of a given shape initialized from a flat data blob More... | |
| const size_type & | size () const |
| container size as dim dimensional vector More... | |
| unsigned int | dim () const |
| dimension of the container More... | |
| unsigned int | nEntries () const |
| total number of values stored in the container More... | |
| std::vector< T > | getRawData () const |
| get the raw data vector More... | |
| void | resize (const size_type &shape) |
| Resize container. Must keep dimensionality constant. More... | |
| void | assign (const size_type &shape, T value) |
| Reshape container arbitrarily and initialize with value. More... | |
| unsigned int | flatIndex (const size_type &indices) const |
| compute the flat index for a size_type index More... | |
| T & | operator() (const size_type &indices) |
| element access operators More... | |
| const T & | operator() (const size_type &indices) const |
| T & | operator[] (unsigned int j) |
| direct data access via bracket operator More... | |
| const T & | operator[] (unsigned int j) const |
| T & | at (unsigned int j) |
| MultiIndex< T > | slice (unsigned int dimension, unsigned int index) const |
| accesses a slice of the multi index object More... | |
| MultiIndex< T > | slice (size_type dimension, size_type index) const |
| unsigned int | stride (unsigned int j) const |
| access the stride More... | |
| const size_type & | stride () const |
| void | dataStore (std::ostream &stream, void *context) |
| Implement loadHelper and storeHelper for easier data (de)serialization. More... | |
| void | dataLoad (std::istream &stream, void *context) |
| iterator | begin () |
| iterators for begin and end of this container More... | |
| iterator | end () |
| const_iterator | begin () const |
| const_iterator | end () const |
Protected Member Functions | |
| void | findIndexVector (unsigned int flat_index, size_type &indices) const |
| given a flat index computes the vector of indices i0, i1, i2, ... More... | |
Protected Attributes | |
| size_type | _shape |
| the size along each index More... | |
| unsigned int | _dim |
| the number of dimensions TODO: get rid of this -> _shape.size() More... | |
| unsigned int | _nentries |
| the number of entries TODO: get rid of this -> _data.size() More... | |
| size_type | _stride |
| stride for each index, e.g. if you know {i, j, k} -> flat_index, {i, j + 1, k} = flat_index + stride[1] More... | |
| std::vector< T > | _data |
| the data unrolled into a vector More... | |
Private Member Functions | |
| void | buildAccumulatedShape () |
| build accumulated shape vector for flat index calculation More... | |
| void | reshape (const size_type &shape) |
| change the container shape and reset meta data More... | |
Implements a container class for multi-indexed objects with an arbitrary number of indices.
Definition at line 22 of file MultiIndex.h.
| using MultiIndex< T >::const_iterator = const_noconst_iterator<true> |
Definition at line 33 of file MultiIndex.h.
| using MultiIndex< T >::iterator = const_noconst_iterator<false> |
Definition at line 32 of file MultiIndex.h.
| typedef std::vector<unsigned int> MultiIndex< T >::size_type |
Definition at line 31 of file MultiIndex.h.
| typedef T MultiIndex< T >::value_type |
container related types and categories
Definition at line 27 of file MultiIndex.h.
| MultiIndex< T >::MultiIndex | ( | const size_type & | shape | ) |
construct zero initialized container of a given shape
Definition at line 249 of file MultiIndex.h.
| MultiIndex< T >::MultiIndex | ( | const size_type & | shape, |
| const std::vector< T > & | data | ||
| ) |
construct container of a given shape initialized from a flat data blob
Definition at line 256 of file MultiIndex.h.
| void MultiIndex< T >::assign | ( | const size_type & | shape, |
| T | value | ||
| ) |
Reshape container arbitrarily and initialize with value.
Definition at line 397 of file MultiIndex.h.
|
inline |
Definition at line 50 of file MultiIndex.h.
|
inline |
iterators for begin and end of this container
Definition at line 87 of file MultiIndex.h.
Referenced by MultiIndex< Real >::slice().
|
inline |
Definition at line 89 of file MultiIndex.h.
|
private |
build accumulated shape vector for flat index calculation
Definition at line 439 of file MultiIndex.h.
| void MultiIndex< T >::dataLoad | ( | std::istream & | stream, |
| void * | context | ||
| ) |
Definition at line 413 of file MultiIndex.h.
Referenced by dataLoad().
| void MultiIndex< T >::dataStore | ( | std::ostream & | stream, |
| void * | context | ||
| ) |
Implement loadHelper and storeHelper for easier data (de)serialization.
Definition at line 405 of file MultiIndex.h.
Referenced by dataStore().
|
inline |
dimension of the container
Definition at line 62 of file MultiIndex.h.
Referenced by MultiDimensionalInterpolationTempl< T >::setData().
|
inline |
Definition at line 88 of file MultiIndex.h.
|
inline |
Definition at line 90 of file MultiIndex.h.
|
protected |
given a flat index computes the vector of indices i0, i1, i2, ...
Definition at line 424 of file MultiIndex.h.
| unsigned int MultiIndex< T >::flatIndex | ( | const size_type & | indices | ) | const |
compute the flat index for a size_type index
Definition at line 477 of file MultiIndex.h.
|
inline |
|
inline |
total number of values stored in the container
Definition at line 65 of file MultiIndex.h.
| T & MultiIndex< T >::operator() | ( | const size_type & | indices | ) |
element access operators
Definition at line 267 of file MultiIndex.h.
| const T & MultiIndex< T >::operator() | ( | const size_type & | indices | ) | const |
Definition at line 274 of file MultiIndex.h.
|
inline |
|
inline |
Definition at line 49 of file MultiIndex.h.
|
private |
change the container shape and reset meta data
Definition at line 454 of file MultiIndex.h.
| void MultiIndex< T >::resize | ( | const size_type & | shape | ) |
Resize container. Must keep dimensionality constant.
Definition at line 345 of file MultiIndex.h.
Referenced by MultiIndex< Real >::findIndexVector(), and MultiDimensionalInterpolationTempl< T >::linearSearch().
|
inline |
container size as dim dimensional vector
Definition at line 59 of file MultiIndex.h.
Referenced by MultiDimensionalInterpolationTempl< T >::errorCheck(), and MultiDimensionalInterpolationTempl< T >::setData().
| MultiIndex< T > MultiIndex< T >::slice | ( | unsigned int | dimension, |
| unsigned int | index | ||
| ) | const |
accesses a slice of the multi index object
Definition at line 281 of file MultiIndex.h.
Referenced by MultiDimensionalInterpolationTempl< T >::setData().
| MultiIndex< T > MultiIndex< T >::slice | ( | size_type | dimension, |
| size_type | index | ||
| ) | const |
Definition at line 290 of file MultiIndex.h.
| unsigned int MultiIndex< T >::stride | ( | unsigned int | j | ) | const |
access the stride
Definition at line 389 of file MultiIndex.h.
Referenced by MultiDimensionalInterpolationTempl< T >::multiLinearInterpolation().
|
inline |
Definition at line 78 of file MultiIndex.h.
|
protected |
the data unrolled into a vector
Definition at line 113 of file MultiIndex.h.
Referenced by MultiIndex< Real >::at(), MultiIndex< Real >::getRawData(), and MultiIndex< Real >::operator[]().
|
protected |
the number of dimensions TODO: get rid of this -> _shape.size()
Definition at line 104 of file MultiIndex.h.
|
protected |
the number of entries TODO: get rid of this -> _data.size()
Definition at line 107 of file MultiIndex.h.
Referenced by MultiIndex< Real >::end(), and MultiIndex< Real >::nEntries().
|
protected |
the size along each index
Definition at line 101 of file MultiIndex.h.
Referenced by MultiIndex< Real >::dim(), MultiIndex< T >::const_noconst_iterator< is_const >::operator++(), MultiIndex< T >::const_noconst_iterator< is_const >::operator--(), and MultiIndex< Real >::size().
|
protected |
stride for each index, e.g. if you know {i, j, k} -> flat_index, {i, j + 1, k} = flat_index + stride[1]
Definition at line 110 of file MultiIndex.h.
Referenced by MultiIndex< Real >::stride().
1.8.14