Helios++
Helios software for LiDAR simulations
fluxionum::DesignMatrix< T > Class Template Reference

This class represents a DesignMatrix \(X \in \mathbb{R}^{m \times n}\). More...

#include <DesignMatrix.h>

Inheritance diagram for fluxionum::DesignMatrix< T >:
Collaboration diagram for fluxionum::DesignMatrix< T >:

Public Member Functions

 DesignMatrix (vector< string > const &columnNames=vector< string >(0))
 Build a DesignMatrix with no data. More...
 
 DesignMatrix (arma::Mat< T > 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...
 
T & 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, T const x)
 Add \(x\) to all elements of \(j\)-th column. More...
 
arma::Mat< T > const & getX () const
 Obtain a constant/read reference to the \(X\) matrix. More...
 
arma::Mat< T > & 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< T > const getRow (size_t const i) const
 Obtain the \(i\)-th row of the DesignMatrix \(X\). More...
 
arma::Row< T > 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< T > const getColumn (size_t const j) const
 Obtain the \(j\)-th column of the DesignMatrix \(X\). More...
 
arma::Col< T > 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::subview_col< T > const getColumn (string const &columnName) const
 Like the fluxionum::DesignMatrix::getColumn(size_t const) method but specifying the column by name. More...
 
arma::Col< T > 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< T > const &col)
 Set the \(j\)-th column of the DesignMatrix \(X\). More...
 
- Public Member Functions inherited from fluxionum::AbstractDesignMatrix< T >
 AbstractDesignMatrix (vector< string > const &columnNames=vector< string >(0))
 Default constructor for the AbstractDesignMatrix. More...
 
T & 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...
 

Protected Attributes

arma::Mat< T > X
 The design matrix \(X \in \mathbb{R}^{m \times n}\).
 
- Protected Attributes inherited from fluxionum::AbstractDesignMatrix< T >
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< T >
size_t translateColumnNameToIndex (string const &columnName) const
 Find the corresponding column name for given index. More...
 

Detailed Description

template<typename T>
class fluxionum::DesignMatrix< T >

This class represents a DesignMatrix \(X \in \mathbb{R}^{m \times n}\).

Author
Alberto M. Esmoris Pena
Version
1.0

It is assumed that each row represents a different point while each column defines a different attribute for the point. Thus, the DesignMatrix can be interpreted as a set of \(m\) different points defined in a \(n\) dimensional space. The DesignMatrix might even be decoded into a structure subset (structure space) that defines the structural relationship between points (i.e. their spatial relationships) and a feature subset (feature space) that defines the characteristics of each point (for instance, as descriptors of their local neighborhood).

Template Parameters
TType \(\mathcal{T}\) of element for the design matrix \(X\) such that \(x_{ij} \in \mathcal{T}\).
See also
fluxionum::AbstractDesignMatrix
fluxionum::TemporalDesignMatrix
fluxionum::IndexedDesignMatrix

Constructor & Destructor Documentation

◆ DesignMatrix() [1/3]

template<typename T >
fluxionum::DesignMatrix< T >::DesignMatrix ( vector< string > const &  columnNames = vector<string>(0))
inline

Build a DesignMatrix with no data.

Parameters
columnNamesEither the name for each column or an empty vector if there are no names

◆ DesignMatrix() [2/3]

template<typename T >
fluxionum::DesignMatrix< T >::DesignMatrix ( arma::Mat< T > const &  X,
vector< string > const &  columnNames = vector<string>(0) 
)
inline

Build a DesignMatrix from given armadillo matrix.

Parameters
XArmadillo matrix to build DesignMatrix from
columnNamesEither the name for each column or an empty vector if there are no names

◆ DesignMatrix() [3/3]

template<typename T >
fluxionum::DesignMatrix< T >::DesignMatrix ( string const &  path,
string const &  sep = "," 
)
inline

Build a DesignMatrix from data in file at given path.

Parameters
pathPath to the file containing the data for the DesignMatrix
columnNamesThe default column names to be used if no column names are read from file at given path

Member Function Documentation

◆ addToColumn()

template<typename T >
void fluxionum::DesignMatrix< T >::addToColumn ( size_t const  colIdx,
T const  x 
)
inline

Add \(x\) to all elements of \(j\)-th column.

Parameters
colIdxThe index ( \(j\)) of the column to be modified
xThe value to be added to each element of given column

