Helios++
Helios software for LiDAR simulations
fluxionum::IndexedDesignMatrix< IndexType, VarType > Class Template Reference

#include <IndexedDesignMatrix.h>

Inheritance diagram for fluxionum::IndexedDesignMatrix< IndexType, VarType >:
Collaboration diagram for fluxionum::IndexedDesignMatrix< IndexType, VarType >:

Public Member Functions

 IndexedDesignMatrix (DesignMatrix< VarType > const &designMatrix, size_t const indicesColumnIndex, string const indexName="index", vector< string > const &columnNames=vector< string >(0))
 Build an IndexedDesignMatrix from given DesignMatrix and specified indices column. More...
 
 IndexedDesignMatrix (DesignMatrix< VarType > const &designMatrix, vector< IndexType > const &indices, string const indexName="index", vector< string > const &columnNames=vector< string >(0))
 Build an IndexedDesignMatrix from given DesignMatrix and indices vector. More...
 
 IndexedDesignMatrix (arma::Mat< VarType > const &X, size_t const indicesColumnIndex, string const indexName="index", vector< string > const &columnNames=vector< string >(0))
 Build an IndexedDesignMatrix from given \(X\) matrix and specified indices column. More...
 
 IndexedDesignMatrix (arma::Mat< VarType > const &X, vector< IndexType > const &indices, string const indexName="index", vector< string > const &columnNames=vector< string >(0))
 Build an IndexedDesignMatrix from given DesignMatrix \(X\) and indices. More...
 
 IndexedDesignMatrix (string const &path, string const indexName="index")
 Build an IndexedDesignMatrix from data in file at given path and specified index column. More...
 
IndexType & operator[] (size_t const i)
 Access to the \(i\)-th index. More...
 
DiffDesignMatrix< double, VarType > toLinearTimeDiffDesignMatrix (double const ta=0.0, double const tb=1.0, DiffDesignMatrixType diffType=DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES) const
 Build a DiffDesignMatrix from the IndexedDesignMatrix assuming that the index 0 lies at \(t_a\) while the maximum index lies at \(t_b\). All \(m\) indices are expected to be linearly spaced with a step \(\Delta t = \frac{t_b - t_a}{m}\). More...
 
shared_ptr< DiffDesignMatrix< double, VarType > > toLinearTimeDiffDesignMatrixPointer (double const ta=0.0, double const tb=1.0, DiffDesignMatrixType diffType=DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES) const
 
void mergeInPlace (DesignMatrix< VarType > const &dm) override
 Extend DesignMatrix::mergeInPlace method so the indices are also merged. More...
 
vector< IndexType > const & getIndices () const
 Obtain a constant/read reference to the vector of indices. More...
 
string const getIndexName () const
 Obtain the name of the index attribute. More...
 
void setIndexName (string const &indexName)
 Set the name of the index attribute. More...
 
- Public Member Functions inherited from fluxionum::DesignMatrix< VarType >
 DesignMatrix (vector< string > const &columnNames=vector< string >(0))
 Build a DesignMatrix with no data. More...
 
 DesignMatrix (arma::Mat< VarType > const &X, vector< string > const &columnNames=vector< string >(0))
 Build a DesignMatrix from given armadillo matrix. More...
 
 DesignMatrix (string const &path, string const &sep=",")
 Build a DesignMatrix from data in file at given path. More...
 
VarType & operator() (size_t const i, size_t const j) override
 Access to the \(x_{ij}\) component of the \(X\) design matrix. More...
 
virtual void mergeInPlace (DesignMatrix const &dm)
 Merge given DesignMatrix into this DesignMatrix. More...
 
void swapColumns (vector< long unsigned int > const &indices)
 
void swapColumns (vector< unsigned long long > const &indices)
 
void swapColumns (arma::uvec const &indices)
 Swap the columns of the DesignMatrix. More...
 
void dropColumns (vector< long unsigned int > const &indices)
 
void dropColumns (vector< unsigned long long > const &indices)
 
void dropColumns (arma::uvec const &indices)
 Remove the columns from the DesignMatrix. More...
 
void dropRows (vector< long unsigned int > const &indices)
 
void dropRows (vector< unsigned long long > const &indices)
 
virtual void dropRows (arma::uvec const &indices)
 Remove the rows from the DesignMatrix. More...
 
