1 #ifndef _FLUXIONUM_INDEXED_DESIGN_MATRIX_H_
3 #include <fluxionum/DesignMatrix.h>
4 #include <fluxionum/TemporalDesignMatrix.h>
5 #include <fluxionum/FluxionumTypes.h>
6 #include <filems/read/core/DesignMatrixReader.h>
14 using std::shared_ptr;
15 using std::make_shared;
42 template <
typename IndexType,
typename VarType>
90 arma::Mat<VarType>
const &
X,
size_t const indicesColumnIndex
92 arma::Col<VarType> inds =
X.col(indicesColumnIndex);
93 size_t const m = inds.n_rows;
94 vector<IndexType>
indices(inds.n_rows);
95 for(
size_t i = 0 ; i < m ; ++i)
indices[i] = (IndexType) inds[i];
113 size_t const indicesColumnIndex,
115 vector<string>
const &
columnNames=vector<string>(0)
119 designMatrix.
getX(), indicesColumnIndex
143 vector<IndexType>
const &
indices,
145 vector<string>
const &
columnNames=vector<string>(0)
159 arma::Mat<VarType>
const &
X,
160 size_t const indicesColumnIndex,
162 vector<string>
const &
columnNames=vector<string>(0)
166 X, indicesColumnIndex
181 arma::Mat<VarType>
const &
X,
182 vector<IndexType>
const &
indices,
184 vector<string>
const &
columnNames=vector<string>(0)
203 std::unordered_map<string, string> kv;
205 size_t const idxCol = (size_t) std::strtoul(
206 kv.at(
"INDEX_COLUMN").c_str(),
nullptr, 10
245 DiffDesignMatrixType diffType = \
246 DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES
255 shared_ptr<DiffDesignMatrix<double, VarType>>
259 DiffDesignMatrixType diffType = \
260 DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES
306 #define _FLUXIONUM_INDEXED_DESIGN_MATRIX_H_
307 #include <fluxionum/IndexedDesignMatrix.tpp>
string const & getColumnName(size_t const j) const
Obtain the name of the -th column.
Definition: AbstractDesignMatrix.h:111
vector< string > columnNames
The column names for the DesignMatrix. It can be either an empty vector when no column names are spec...
Definition: AbstractDesignMatrix.h:35
bool hasColumnNames() const
Check whether there are available column names for the AbstractDesignMatrix (true) or not (false)
Definition: AbstractDesignMatrix.h:104
vector< string > const & getColumnNames() const
Obtain a constant/read reference to the column names.
Definition: AbstractDesignMatrix.h:126
This class represents a DesignMatrix .
Definition: DesignMatrix.h:41
virtual void mergeInPlace(DesignMatrix const &dm)
Merge given DesignMatrix into this DesignMatrix.
Definition: DesignMatrix.h:119
arma::Mat< VarType > X
The design matrix .
Definition: DesignMatrix.h:52
arma::Mat< VarType > const & getX() const
Obtain a constant/read reference to the matrix.
Definition: DesignMatrix.h:219
The heart of a differential design matrix is the idea that the columns are defining the values of var...
Definition: DiffDesignMatrix.h:169
Definition: IndexedDesignMatrix.h:43
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 and indices.
Definition: IndexedDesignMatrix.h:180
string indexName
The name of the index field in the original DesignMatrix.
Definition: IndexedDesignMatrix.h:75
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.
Definition: IndexedDesignMatrix.h:141
void setIndexName(string const &indexName)
Set the name of the index attribute.
Definition: IndexedDesignMatrix.h:299
IndexType & operator[](size_t const i)
Access to the -th index.
Definition: IndexedDesignMatrix.h:224
void mergeInPlace(DesignMatrix< VarType > const &dm) override
Extend DesignMatrix::mergeInPlace method so the indices are also merged.
Definition: IndexedDesignMatrix.h:269
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.
Definition: IndexedDesignMatrix.h:111
vector< IndexType > const & getIndices() const
Obtain a constant/read reference to the vector of indices.
Definition: IndexedDesignMatrix.h:287
vector< IndexType > indices
The indices vector .
Definition: IndexedDesignMatrix.h:69
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 matrix and specified indices column.
Definition: IndexedDesignMatrix.h:158
static vector< IndexType > extractIndices(arma::Mat< VarType > const &X, size_t const indicesColumnIndex)
Do a copy of the indices column from given DesignMatrix .
Definition: IndexedDesignMatrix.h:89
IndexedDesignMatrix(string const &path, string const indexName="index")
Build an IndexedDesignMatrix from data in file at given path and specified index column.
Definition: IndexedDesignMatrix.h:198
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 while the ma...
string const getIndexName() const
Obtain the name of the index attribute.
Definition: IndexedDesignMatrix.h:293
shared_ptr< DiffDesignMatrix< double, VarType > > toLinearTimeDiffDesignMatrixPointer(double const ta=0.0, double const tb=1.0, DiffDesignMatrixType diffType=DiffDesignMatrixType::FORWARD_FINITE_DIFFERENCES) const
This class represents a DesignMatrix where each row satisfy that its elements can be placed into a co...
Definition: TemporalDesignMatrix.h:74
Class to read design matrices.
Definition: DesignMatrixReader.h:44
virtual fluxionum::DesignMatrix< VarType > read(unordered_map< string, string > *keyval=nullptr)
Read the design matrix.