stateObservation::IndexedMatrixArrayT< MatrixType, Allocator > Class Template Reference

This class describes a structure that enables to store array of matrices with time indexation. More...

#include <state-observation/tools/definitions.hpp>

Public Types

typedef std::vector< MatrixType, Allocator > Array
 

Public Member Functions

 IndexedMatrixArrayT ()
 Default constructor. More...
 
 IndexedMatrixArrayT (TimeSize size, TimeIndex initTime=0)
 Construct a new Indexed Vector Array T with a predifined size. More...
 
void setValue (const MatrixType &v, TimeIndex k)
 
void pushBack (const MatrixType &v)
 Pushes back the matrix to the array, the new value will take the next time. More...
 
void popFront ()
 removes the first (oldest) element of the array More...
 
MatrixType operator[] (TimeIndex index) const
 gets the value with the given time index More...
 
MatrixTypeoperator[] (TimeIndex index)
 gets the value with the given time index, non const version More...
 
const MatrixTypefront () const
 gets the first value More...
 
MatrixTypefront ()
 gets the first value More...
 
const MatrixTypeback () const
 gets the last value More...
 
MatrixTypeback ()
 gets the last value More...
 
void truncateAfter (TimeIndex timeIndex)
 removes all the elements with larger indexes than timeIndex More...
 
void truncateBefore (TimeIndex timeIndex)
 removes all the elements with smaller indexes than timeIndex More...
 
void resize (TimeSize i, const MatrixType &m=MatrixType())
 resizes the array More...
 
TimeIndex getLastIndex () const
 Get the time index. More...
 
TimeIndex getNextIndex () const
 
TimeIndex setLastIndex (int index)
 Set the time index of the last element. More...
 
TimeIndex getFirstIndex () const
 Get the time index. More...
 
TimeIndex setFirstIndex (int index)
 set the time index of the first element More...
 
TimeSize size () const
 
void reset ()
 
void clear ()
 Clears the vector but keeps the last index. More...
 
Array getArray () const
 converts the array into a standard vector More...
 
bool checkIndex (TimeIndex k) const
 checks whether the index is present in the array More...
 
void readFromFile (const char *filename, Index rows, Index cols=1, bool withTimeStamp=true)
 
void readFromFile (const std::string &filename, Index rows, Index cols=1, bool withTimeStamp=true)
 
void readVectorsFromFile (const std::string &filename, bool withTimeStamp=true)
 
void readVectorsFromFile (const char *filename, bool withTimeStamp=true)
 
void writeInFile (const char *filename, bool clear=false, bool append=false)
 
void writeInFile (const std::string &filename, bool clear=false, bool append=false)
 

Protected Types

typedef std::deque< MatrixType, Allocator > Deque
 

Protected Member Functions

void check_ (TimeIndex time) const
 
void check_ () const
 
void checkNext_ (TimeIndex time) const
 

Protected Attributes

TimeIndex k_
 
Deque v_
 

Detailed Description

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
class stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >

This class describes a structure that enables to store array of matrices with time indexation.

Member Typedef Documentation

◆ Array

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
typedef std::vector<MatrixType, Allocator> stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::Array

◆ Deque

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
typedef std::deque<MatrixType, Allocator> stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::Deque
protected

Constructor & Destructor Documentation

◆ IndexedMatrixArrayT() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::IndexedMatrixArrayT ( )

Default constructor.

◆ IndexedMatrixArrayT() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::IndexedMatrixArrayT ( TimeSize  size,
TimeIndex  initTime = 0 
)

Construct a new Indexed Vector Array T with a predifined size.

Parameters
sizeis the size of the array
initTimeis the index of the initial time. It is zero by default

Member Function Documentation

◆ back() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
MatrixType& stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::back ( )
inline

gets the last value

◆ back() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
const MatrixType& stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::back ( ) const
inline

gets the last value

◆ check_() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::check_ ( ) const
inlineprotected

Asserts that the array is not empty does nothing in release mode

◆ check_() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::check_ ( TimeIndex  time) const
inlineprotected

