Tomographer  v5.3
Tomographer C++ Framework Documentation
Tomographer::MAT::IndexList< IsRowMajor_ > Class Template Reference

A list of indices with an API for linear or subindices access. More...

#include <tomographer/tools/ezmatio.h>

+ Inheritance diagram for Tomographer::MAT::IndexList< IsRowMajor_ >:
+ Collaboration diagram for Tomographer::MAT::IndexList< IsRowMajor_ >:

Public Types

typedef std::vector< int > VectorType
 Base vector type (superclass)
 

Public Member Functions

 IndexList (const std::vector< int > &dims=std::vector< int >(), int linearindex=-1)
 Constructor with linear index. More...
 
template<typename VectorIntInitializer >
 IndexList (const std::vector< int > &dims, VectorIntInitializer &&index)
 Constructor with multidimensional index specification. More...
 
template<ENABLED_IF( IsRowMajor) >
void setLinearIndex (int linearindex)
 Set the linear index. More...
 
template<ENABLED_IF( !IsRowMajor) >
void setLinearIndex (int linearindex)
 Set the linear index. More...
 
template<ENABLED_IF( IsRowMajor) >
int linearIndex () const
 Linear index corresponding to the stored multidimensional indices. More...
 
template<ENABLED_IF( !IsRowMajor) >
int linearIndex () const
 Linear index corresponding to the stored multidimensional indices. More...
 
const std::vector< int > & index () const
 Return a reference to *this.
 
const std::vector< int > & dims () const
 Get the underlying dimensions given to the constructor. More...
 
IndexListoperator<< (int ind)
 Append index to list. More...
 
IndexListoperator<< (const std::vector< int > &moredims)
 Append a list of indices to list. More...
 
- Public Member Functions inherited from std::vector< int >
int push_back (int ... args)
 
int crbegin (int ... args)
 
int erase (int ... args)
 
int data (int ... args)
 
int insert (int ... args)
 
int pop_back (int ... args)
 
int shrink_to_fit (int ... args)
 
int back (int ... args)
 
int end (int ... args)
 
int resize (int ... args)
 
int emplace_back (int ... args)
 
int size (int ... args)
 
int cbegin (int ... args)
 
int front (int ... args)
 
int ~vector (int ... args)
 
int rbegin (int ... args)
 
int crend (int ... args)
 
int assign (int ... args)
 
int operator= (int ... args)
 
int vector (int ... args)
 
int reserve (int ... args)
 
int capacity (int ... args)
 
int empty (int ... args)
 
int cend (int ... args)
 
int swap (int ... args)
 
int max_size (int ... args)
 
int rend (int ... args)
 
int get_allocator (int ... args)
 
int clear (int ... args)
 
int at (int ... args)
 
int emplace (int ... args)
 
int operator[] (int ... args)
 
int begin (int ... args)
 

Static Public Member Functions

template<bool IsRowMajor2 = false>
static const std::vector< int > & forward_index (const IndexList< IsRowMajor2 > &index)
 
template<bool IsRowMajor2 = false>
static std::vector< int > && forward_index (IndexList< IsRowMajor2 > &&index)
 

Static Public Attributes

static constexpr bool IsRowMajor = IsRowMajor_
 Is this class calculating and expecting row-major (true) or column-major (false) format.
 

Additional Inherited Members

- Public Attributes inherited from std::vector< int >
int elements
 STL member.
 

Detailed Description

template<bool IsRowMajor_ = false>
class Tomographer::MAT::IndexList< IsRowMajor_ >

A list of indices with an API for linear or subindices access.

This subclass of std::vector<int> stores indices into a multi-dimensional array, and adds utilities to access the data with a linear index (i.e. linear memory access model) in either column-major or row-major format.

If RowMajor is true, then the linear indices in this class are given and calculated in row-major format; if false, in column-major format. See Eigen's page on storage orders.

