Helios++
Helios software for LiDAR simulations
fluxionum::TemporalDesignMatrix< TimeType, VarType > Class Template Reference

This class represents a DesignMatrix where each row satisfy that its elements can be placed into a continuous succession order representation (i.e. continuous time domain). For a discrete succession order representation see fluxionum::IndexedDesignMatrix better. More...

#include <TemporalDesignMatrix.h>

Inheritance diagram for fluxionum::TemporalDesignMatrix< TimeType, VarType >:
Collaboration diagram for fluxionum::TemporalDesignMatrix< TimeType, VarType >:

Public Member Functions

 TemporalDesignMatrix (DesignMatrix< VarType > const &designMatrix, size_t const timeColumnIndex, string const timeName="time", vector< string > const &columnNames=vector< string >(0))
 Build a TemporalDesignMatrix from given DesignMatrix and specified time column. More...
 
 TemporalDesignMatrix (DesignMatrix< VarType > const &designMatrix, arma::Col< TimeType > const &timeVector, string const timeName="time")
 Build a TemporalDesignMatrix from given DesignMatrix and time vector. More...
 
 TemporalDesignMatrix (arma::Mat< VarType > const &X, size_t const timeColumnIndex, string const timeName="time", vector< string > const &columnNames=vector< string >(0))
 Build a TemporalDesignMatrix from given \(X\) matrix and specified time column. More...
 
 TemporalDesignMatrix (arma::Mat< VarType > const &X, arma::Col< TimeType > const &t, string const timeName="time", vector< string > const &columnNames=vector< string >(0))
 Build a TemporalDesignMatrix from given DesignMatrix \(X\) and time vector \(\vec{t}\). More...
 
 TemporalDesignMatrix (string const &path, string const &sep=",", string const &timeName="time")
 Build a TemporalDesignMatrix from data in file at given path and specified time column. More...
 
TimeType & operator[] (size_t const i)
 Access to the \(t_{i}\) component of the \(\vec{t}\) time vector. More...
 
DiffDesignMatrix< TimeType, VarType > toDiffDesignMatrix (DiffDesignMatrixType diffType=DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES, bool const sort=true) const
 Build a DiffDesignMatrix from the TemporalDesignMatrix. More...
 
shared_ptr< DiffDesignMatrix< TimeType, VarType > > toDiffDesignMatrixPointer (DiffDesignMatrixType diffType=DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES, bool const sort=true) const
 Like fluxionum::TemporalDesignMatrix::toDiffDesignMatrix but returning a pointer to the object. More...
 
void mergeInPlace (DesignMatrix< VarType > const &dm) override
 Extend DesignMatrix::mergeInPlace method so the time values are also merged. More...
 
void dropRows (arma::uvec const &indices) override
 Extend DesignMatrix::dropRows(arma::uvec const &) method so the time values are also dropped. More...
 
virtual void shiftTime (TimeType const x)
 Add given time \(x\) to all time values in vector \(\vec{t}\). More...
 
virtual void sortByTime ()
 Sort all rows of \(X\) matrix and all components of \(\vec{t}\) vector so \(t_{i+1} > t_{i}\) \(vec{t}\), considering the row \(X(i,:)\) is associated with the time component \(t_i\).
 
virtual size_t slopeFilter (VarType const tau)
 Apply a filter based on the first derivative understood as the slope. More...
 
arma::Col< TimeType > const & getTimeVector () const
 Obtain a constant/read reference to the time vector \(\vec{t}\). More...
 
string const & getTimeName () const
 Obtain the name of the time attribute. More...
 
void setTimeName (string const &timeName)
 Set the name of the time 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)
 
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 arma::Mat< VarType > extractNonTimeMatrix (arma::Mat< VarType > const &X, size_t const timeColumnIndex)
 Do a copy of the DesignMatrix \(X\) with all its columns but removing the time column. More...
 
static vector< string > extractNonTimeNames (vector< string > const &names, size_t const timeColumnIndex)
 Do a copy of the names of the DesignMatrix but discarding the name of the time column. More...
 
