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... | |
MatrixType & | operator[] (TimeIndex index) |
gets the value with the given time index, non const version More... | |
const MatrixType & | front () const |
gets the first value More... | |
MatrixType & | front () |
gets the first value More... | |
const MatrixType & | back () const |
gets the last value More... | |
MatrixType & | back () |
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_ |
This class describes a structure that enables to store array of matrices with time indexation.
typedef std::vector<MatrixType, Allocator> stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::Array |
|
protected |
stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::IndexedMatrixArrayT | ( | ) |
Default constructor.
stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::IndexedMatrixArrayT | ( | TimeSize | size, |
TimeIndex | initTime = 0 |
||
) |
Construct a new Indexed Vector Array T with a predifined size.
size | is the size of the array |
initTime | is the index of the initial time. It is zero by default |
|
inline |
gets the last value
|
inline |
gets the last value
|
inlineprotected |
Asserts that the array is not empty does nothing in release mode
|
inlineprotected |
Asserts that the index is present in the array does nothing in release mode
|
inline |
checks whether the index is present in the array
|
inlineprotected |
Asserts that the given time can be pushed at the back of the vector does nothing in release mode
|
inline |
Clears the vector but keeps the last index.
|
inline |
gets the first value
|
inline |
gets the first value
Array stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::getArray | ( | ) | const |
converts the array into a standard vector
|
inline |
Get the time index.
|
inline |
Get the time index.
|
inline |
Get the time index of the next value that will be pushed back Can be used in for loops
|
inline |
gets the value with the given time index, non const version
|
inline |
gets the value with the given time index
|
inline |
removes the first (oldest) element of the array
|
inline |
Pushes back the matrix to the array, the new value will take the next time.
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
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::readFromFile | ( | const std::string & | filename, |
Index | rows, | ||
Index | cols = 1 , |
||
bool | withTimeStamp = true |
||
) |
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::readVectorsFromFile | ( | const char * | filename, |
bool | withTimeStamp = true |
||
) |
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
|
inline |
Resets the array to initial state the value is no longer accessible
|
inline |
resizes the array
|
inline |
set the time index of the first element
|
inline |
Set the time index of the last element.
|
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
|
inline |
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::truncateAfter | ( | TimeIndex | timeIndex | ) |
removes all the elements with larger indexes than timeIndex
void stateObservation::IndexedMatrixArrayT< MatrixType, Allocator >::truncateBefore | ( | TimeIndex | timeIndex | ) |
removes all the elements with smaller indexes than timeIndex
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
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
|
protected |
|
protected |