Note
that this class also stores the underlying dimensions of the tensor, which are needed to calculate the linear indices. Also, note that the multidimensional index list is stored, not the linear index. So repeated calls to setLinearIndex() and linearIndex() will do redundant calculations.
Use IndexListIterator if you want to iterate linearly through memory layout with both linear and indices-based access.
There is no way to change the underlying dimensions once the object is constructed.

Definition at line 440 of file ezmatio.h.

Constructor & Destructor Documentation

§ IndexList() [1/2]

template<bool IsRowMajor_ = false>
Tomographer::MAT::IndexList< IsRowMajor_ >::IndexList ( const std::vector< int > &  dims = std::vector<int>(),
int  linearindex = -1 
)
inline

Constructor with linear index.

Note
if no linear index is specified (or a negative value is given), then the vector is uninitialized.

Definition at line 453 of file ezmatio.h.

§ IndexList() [2/2]

template<bool IsRowMajor_ = false>
template<typename VectorIntInitializer >
Tomographer::MAT::IndexList< IsRowMajor_ >::IndexList ( const std::vector< int > &  dims,
VectorIntInitializer &&  index 
)
inline

Constructor with multidimensional index specification.

The second argument is any (single-argument) initializer which can be used as constructor in a std::vector<int>.

Definition at line 473 of file ezmatio.h.

Member Function Documentation

§ dims()

template<bool IsRowMajor_ = false>
const std::vector<int>& Tomographer::MAT::IndexList< IsRowMajor_ >::dims ( ) const
inline

Get the underlying dimensions given to the constructor.

There is no way to change the underlying dims.

Definition at line 556 of file ezmatio.h.

§ linearIndex() [1/2]

template<bool IsRowMajor_ = false>
template<ENABLED_IF( IsRowMajor) >
int Tomographer::MAT::IndexList< IsRowMajor_ >::linearIndex ( ) const
inline

Linear index corresponding to the stored multidimensional indices.

(This is the row-major implementation.)

Definition at line 521 of file ezmatio.h.

§ linearIndex() [2/2]

template<bool IsRowMajor_ = false>
template<ENABLED_IF( !IsRowMajor) >
int Tomographer::MAT::IndexList< IsRowMajor_ >::linearIndex ( ) const
inline

Linear index corresponding to the stored multidimensional indices.

(This is the column-major implementation.)

Definition at line 535 of file ezmatio.h.

§ operator<<() [1/2]

template<bool IsRowMajor_ = false>
IndexList& Tomographer::MAT::IndexList< IsRowMajor_ >::operator<< ( int  ind)
inline

Append index to list.

Utility to construct an index list as

IndexList il; il << 1 << 2 << 5;

Definition at line 568 of file ezmatio.h.

§ operator<<() [2/2]

template<bool IsRowMajor_ = false>
IndexList& Tomographer::MAT::IndexList< IsRowMajor_ >::operator<< ( const std::vector< int > &  moredims)
inline

Append a list of indices to list.

Utility to construct an index list as

IndexList more = ...; // or std::vector<int> more = ...
IndexList il; il << 1 << 2 << more;

Definition at line 581 of file ezmatio.h.

§ setLinearIndex() [1/2]

template<bool IsRowMajor_ = false>
template<ENABLED_IF( IsRowMajor) >
void Tomographer::MAT::IndexList< IsRowMajor_ >::setLinearIndex ( int  linearindex)
inline

Set the linear index.

This will set the underlying index list to the multi-dimensional index corresponding to this linear index.

(This is the row-major implementation)

Definition at line 489 of file ezmatio.h.

§ setLinearIndex() [2/2]

template<bool IsRowMajor_ = false>
template<ENABLED_IF( !IsRowMajor) >
void Tomographer::MAT::IndexList< IsRowMajor_ >::setLinearIndex ( int  linearindex)
inline

Set the linear index.

This will set the underlying index list to the multi-dimensional index corresponding to this linear index.

(This is the column-major implementation)

Definition at line 505 of file ezmatio.h.


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