static arma::Col< TimeType > extractTimeVector (arma::Mat< VarType > const &X, size_t const timeColumnIndex)
 Do a copy of the time column from given DesignMatrix \(X\). More...
 

Protected Attributes

arma::Col< TimeType > t
 The time values such that \(t_{i}\) is associated with the \(i\)-th row of the design matrix \(X\). It must strictly satisfy \(\forall i, t_{i+1} > t_i\).
 
string timeName
 The name of the time 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 TimeType, typename VarType>
class fluxionum::TemporalDesignMatrix< TimeType, VarType >

This class represents a DesignMatrix where each row satisfy that its elements can be placed into a continuous succession order representation (i.e. continuous time domain). For a discrete succession order representation see fluxionum::IndexedDesignMatrix better.

Author
Alberto M. Esmoris Pena
Version
1.0

Let \(x_i\) be the \(i\)-th row of the temporal design matrix such that

\[ \exists j \in \mathbb{Z} \ni \forall i,\, x_i = \left\{ t_{i} = x_{ij}, x_{i}' = \bigg{(} x_{i,1}, \ldots, x_{i,j-1} , x_{i,j+1}, \ldots, x_{i,n} \bigg{)} \right\} \]

For which its valid status constraint can be defined as:

\[ \forall i, t_{i+1} > t_{i} \]

Notice that implicitly implies the following is not allowed:

\[ \exists i \ni t_{i+1} = t_{i} \]

It is, no repeated time values are allowed because they make the TemporalDesignMatrix lose its valid status constraint, thus any calculus involving it is undefined.

Thus, it is expected that a \(\frac{DX}{DT} \in \mathbb{R}^{(m-1) \times n}\) DiffDesignMatrix exists for the concrete state of any valid TemporalDesignMatrix such that:

\[ \frac{DX}{DT} = \left[\begin{array}{ccc} \frac{x_{21}' - x_{11}'}{t_2 - t_1} & \ldots & \frac{x_{2n}' - x_{1n}'}{t_2 - t_1} \\ \vdots & \ddots & \vdots \\ \frac{x_{m1}' - x_{m-1,1}'}{t_m - t_{m-1}} & \ldots & \frac{x_{mn}' - x_{m-1,n}'}{t_m - t_{m-1}} \end{array}\right] \]

Template Parameters
TimeTypeThe time's domain
VarTypeThe non time's domain (basic DesignMatrix domain)
See also
fluxionum::IndexedDesignMatrix
fluxionum::DiffDesignMatrix
fluxionum::DesignMatrix

Constructor & Destructor Documentation

◆ TemporalDesignMatrix() [1/5]

template<typename TimeType , typename VarType >
fluxionum::TemporalDesignMatrix< TimeType, VarType >::TemporalDesignMatrix ( DesignMatrix< VarType > const &  designMatrix,
size_t const  timeColumnIndex,
string const  timeName = "time",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build a TemporalDesignMatrix from given DesignMatrix and specified time column.

Parameters
designMatrixThe full design matrix, including time values
timeColumnIndexIndex of the column containing time values
timeNameThe default name for the time attribute to be used in case the given DesignMatrix does not specify a column name for its time column

◆ TemporalDesignMatrix() [2/5]

template<typename TimeType , typename VarType >
fluxionum::TemporalDesignMatrix< TimeType, VarType >::TemporalDesignMatrix ( DesignMatrix< VarType > const &  designMatrix,
arma::Col< TimeType > const &  timeVector,
string const  timeName = "time" 
)
inline

Build a TemporalDesignMatrix from given DesignMatrix and time vector.

Parameters
designMatrixThe design matrix (with no time column)
timeVectorThe time vector
timeNameThe name for the time attribute

◆ TemporalDesignMatrix() [3/5]

template<typename TimeType , typename VarType >
fluxionum::TemporalDesignMatrix< TimeType, VarType >::TemporalDesignMatrix ( arma::Mat< VarType > const &  X,
size_t const  timeColumnIndex,
string const  timeName = "time",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build a TemporalDesignMatrix from given \(X\) matrix and specified time column.

Parameters
XThe matrix containing both data points and its associated time
timeColumnIndexIndex of the column containing time values
timeNameThe name for the time attribute

◆ TemporalDesignMatrix() [4/5]

template<typename TimeType , typename VarType >
fluxionum::TemporalDesignMatrix< TimeType, VarType >::TemporalDesignMatrix ( arma::Mat< VarType > const &  X,
arma::Col< TimeType > const &  t,
string const  timeName = "time",
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build a TemporalDesignMatrix from given DesignMatrix \(X\) and time vector \(\vec{t}\).

Parameters
XThe DesignMatrix (with no time column)
tThe time vector
timeNameThe name for the time attribute

◆ TemporalDesignMatrix() [5/5]

template<typename TimeType , typename VarType >
fluxionum::TemporalDesignMatrix< TimeType, VarType >::TemporalDesignMatrix ( string const &  path,
string const &  sep = ",",
string const &  timeName = "time" 
)
inline

Build a TemporalDesignMatrix from data in file at given path and specified time column.

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

Member Function Documentation

◆ dropRows()

template<typename TimeType , typename VarType >
void fluxionum::TemporalDesignMatrix< TimeType, VarType >::dropRows ( arma::uvec const &  indices)
inlineoverridevirtual

Extend DesignMatrix::dropRows(arma::uvec const &) method so the time values are also dropped.

Parameters
indicesIndices of the rows to be dropped

Reimplemented from fluxionum::DesignMatrix< VarType >.

◆ extractNonTimeMatrix()

template<typename TimeType , typename VarType >
static arma::Mat<VarType> fluxionum::TemporalDesignMatrix< TimeType, VarType >::extractNonTimeMatrix ( arma::Mat< VarType > const &  X,
size_t const  timeColumnIndex 
)
inlinestatic

Do a copy of the DesignMatrix \(X\) with all its columns but removing the time column.

Parameters
XThe DesignMatrix \(X\) to be copied
timeColumnIndexThe index of the time column in given DesignMatrix \(X\)X
Returns
Copy of given DesignMatrix \(X\) with no time column
See also
fluxionum::DesignMatrix::X

◆ extractNonTimeNames()

template<typename TimeType , typename VarType >
static vector<string> fluxionum::TemporalDesignMatrix< TimeType, VarType >::extractNonTimeNames ( vector< string > const &  names,
size_t const  timeColumnIndex 
)
inlinestatic

Do a copy of the names of the DesignMatrix but discarding the name of the time column.

Parameters
namesThe names of the DesignMatrix to be copied
timeColumnIndexThe index of the time column
Returns
Copy of the names of given DesignMatrix but discarding the name of the time column
See also
fluxionum::AbstractDesignMatrix::columnNames

◆ extractTimeVector()

template<typename TimeType , typename VarType >
static arma::Col<TimeType> fluxionum::TemporalDesignMatrix< TimeType, VarType >::extractTimeVector ( arma::Mat< VarType > const &  X,
size_t const  timeColumnIndex 
)
inlinestatic

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

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

◆ getTimeName()

template<typename TimeType , typename VarType >
string const& fluxionum::TemporalDesignMatrix< TimeType, VarType >::getTimeName ( ) const
inline

Obtain the name of the time attribute.

Returns
The name of the time attribute
See also
fluxionum::TemporalDesignMatrix::timeName

◆ getTimeVector()

template<typename TimeType , typename VarType >
arma::Col<TimeType> const& fluxionum::TemporalDesignMatrix< TimeType, VarType >::getTimeVector ( ) const
inline

Obtain a constant/read reference to the time vector \(\vec{t}\).

Returns
Constant/read reference to the time vector \(\vec{t}\)
See also
fluxionum::TemporalDesignMatrix::t

◆ mergeInPlace()

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

Extend DesignMatrix::mergeInPlace method so the time values are also merged.

Parameters
dmThe TemporalDesignMatrix to be merged

◆ operator[]()

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

Access to the \(t_{i}\) component of the \(\vec{t}\) time vector.

Parameters
iThe index of the time being accessed (its position in the time vector)
Returns
Reference to the \(t_{i}\) component of the time vector \(\vec{t}\)

◆ setTimeName()

template<typename TimeType , typename VarType >
void fluxionum::TemporalDesignMatrix< TimeType, VarType >::setTimeName ( string const &  timeName)
inline

Set the name of the time attribute.

Parameters
timeNameThe new name for the time attribute
See also
fluxionum::TemporalDesignMatrix::timeName

◆ shiftTime()

template<typename TimeType , typename VarType >
virtual void fluxionum::TemporalDesignMatrix< TimeType, VarType >::shiftTime ( TimeType const  x)
inlinevirtual

Add given time \(x\) to all time values in vector \(\vec{t}\).

\vec{t'} = \vec{t} + x = \left[\begin{array}{c} t_1 + x \ \vdots t_m + x \end{array}\right.

Parameters
xThe time shift for each time component

◆ slopeFilter()

template<typename TimeType , typename VarType >
virtual size_t fluxionum::TemporalDesignMatrix< TimeType, VarType >::slopeFilter ( VarType const  tau)
inlinevirtual

Apply a filter based on the first derivative understood as the slope.

Let \(X \in \mathbb{R}^{m \times n}\) such that \(x_j(t_i) = X(i,j) = x_{ij}\), so it is possible to approximate the derivative as follows:

\[ \frac{\Delta x_j}{\Delta t}(t_i) = \frac{x_j(t_{i+1}) - x_j(t_i)}{t_{i+1} - t_i} \]

But then, the differences between consecutive derivatives can be calculated as shown below:

\[ Dx_j(t_i) = \frac{\Delta x_j}{\Delta t}(t_{i+1}) - \frac{\Delta x_j}{\Delta t}(t_i) \]

Therefore, the vector \(DX(t_i) = \left(Dx_1(t_i), \ldots, Dx_n(t_i)\right)\) arises. And the maximum slope difference at time \(t_i\) can be defined as the maximum absolute component from the vector \(DX(t_i)\) such that \(d_i^* = \max_{1 \leq j \leq n} \vert{Dx_j(t_i)}\vert\).

Finally, let \(\tau\) be the slope difference threshold. Thus, always that \(d_i^* > \tau\) the \(i+1\) row/point will be removed from matrix \(X\) as it is considered that it does not bring useful enough information.

Parameters
tauThe threshold \(\tau\) to decide whether to preserver or to discard a row/point
Returns
The number of discarded rows/points

◆ toDiffDesignMatrix()

template<typename TimeType , typename VarType >
DiffDesignMatrix<TimeType, VarType> fluxionum::TemporalDesignMatrix< TimeType, VarType >::toDiffDesignMatrix ( DiffDesignMatrixType  diffType = DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES,
bool const  sort = true 
) const

Build a DiffDesignMatrix from the TemporalDesignMatrix.

Parameters
diffTypeThe type of differential to be used
sortWhen true, the DiffDesignMatrix construction will lead to an expensive sort operation to assure the finite differences computation makes sense. When false, the expensive sort computation will be skipped as it is expected that the TemporalDesignMatrix is already sorted
Returns
DiffDesignMatrix built from TemporalDesignMatrix
See also
fluxionum::TemporalDesignMatrix::toDiffDesignMatrixPointer
fluxionum::DiffDesignMatrixType
fluxionum::DiffDesignMatrix

◆ toDiffDesignMatrixPointer()

template<typename TimeType , typename VarType >
shared_ptr<DiffDesignMatrix<TimeType, VarType> > fluxionum::TemporalDesignMatrix< TimeType, VarType >::toDiffDesignMatrixPointer ( DiffDesignMatrixType  diffType = DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES,
bool const  sort = true 
) const

Member Data Documentation

◆ timeName

template<typename TimeType , typename VarType >
string fluxionum::TemporalDesignMatrix< TimeType, VarType >::timeName
protected

The name of the time field in the original DesignMatrix.

By default, it is "time"


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