void addToColumn (size_t const colIdx, VarType const x)
 Add \(x\) to all elements of \(j\)-th column. More...
 
arma::Mat< VarType > const & getX () const
 Obtain a constant/read reference to the \(X\) matrix. More...
 
arma::Mat< VarType > & getWritableX ()
 Obtain a writable reference to the \(X\) matrix. More...
 
size_t getNumRows () const override
 Obtain the number of rows of the DesignMatrix \(X\). More...
 
size_t getNumColumns () const override
 Obtain the number of columns of the DesignMatrix \(X\). More...
 
size_t getNumElements () const override
 Obtain the number of elements of the DesignMatrix \(X\). More...
 
arma::subview_row< VarType > const getRow (size_t const i) const
 Obtain the \(i\)-th row of the DesignMatrix \(X\). More...
 
arma::Row< VarType > getRowCopy (size_t const i) const
 Like DesignMatrix::getRow(size_t const) but returning a copy by value instead of a view-like reference. More...
 
arma::subview_col< VarType > const getColumn (size_t const j) const
 Obtain the \(j\)-th column of the DesignMatrix \(X\). More...
 
arma::subview_col< VarType > const getColumn (string const &columnName) const
 Like the fluxionum::DesignMatrix::getColumn(size_t const) method but specifying the column by name. More...
 
arma::Col< VarType > getColumnCopy (size_t const j) const
 Like DesignMatrix::getColumn(size_t const) but returning a copy by value instead of a view-like reference. More...
 
arma::Col< VarType > getColumnCopy (string const &columnName) const
 Like DesignMatrix::getColumn(string const &) but returning a copy by value instead of a view-like reference. More...
 
void setColumn (size_t const j, arma::Col< VarType > const &col)
 Set the \(j\)-th column of the DesignMatrix \(X\). More...
 
- Public Member Functions inherited from fluxionum::AbstractDesignMatrix< VarType >
 AbstractDesignMatrix (vector< string > const &columnNames=vector< string >(0))
 Default constructor for the AbstractDesignMatrix. More...
 
VarType & operator() (size_t const i, string const columnName)
 Like the AbstractDesignMatrix::operator()(size_t const, size_t const) method but specifying the column by its name instead of its index. More...
 
bool hasColumnNames () const
 Check whether there are available column names for the AbstractDesignMatrix (true) or not (false) More...
 
string const & getColumnName (size_t const j) const
 Obtain the name of the \(j\)-th column. More...
 
void setColumnName (size_t const j, string const &columnName)
 Set the name of the \(j\)-th column. More...
 
vector< string > const & getColumnNames () const
 Obtain a constant/read reference to the column names. More...
 
void setColumnNames (vector< string > const &columnNames)
 Obtain a constant/read reference to the column names. More...
 

Static Public Member Functions

static vector< IndexType > extractIndices (arma::Mat< VarType > const &X, size_t const indicesColumnIndex)
 Do a copy of the indices column from given DesignMatrix \(X\). More...
 

Protected Attributes

vector< IndexType > indices
 The indices vector \(\vec{\iota} = \left(\iota_1, \ldots, \iota_m\right) \in \mathbb{Z}^{m}\). More...
 
string indexName
 The name of the index field in the original DesignMatrix. More...
 
- Protected Attributes inherited from fluxionum::DesignMatrix< VarType >
arma::Mat< VarType > X
 The design matrix \(X \in \mathbb{R}^{m \times n}\).
 
- Protected Attributes inherited from fluxionum::AbstractDesignMatrix< VarType >
vector< string > columnNames
 The column names for the DesignMatrix. It can be either an empty vector when no column names are specified or a vector with as many names as columns (in the same order)
 

Additional Inherited Members

- Protected Member Functions inherited from fluxionum::AbstractDesignMatrix< VarType >
size_t translateColumnNameToIndex (string const &columnName) const
 Find the corresponding column name for given index. More...
 

Detailed Description

template<typename IndexType, typename VarType>
class fluxionum::IndexedDesignMatrix< IndexType, VarType >

Author
Alberto M. Esmoris Pena
Version
1.0

An indexed design matrix is simply a matrix which values are ordered by its indices so it is known that the \(i\)-th row precedes the \(i+1\) row. It can be seen as the discrete version of a temporal design matrix.

