AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::StorageMatrix2D Class Reference

This class provides an Eigen-compatible automatically resized Matrix2D. More...

#include <AIToolbox/Utils/StorageEigen.hpp>

Public Member Functions

 StorageMatrix2D (size_t startRows, size_t cols)
 Basic constructor. More...
 
 StorageMatrix2D (Matrix2D matrix)
 Basic constructor. More...
 
void pop_back (size_t num=1)
 This function removes rows from the view matrix. More...
 
void push_back ()
 This function inserts a new row in storage, and expands the view accordingly. More...
 
template<typename V >
void push_back (const Eigen::MatrixBase< V > &row)
 This function inserts a new row in storage, and expands the view accordingly. More...
 
void resize (size_t rows)
 This function resizes the view to the requested rows. More...
 
void reserve (size_t rows)
 This function reserves row space in the underlying storage. More...
 

Public Attributes

Eigen::Ref< Matrix2Dmatrix
 This member provides a view of the pushed data. More...
 

Detailed Description

This class provides an Eigen-compatible automatically resized Matrix2D.

The number of columns cannot be modified, only the number of rows.

The interface is deliberately simple for now. This class simply maintains a public reference to the internal storage container.

Pushing and popping modifies the view, while the storage gets increased automatically when needed.

Constructor & Destructor Documentation

◆ StorageMatrix2D() [1/2]

AIToolbox::StorageMatrix2D::StorageMatrix2D ( size_t  startRows,
size_t  cols 
)

Basic constructor.

Parameters
startRowsThe initial pre-reserved rows for storage.
colsThe fixed number of columns to store.

◆ StorageMatrix2D() [2/2]

AIToolbox::StorageMatrix2D::StorageMatrix2D ( Matrix2D  matrix)

Basic constructor.

Parameters
matrixThe vector with which to initialize storage (and the public view).

Member Function Documentation

◆ pop_back()

void AIToolbox::StorageMatrix2D::pop_back ( size_t  num = 1)

This function removes rows from the view matrix.

Parameters
numThe number of rows to remove.

◆ push_back() [1/2]

void AIToolbox::StorageMatrix2D::push_back ( )

This function inserts a new row in storage, and expands the view accordingly.

The new row is left un-initialized. This function is provided for performance, if the new row must be constructed dynamically.

◆ push_back() [2/2]

template<typename V >
void AIToolbox::StorageMatrix2D::push_back ( const Eigen::MatrixBase< V > &  row)

This function inserts a new row in storage, and expands the view accordingly.

Parameters
rowThe row to copy.

◆ reserve()

void AIToolbox::StorageMatrix2D::reserve ( size_t  rows)

This function reserves row space in the underlying storage.

This function does not modify the view. We also call Eigen's conservativeResize so that already stored data is maintained.

Parameters
rowsThe requested new rows.

◆ resize()

void AIToolbox::StorageMatrix2D::resize ( size_t  rows)

This function resizes the view to the requested rows.

We first call reserve(size_t) to make sure that the storage is appropriately sized.

Parameters
rowsThe requested new rows.

Member Data Documentation

◆ matrix

Eigen::Ref<Matrix2D> AIToolbox::StorageMatrix2D::matrix

This member provides a view of the pushed data.


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