Asserts that the index is present in the array does nothing in release mode

◆ checkIndex()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
bool stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::checkIndex ( TimeIndex  k) const
inline

checks whether the index is present in the array

◆ checkNext_()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::checkNext_ ( TimeIndex  time) const
inlineprotected

Asserts that the given time can be pushed at the back of the vector does nothing in release mode

◆ clear()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::clear ( )
inline

Clears the vector but keeps the last index.

◆ front() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
MatrixType& stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::front ( )
inline

gets the first value

◆ front() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
const MatrixType& stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::front ( ) const
inline

gets the first value

◆ getArray()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
Array stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::getArray ( ) const

converts the array into a standard vector

◆ getFirstIndex()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeIndex stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::getFirstIndex ( ) const
inline

Get the time index.

◆ getLastIndex()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeIndex stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::getLastIndex ( ) const
inline

Get the time index.

◆ getNextIndex()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeIndex stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::getNextIndex ( ) const
inline

Get the time index of the next value that will be pushed back Can be used in for loops

◆ operator[]() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
MatrixType& stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::operator[] ( TimeIndex  index)
inline

gets the value with the given time index, non const version

◆ operator[]() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
MatrixType stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::operator[] ( TimeIndex  index) const
inline

gets the value with the given time index

◆ popFront()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::popFront ( )
inline

removes the first (oldest) element of the array

◆ pushBack()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::pushBack ( const MatrixType v)
inline

Pushes back the matrix to the array, the new value will take the next time.

◆ readFromFile() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::readFromFile ( const char *  filename,
Index  rows,
Index  cols = 1,
bool  withTimeStamp = true 
)

gets the array from a file the line starts with the time index and then the matrix is read row by row WARNING: this resets the array

◆ readFromFile() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::readFromFile ( const std::string &  filename,
Index  rows,
Index  cols = 1,
bool  withTimeStamp = true 
)

◆ readVectorsFromFile() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::readVectorsFromFile ( const char *  filename,
bool  withTimeStamp = true 
)

◆ readVectorsFromFile() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::readVectorsFromFile ( const std::string &  filename,
bool  withTimeStamp = true 
)

gets the array from a file the line starts with the time index and then every line of the file is converted into a vector WARNING: this resets the array

◆ reset()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::reset ( )
inline

Resets the array to initial state the value is no longer accessible

◆ resize()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::resize ( TimeSize  i,
const MatrixType m = MatrixType() 
)
inline

resizes the array

◆ setFirstIndex()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeIndex stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::setFirstIndex ( int  index)
inline

set the time index of the first element

◆ setLastIndex()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeIndex stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::setLastIndex ( int  index)
inline

Set the time index of the last element.

◆ setValue()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::setValue ( const MatrixType v,
TimeIndex  k 
)
inline

Sets the vector v at the time index k It checks the time index, the array must have contiguous indexes It can be used to push a value into the back of the array

◆ size()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeSize stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::size ( ) const
inline

◆ truncateAfter()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::truncateAfter ( TimeIndex  timeIndex)

removes all the elements with larger indexes than timeIndex

◆ truncateBefore()

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::truncateBefore ( TimeIndex  timeIndex)

removes all the elements with smaller indexes than timeIndex

◆ writeInFile() [1/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::writeInFile ( const char *  filename,
bool  clear = false,
bool  append = false 
)

write the array in a a file the line starts with the time index and then the matrix is described row by row When clear is set, the array is cleared but the time index is conserved When append is set to true, the output is appended to file

◆ writeInFile() [2/2]

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::writeInFile ( const std::string &  filename,
bool  clear = false,
bool  append = false 
)

write the array in a a file the line starts with the time index and then the matrix is described row by row When clear is set, the array is cleared but the time index is conserved When append is set to true, the output is appended to file

Member Data Documentation

◆ k_

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
TimeIndex stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::k_
protected

◆ v_

template<typename MatrixType = Matrix, typename Allocator = std::allocator<MatrixType>>
Deque stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::v_
protected

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