3 #include <fluxionum/AbstractDesignMatrix.h>
4 #include <filems/read/core/DesignMatrixReader.h>
13 using namespace helios::filems;
63 vector<string>
const &columnNames=vector<string>(0)
74 arma::Mat<T>
const &X,
75 vector<string>
const &columnNames=vector<string>(0)
90 *
this = reader.
read();
105 inline T& operator() (
size_t const i,
size_t const j)
override
120 X.insert_rows(X.n_rows, dm.
getX());
125 inline void swapColumns(vector<long unsigned int>
const& indices){
127 vector<unsigned long long>(indices.begin(), indices.end())
133 inline void swapColumns(vector<unsigned long long>
const &indices)
134 {
return swapColumns(arma::uvec(indices));}
148 {X = X.cols(indices);}
152 inline void dropColumns(vector<long unsigned int>
const &indices){
154 vector<unsigned long long>(indices.begin(), indices.end())
160 inline void dropColumns(vector<unsigned long long>
const &indices)
161 {
return dropColumns(arma::uvec(indices));}
175 {X.shed_cols(indices);}
179 inline void dropRows(vector<long unsigned int>
const &indices){
181 vector<unsigned long long>(indices.begin(), indices.end())
187 inline void dropRows(vector<unsigned long long>
const &indices)
188 {
return dropRows(arma::uvec(indices));}
202 {X.shed_rows(indices);}
209 {X.col(colIdx) += x;}
219 inline arma::Mat<T>
const &
getX()
const {
return X;}
258 inline arma::subview_row<T>
const getRow(
size_t const i)
const
265 inline arma::Row<T>
getRowCopy(
size_t const i)
const {
return getRow(i);}
272 inline arma::subview_col<T>
const getColumn(
size_t const j)
const
280 {
return getColumn(j);}
288 string const &columnName
290 {
return getColumn(translateColumnNameToIndex(columnName));}
297 {
return getColumn(columnName);}
304 inline void setColumn(
size_t const j, arma::Col<T>
const &col)
The abstract class which represents the fundamentals of any design matrix.
Definition: AbstractDesignMatrix.h:26
This class represents a DesignMatrix .
Definition: DesignMatrix.h:41
void dropColumns(vector< unsigned long long > const &indices)
Definition: DesignMatrix.h:160
virtual void mergeInPlace(DesignMatrix const &dm)
Merge given DesignMatrix into this DesignMatrix.
Definition: DesignMatrix.h:119
void dropColumns(vector< long unsigned int > const &indices)
Definition: DesignMatrix.h:152
size_t getNumColumns() const override
Obtain the number of columns of the DesignMatrix .
Definition: DesignMatrix.h:244
arma::Col< T > getColumnCopy(string const &columnName) const
Like DesignMatrix::getColumn(string const &) but returning a copy by value instead of a view-like ref...
Definition: DesignMatrix.h:296
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 refer...
Definition: DesignMatrix.h:279
DesignMatrix(string const &path, string const &sep=",")
Build a DesignMatrix from data in file at given path.
Definition: DesignMatrix.h:86
DesignMatrix(vector< string > const &columnNames=vector< string >(0))
Build a DesignMatrix with no data.
Definition: DesignMatrix.h:62
void dropRows(vector< long unsigned int > const &indices)
Definition: DesignMatrix.h:179
arma::Mat< T > & getWritableX()
Obtain a writable reference to the matrix.
Definition: DesignMatrix.h:230
arma::subview_row< T > const getRow(size_t const i) const
Obtain the -th row of the DesignMatrix .
Definition: DesignMatrix.h:258
size_t getNumRows() const override
Obtain the number of rows of the DesignMatrix .
Definition: DesignMatrix.h:237
void dropColumns(arma::uvec const &indices)
Remove the columns from the DesignMatrix.
Definition: DesignMatrix.h:174
void swapColumns(arma::uvec const &indices)
Swap the columns of the DesignMatrix.
Definition: DesignMatrix.h:147
void setColumn(size_t const j, arma::Col< T > const &col)
Set the -th column of the DesignMatrix .
Definition: DesignMatrix.h:304
void dropRows(vector< unsigned long long > const &indices)
Definition: DesignMatrix.h:187
void addToColumn(size_t const colIdx, T const x)
Add to all elements of -th column.
Definition: DesignMatrix.h:208
arma::Mat< T > X
The design matrix .
Definition: DesignMatrix.h:52
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 referenc...
Definition: DesignMatrix.h:265
arma::Mat< T > const & getX() const
Obtain a constant/read reference to the matrix.
Definition: DesignMatrix.h:219
void swapColumns(vector< long unsigned int > const &indices)
Definition: DesignMatrix.h:125
virtual void dropRows(arma::uvec const &indices)
Remove the rows from the DesignMatrix.
Definition: DesignMatrix.h:201
void swapColumns(vector< unsigned long long > const &indices)
Definition: DesignMatrix.h:133
DesignMatrix(arma::Mat< T > const &X, vector< string > const &columnNames=vector< string >(0))
Build a DesignMatrix from given armadillo matrix.
Definition: DesignMatrix.h:73
size_t getNumElements() const override
Obtain the number of elements of the DesignMatrix .
Definition: DesignMatrix.h:251
arma::subview_col< T > const getColumn(size_t const j) const
Obtain the -th column of the DesignMatrix .
Definition: DesignMatrix.h:272
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.
Definition: DesignMatrix.h:287
Class to read design matrices.
Definition: DesignMatrixReader.h:44
virtual fluxionum::DesignMatrix< VarType > read(unordered_map< string, string > *keyval=nullptr)
Read the design matrix.