Obtaining a DiffDesignMatrix from an IndexedDesignMatrix is not possible without an assumption about the time domain. For instance, it can be assumed that indices are linearly spaced inside a normalized time interval \(t \in [0, 1]\). However, this assumption must accurately pair with the reality of data. Otherwise, the generated DiffDesignMatrix will be wrong. It is also possible that there is no useful time domain interpretation for the indices, thus there might be some IndexedDesignMatrix for which it is not possible to have a corresponding DiffDesignMatrix.

Template Parameters
IndexTypeThe type of index or index domain
VarTypeThe non index domain (basic DesignMatrix domain)
See also
fluxionum::TemporalDesignMatrix
fluxionum::DiffDesignMatrix
fluxionum::DesignMatrix

Constructor & Destructor Documentation

◆ IndexedDesignMatrix() [1/5]

template<typename IndexType , typename VarType >
fluxionum::IndexedDesignMatrix< IndexType, VarType >::IndexedDesignMatrix ( DesignMatrix< VarType > const &  designMatrix,
size_t const  indicesColumnIndex,
string const  indexName = "index",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build an IndexedDesignMatrix from given DesignMatrix and specified indices column.

Parameters
designMatrixThe full design matrix, including indices
indicesColumnIndexIndex of the column containing indices
indexNameThe default name for the index attribute to be used in case the given DesignMatrix does not specify a column name for its indices column

◆ IndexedDesignMatrix() [2/5]

template<typename IndexType , typename VarType >
fluxionum::IndexedDesignMatrix< IndexType, VarType >::IndexedDesignMatrix ( DesignMatrix< VarType > const &  designMatrix,
vector< IndexType > const &  indices,
string const  indexName = "index",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build an IndexedDesignMatrix from given DesignMatrix and indices vector.

Parameters
designMatrixThe design matrix (with no indices column)
indicesThe vector of indices
indexNameThe name for the index attribute

◆ IndexedDesignMatrix() [3/5]

template<typename IndexType , typename VarType >
fluxionum::IndexedDesignMatrix< IndexType, VarType >::IndexedDesignMatrix ( arma::Mat< VarType > const &  X,
size_t const  indicesColumnIndex,
string const  indexName = "index",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build an IndexedDesignMatrix from given \(X\) matrix and specified indices column.

Parameters
XThe matrix containing both data points and its associated index
indicesColumnIndexIndex of the column containing indices
indexNameThe name for the index attribute

◆ IndexedDesignMatrix() [4/5]

template<typename IndexType , typename VarType >
fluxionum::IndexedDesignMatrix< IndexType, VarType >::IndexedDesignMatrix ( arma::Mat< VarType > const &  X,
vector< IndexType > const &  indices,
string const  indexName = "index",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build an IndexedDesignMatrix from given DesignMatrix \(X\) and indices.

Parameters
XThe DesignMatrix (with no indices column)
indicesThe indices
indexNameThe name for the index attribute

◆ IndexedDesignMatrix() [5/5]

template<typename IndexType , typename VarType >
fluxionum::IndexedDesignMatrix< IndexType, VarType >::IndexedDesignMatrix ( string const &  path,
string const  indexName = "index" 
)
inline

Build an IndexedDesignMatrix from data in file at given path and specified index column.

Parameters
pathPath to the file containing both the data and the indices
indexNameThe default name for the index attribute to be used in case the read DesignMatrix does not specify a column name for its indices column

Member Function Documentation

◆ extractIndices()

template<typename IndexType , typename VarType >
static vector<IndexType> fluxionum::IndexedDesignMatrix< IndexType, VarType >::extractIndices ( arma::Mat< VarType > const &  X,
size_t const  indicesColumnIndex 
)
inlinestatic

Do a copy of the indices column from given DesignMatrix \(X\).

Parameters
XThe DesignMatrix \(X\) containing a column of indices
indicesColumnIndexThe index of the indices column in given DesignMatrix \(X\)
Returns
The copy of the indices column from DesignMatrix \(X\)
See also
fluxionum::DesignMatrix::X

◆ getIndexName()

template<typename IndexType , typename VarType >
string const fluxionum::IndexedDesignMatrix< IndexType, VarType >::getIndexName ( ) const
inline

Obtain the name of the index attribute.

Returns
The name of the index attribute
See also
fluxionum::IndexedDesignMatrix::indexName

◆ getIndices()

template<typename IndexType , typename VarType >
vector<IndexType> const& fluxionum::IndexedDesignMatrix< IndexType, VarType >::getIndices ( ) const
inline

Obtain a constant/read reference to the vector of indices.

Returns
Constant/read reference to the vector of indices
See also
fluxionum::IndexedDesignMatrix::indices

◆ mergeInPlace()

template<typename IndexType , typename VarType >
void fluxionum::IndexedDesignMatrix< IndexType, VarType >::mergeInPlace ( DesignMatrix< VarType > const &  dm)
inlineoverride

Extend DesignMatrix::mergeInPlace method so the indices are also merged.

Parameters
dmThe IndexedDesignMatrix to be merged

◆ operator[]()

template<typename IndexType , typename VarType >
IndexType& fluxionum::IndexedDesignMatrix< IndexType, VarType >::operator[] ( size_t const  i)
inline

Access to the \(i\)-th index.

Parameters
iThe index (in the indices vector) of the index being accessed
Returns
Reference to the \(i\)-th index

◆ setIndexName()

template<typename IndexType , typename VarType >
void fluxionum::IndexedDesignMatrix< IndexType, VarType >::setIndexName ( string const &  indexName)
inline

Set the name of the index attribute.

Parameters
indexNameThe new name for the index attribute
See also
fluxionum::IndexedDesignMatrix::indexName

◆ toLinearTimeDiffDesignMatrix()

template<typename IndexType , typename VarType >
DiffDesignMatrix<double, VarType> fluxionum::IndexedDesignMatrix< IndexType, VarType >::toLinearTimeDiffDesignMatrix ( double const  ta = 0.0,
double const  tb = 1.0,
DiffDesignMatrixType  diffType = DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES 
) const

Build a DiffDesignMatrix from the IndexedDesignMatrix assuming that the index 0 lies at \(t_a\) while the maximum index lies at \(t_b\). All \(m\) indices are expected to be linearly spaced with a step \(\Delta t = \frac{t_b - t_a}{m}\).

Parameters
taThe start time
tbThe end time
diffTypeThe type of differential to be used
Returns
DiffDesignMatrix built from IndexedDesignMatrix
See also
IndexedDesignMatrix::toLinearTimeDiffDesignMatrixPointer
fluxionum::DiffDesignMatrix

◆ toLinearTimeDiffDesignMatrixPointer()

template<typename IndexType , typename VarType >
shared_ptr<DiffDesignMatrix<double, VarType> > fluxionum::IndexedDesignMatrix< IndexType, VarType >::toLinearTimeDiffDesignMatrixPointer ( double const  ta = 0.0,
double const  tb = 1.0,
DiffDesignMatrixType  diffType = DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES 
) const
See also
Like toLinearTimeDiffDesignMatrix(double const, double const) but returning a pointer to the object
Returns
Pointer to the DiffDesignMatrix built from IndexedDesignMatrix
See also
IndexedDesignMatrix::toLinearTimeDiffDesignMatrix
fluxionum::DiffDesignMatrix

Member Data Documentation

◆ indexName

template<typename IndexType , typename VarType >
string fluxionum::IndexedDesignMatrix< IndexType, VarType >::indexName
protected

The name of the index field in the original DesignMatrix.

By default, it is "index"

◆ indices

template<typename IndexType , typename VarType >
vector<IndexType> fluxionum::IndexedDesignMatrix< IndexType, VarType >::indices
protected

The indices vector \(\vec{\iota} = \left(\iota_1, \ldots, \iota_m\right) \in \mathbb{Z}^{m}\).

Note indices are explicitly defined. Thus, instead of having the \(i\)-th row from DesignMatrix \(X\) as implicitly corresponding to the index \(i\), the \(i\)-th row corresponds to the \(\iota_i\) index. It is done this way since obtaining a DiffDesignMatrix requires some assumption on the relationship between indices and time domain. For instance, in the case of linearly spaced indices in a time domain \(t \in [0, 1]\), explicitly specifying the indices makes it possible to have the time difference between \(i\) and \(i+1\) rows of \(X \in \mathbb{R}^{m \times n}\) to be \((\iota_{i+1} - \iota_{i}) {\Delta t}\) where \({\Delta t}\) is the time step between consecutive indices.


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