◆ dropColumns() [1/3]

template<typename T >
void fluxionum::DesignMatrix< T >::dropColumns ( arma::uvec const &  indices)
inline

Remove the columns from the DesignMatrix.

Let \(\vec{u} = (u_1, \ldots, u_k)\) be the vector of indices for the \(k \leq n\) columns to be removed from the matrix \(X \in \mathbb{R}^{m \times n}\). Thus, the new matrix \(X' \in \mathbb{R}^{m \times (n-k)}\) can be obtained from the \(X\) matrix simply by removing all the columns which index is the \(u_i\) component of vector \(\vec{u}\)

Parameters
indicesThe vector of indices \(vec{u} = (u_1, \ldots, u_n)\)

◆ dropColumns() [2/3]

template<typename T >
void fluxionum::DesignMatrix< T >::dropColumns ( vector< long unsigned int > const &  indices)
inline

◆ dropColumns() [3/3]

template<typename T >
void fluxionum::DesignMatrix< T >::dropColumns ( vector< unsigned long long > const &  indices)
inline

◆ dropRows() [1/3]

template<typename T >
virtual void fluxionum::DesignMatrix< T >::dropRows ( arma::uvec const &  indices)
inlinevirtual

Remove the rows from the DesignMatrix.

Let \(\vec{u} = (u_1, \ldots, u_k)\) be the vector of indices for the \(k \leq m\) rows to be removed from the matrix \(X \in \mathbb{R}^{m \times n}\). Thus, the new matrix \(X' \in \mathbb{R}^{(m-k) \times n}\) can be obtained from the \(X\) matrix simply by removing all the rows which index if the \(u_i\) component of vector \(\vec{u}\)

Parameters
indicesThe vector of indices \({u} = (u_1, \ldots, u_n)\)

Reimplemented in fluxionum::TemporalDesignMatrix< TimeType, VarType >.

◆ dropRows() [2/3]

template<typename T >
void fluxionum::DesignMatrix< T >::dropRows ( vector< long unsigned int > const &  indices)
inline

◆ dropRows() [3/3]

template<typename T >
void fluxionum::DesignMatrix< T >::dropRows ( vector< unsigned long long > const &  indices)
inline

◆ getColumn() [1/2]

template<typename T >
arma::subview_col<T> const fluxionum::DesignMatrix< T >::getColumn ( size_t const  j) const
inline

Obtain the \(j\)-th column of the DesignMatrix \(X\).

Parameters
jIndex of the column to be obtained
Returns
The \(j\)-th column of the DesignMatrix \(X\)X
See also
fluxionum::DesignMatrix::X

◆ getColumn() [2/2]

template<typename T >
arma::subview_col<T> const fluxionum::DesignMatrix< T >::getColumn ( string const &  columnName) const
inline

Like the fluxionum::DesignMatrix::getColumn(size_t const) method but specifying the column by name.

Parameters
columnNameThe name of the column to be obtained
See also
fluxionum::DesignMatrix::getColumn(size_t const)

◆ getColumnCopy() [1/2]

template<typename T >
arma::Col<T> fluxionum::DesignMatrix< T >::getColumnCopy ( size_t const  j) const
inline

Like DesignMatrix::getColumn(size_t const) but returning a copy by value instead of a view-like reference.

See also
fluxionum::DesignMatrix::getColumn(size_t const)

◆ getColumnCopy() [2/2]

template<typename T >
arma::Col<T> fluxionum::DesignMatrix< T >::getColumnCopy ( string const &  columnName) const
inline

Like DesignMatrix::getColumn(string const &) but returning a copy by value instead of a view-like reference.

See also
fluxionum::DesignMatrix::getColumn(string const &)

◆ getNumColumns()

template<typename T >
size_t fluxionum::DesignMatrix< T >::getNumColumns ( ) const
inlineoverridevirtual

Obtain the number of columns of the DesignMatrix \(X\).

Returns
The number of columns of the DesignMatrix \(X\)
See also
fluxionum::DesignMatrix::X
fluxionum::AbstractDesignMatrix::getNumColumns

Implements fluxionum::AbstractDesignMatrix< T >.

◆ getNumElements()

template<typename T >
size_t fluxionum::DesignMatrix< T >::getNumElements ( ) const
inlineoverridevirtual

Obtain the number of elements of the DesignMatrix \(X\).

Returns
The number of elements of the DesignMatrix \(X\)
See also
fluxionum::DesignMatrix::X
fluxionum::AbstractDesignMatrix::getNumElements

Implements fluxionum::AbstractDesignMatrix< T >.

◆ getNumRows()

template<typename T >
size_t fluxionum::DesignMatrix< T >::getNumRows ( ) const
inlineoverridevirtual

Obtain the number of rows of the DesignMatrix \(X\).

Returns
The number of rows of the DesignMatrix \(X\)
See also
fluxionum::DesignMatrix::X
fluxionum::AbstractDesignMatrix::getNumRows

Implements fluxionum::AbstractDesignMatrix< T >.

◆ getRow()

template<typename T >
arma::subview_row<T> const fluxionum::DesignMatrix< T >::getRow ( size_t const  i) const
inline

Obtain the \(i\)-th row of the DesignMatrix \(X\).

Parameters
iIndex of the row to be obtained
Returns
The \(i\)-th row of the DesignMatrix \(X\)
See also
fluxionum::DesignMatrix::X

◆ getRowCopy()

template<typename T >
arma::Row<T> fluxionum::DesignMatrix< T >::getRowCopy ( size_t const  i) const
inline

Like DesignMatrix::getRow(size_t const) but returning a copy by value instead of a view-like reference.

See also
fluxionum::DesignMatrix::getRow(size_t const)

◆ getWritableX()

template<typename T >
arma::Mat<T>& fluxionum::DesignMatrix< T >::getWritableX ( )
inline

Obtain a writable reference to the \(X\) matrix.

WARNING use this method only if you know how to manipulate underlying data structures of armadillo library

Returns
Writable reference to the \(X\) matrix
See also
fluxionum::DesignMatrix::X

◆ getX()

template<typename T >
arma::Mat<T> const& fluxionum::DesignMatrix< T >::getX ( ) const
inline

Obtain a constant/read reference to the \(X\) matrix.

Returns
Constant/read reference to the \(X\) matrix
See also
fluxionum::DesignMatrix::X

◆ mergeInPlace()

template<typename T >
virtual void fluxionum::DesignMatrix< T >::mergeInPlace ( DesignMatrix< T > const &  dm)
inlinevirtual

Merge given DesignMatrix into this DesignMatrix.

After merging, the values of this DesignMatrix will be the union of the previous values and the new ones from the given DesignMatrix dm

Parameters
dmDesignMatrix to be merged into this

◆ operator()()

template<typename T >
T& fluxionum::DesignMatrix< T >::operator() ( size_t const  i,
size_t const  j 
)
inlineoverridevirtual

Access to the \(x_{ij}\) component of the \(X\) design matrix.

Parameters
iThe row of the element being accessed
jThe column of the element being accessed
Returns
Reference to the element at \(i\)-th row and \(j\)-th column
See also
fluxionum::DesignMatrix::X
AbstractDesignMatrix::operator()(size_t const, size_t const)

Implements fluxionum::AbstractDesignMatrix< T >.

◆ setColumn()

template<typename T >
void fluxionum::DesignMatrix< T >::setColumn ( size_t const  j,
arma::Col< T > const &  col 
)
inline

Set the \(j\)-th column of the DesignMatrix \(X\).

Parameters
jIndex of the column to be setted
colNew values for the column to be setted
See also
fluxionum::DesignMatrix::X

◆ swapColumns() [1/3]

template<typename T >
void fluxionum::DesignMatrix< T >::swapColumns ( arma::uvec const &  indices)
inline

Swap the columns of the DesignMatrix.

Let \(\vec{u} = (u_1, \ldots, u_n)\) be the vector of indices for the \(n\) columns of the matrix \(X \in \mathbb{R}^{m \times n}\). Thus, the new matrix \(X' \in \mathbb{R}^{m \times n}\) can be obtained from the \(X\) matrix simply by assuming that the \(i\)-th column of the \(X'\) matrix is the \(u_i\)-th column of the \(X\) matrix

Parameters
indicesThe vector of indices \(\vec{u} = (u_1, \ldots, u_n)\)

◆ swapColumns() [2/3]

template<typename T >
void fluxionum::DesignMatrix< T >::swapColumns ( vector< long unsigned int > const &  indices)
inline

◆ swapColumns() [3/3]

template<typename T >
void fluxionum::DesignMatrix< T >::swapColumns ( vector< unsigned long long > const &  indices)
inline

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