SG++-Doxygen-Documentation
|
A class to store two-dimensional data. More...
#include <DataMatrixSP.hpp>
Public Member Functions | |
void | abs () |
Sets all elements to their absolute value. More... | |
void | add (const DataMatrixSP &matr) |
Adds the values from another DataMatrixSP to the current values. More... | |
void | addReduce (DataVectorSP &reduction) |
Reduce the DataMatrixSP along the columns by adding all entries in one row. More... | |
void | addReduce (DataVectorSP &reduction, DataVectorSP &beta, size_t start_beta) |
Reduce the DataMatrixSP along the columns by adding all entries in one row. More... | |
void | addSize (size_t inc_nrows) |
Reserves memory for potentially inc_nrows new rows; the actual number of rows remains unchanged. More... | |
size_t | appendRow () |
Appends a new row and returns index of it. More... | |
size_t | appendRow (const DataVectorSP &vec) |
Appends a new row with data contained in DataVectorSP vec and returns index of new row. More... | |
void | componentwise_div (const DataMatrixSP &matr) |
Divides the current DataMatrixSP component-wise by another DataMatrixSP. More... | |
void | componentwise_mult (const DataMatrixSP &matr) |
Multiplies the current DataMatrixSP component-wise with another DataMatrixSP. More... | |
void | copyFrom (const DataMatrixSP &matr) |
Copies the data from another DataMatrixSP matr. More... | |
DataMatrixSP (size_t nrows, size_t ncols) | |
Create a two-dimensional DataMatrixSP with nrows rows and ncols columns (uninitialized values). More... | |
DataMatrixSP (size_t nrows, size_t ncols, float value) | |
Create a two-dimensional DataMatrixSP with nrows rows and ncols columns and initializes all elements with the same value. More... | |
DataMatrixSP (const DataMatrixSP &matr) | |
Create a new DataMatrixSP that is a copy of matr. More... | |
DataMatrixSP (float *input, size_t nrows, size_t ncols) | |
Create a new DataMatrixSP from a float array. More... | |
void | expand (const DataVectorSP &expand) |
expands a given DataVectorSP into a DataMatrixSP. More... | |
float | get (size_t row, size_t col) const |
Returns the value of the element at position [row,col]. More... | |
void | getColumn (size_t col, DataVectorSP &vec) const |
Copies the values of a column to the DataVectorSP vec. More... | |
size_t | getInc () const |
Get the current number of rows by which the DataMatrixSP is extended, if appendRow() is called and no unused rows are left. More... | |
size_t | getNcols () const |
Returns the number of columns of the DataMatrixSP. More... | |
size_t | getNrows () const |
Returns the number of rows of the DataMatrixSP. More... | |
size_t | getNumberNonZero () const |
Determines the number of non-zero elements in the vector. More... | |
float * | getPointer () |
Returns pointer to float array containing underlying data. More... | |
const float * | getPointer () const |
Returns const pointer to float array containing underlying data. More... | |
void | getRow (size_t row, DataVectorSP &vec) const |
Copies the values of a row to the DataVectorSP vec. More... | |
void | getRow (size_t row, std::vector< float > &vec) const |
Copies the values of a row to the std::vector vec. More... | |
size_t | getSize () const |
Returns the total number of (used) elements, i.e., getNrows()*getNCols() More... | |
size_t | getUnused () const |
Returns the number of unused rows. More... | |
float | max (size_t col) const |
Returns the maximum value of column col. More... | |
float | max () const |
Returns the maximum over all entries. More... | |
float | min (size_t col) const |
Returns the minimum value of column col. More... | |
float | min () const |
Returns the minimum over all entries. More... | |
void | minmax (size_t col, float *min, float *max) const |
Determines minimum and maximum of column col. More... | |
void | minmax (float *min, float *max) const |
Determines minimum and maximum over all entries. More... | |
void | mult (const DataVectorSP &x, DataVectorSP &y) |
Multiplies the matrix with a vector x and stores the result in another vector y. More... | |
void | mult (float scalar) |
Multiplies all elements by a constant factor. More... | |
void | normalizeDimension (size_t d) |
Normalizes the d-th dimension (entries in the d-th column) to \([0,1]\). More... | |
void | normalizeDimension (size_t d, float border) |
Normalizes the d-th dimension (entries in the d-th column) to \([border,1-border]\). More... | |
float & | operator() (size_t row, size_t col) |
Returns the value of the element at position [row,col]. More... | |
const float & | operator() (size_t row, size_t col) const |
Returns the value of the element at position [row,col]. More... | |
DataMatrixSP & | operator= (const DataMatrixSP &matr) |
Copies the data from another DataMatrixSP. More... | |
void | resize (size_t nrows) |
Resizes the DataMatrixSP to nrows rows. More... | |
void | resize (size_t nrows, size_t ncols) |
Resizes the DataMatrixSP to nrows rows and ncols columns. More... | |
void | resizeZero (size_t nrows) |
Resizes the DataMatrixSP to nrows rows. More... | |
void | resizeZero (size_t nrows, size_t ncols) |
Resizes the DataMatrixSP to nrows rows and ncols columns. More... | |
void | set (size_t row, size_t col, float value) |
Sets the element at position [row,col] to value. More... | |
void | setAll (float value) |
Sets all entries of DataMatrixSP to value. More... | |
void | setColumn (size_t col, const DataVectorSP &vec) |
Sets a column of the DataMatrixSP to the values of a DataVectorSP vec. More... | |
void | setInc (size_t inc_rows) |
Sets the current number of rows by which the DataMatrixSP is extended, if appendRow() is called and no unused rows are left. More... | |
void | setRow (size_t row, const DataVectorSP &vec) |
Sets a row of the DataMatrixSP to the values of a DataVectorSP vec. More... | |
void | sqr () |
Squares all elements of the DataMatrixSP. More... | |
void | sqrt () |
Takes the square root of all elements of the DataMatrixSP. More... | |
void | sub (const DataMatrixSP &matr) |
Subtracts the values from another DataMatrixSP of the current values. More... | |
float | sum () const |
Returns the sum of all elements. More... | |
void | toString (std::string &text) const |
Writes the data stored in the DataMatrixSP into a string. More... | |
std::string | toString () const |
Returns a description of the DataMatrixSP as a string. More... | |
void | transpose () |
Transposes this DataMatrixSP. More... | |
virtual | ~DataMatrixSP () |
Destructor. More... | |
A class to store two-dimensional data.
Typically, DataMatrixSP would contain a set of (d-dimensional) data or evaluation points, i.e., the DataMatrixSP consists of d columns, and each row is one of the points. Thus, typical functionality like obtaining the maximum for a certain dimension (or attribute), or normalizing all data points to the unit interval for a certain dimension are provided.
This is an re-implementation of the standard DataMatrix for single precision floating point numbers in order to increase support for GPUs.
sgpp::base::DataMatrixSP::DataMatrixSP | ( | size_t | nrows, |
size_t | ncols | ||
) |
Create a two-dimensional DataMatrixSP with nrows rows and ncols columns (uninitialized values).
nrows | Number of rows |
ncols | Number of columns |
sgpp::base::DataMatrixSP::DataMatrixSP | ( | size_t | nrows, |
size_t | ncols, | ||
float | value | ||
) |
Create a two-dimensional DataMatrixSP with nrows rows and ncols columns and initializes all elements with the same value.
nrows | Number of rows |
ncols | Number of columns |
value | Value for all entries |
References setAll().
sgpp::base::DataMatrixSP::DataMatrixSP | ( | const DataMatrixSP & | matr | ) |
Create a new DataMatrixSP that is a copy of matr.
matr | Reference to another instance of DataMatrixSP |
sgpp::base::DataMatrixSP::DataMatrixSP | ( | float * | input, |
size_t | nrows, | ||
size_t | ncols | ||
) |
Create a new DataMatrixSP from a float array.
The float array contains the entries row-wise: x0_0,x0_1,...,x0_ncol-1, x1_0,x1_1,... ... xnrow_0, xnrow_1,...,xnrow_ncol-1
input | float array that contains the data |
nrows | number of rows |
ncols | number of columns |
|
virtual |
Destructor.
Referenced by setInc().
void sgpp::base::DataMatrixSP::abs | ( | ) |
void sgpp::base::DataMatrixSP::add | ( | const DataMatrixSP & | matr | ) |
Adds the values from another DataMatrixSP to the current values.
Modifies the current values.
matr | The DataMatrixSP which is added to the current values |
References python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::addReduce | ( | DataVectorSP & | reduction | ) |
Reduce the DataMatrixSP along the columns by adding all entries in one row.
reduction | DataVectorSP into which the reduce columns are stored |
References sgpp::base::DataVectorSP::getSize(), python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, sgpp::base::DataVectorSP::set(), and analyse_erg::tmp.
Referenced by set().
void sgpp::base::DataMatrixSP::addReduce | ( | DataVectorSP & | reduction, |
DataVectorSP & | beta, | ||
size_t | start_beta | ||
) |
Reduce the DataMatrixSP along the columns by adding all entries in one row.
reduction | DataVectorSP to which the reduce columns are added |
beta | vector with length of number of columns beta[i] is multiplied to each element row[j][i] |
start_beta | where to start using the beta coefficients |
References sgpp::base::DataVectorSP::getSize(), python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, sgpp::base::DataVectorSP::set(), and analyse_erg::tmp.
void sgpp::base::DataMatrixSP::addSize | ( | size_t | inc_nrows | ) |
Reserves memory for potentially inc_nrows new rows; the actual number of rows remains unchanged.
Corresponds to a resize to nrows+inc_nrows new rows while leaving the current matrix' size unchanged.
inc_nrows | Number of additional rows for which storage is to be reserved. |
Referenced by appendRow().
size_t sgpp::base::DataMatrixSP::appendRow | ( | ) |
Appends a new row and returns index of it.
If the new row does not fit into the reserved memory, reserves memory for getIncRows() additional rows.
References addSize().
Referenced by appendRow().
size_t sgpp::base::DataMatrixSP::appendRow | ( | const DataVectorSP & | vec | ) |
Appends a new row with data contained in DataVectorSP vec and returns index of new row.
If the new row does not fit into the reserved memory, reserves memory for getIncRows() additional rows.
vec | DataVectorSP (length has to match getNcols()) with data |
References appendRow(), sgpp::base::DataVectorSP::getPointer(), and sgpp::base::DataVectorSP::getSize().
void sgpp::base::DataMatrixSP::componentwise_div | ( | const DataMatrixSP & | matr | ) |
Divides the current DataMatrixSP component-wise by another DataMatrixSP.
Modifies the current values. Performs
Note: No check for division by zero!
matr | the DataMatrixSP which the current DataMatrixSP is divided by |
References python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::componentwise_mult | ( | const DataMatrixSP & | matr | ) |
Multiplies the current DataMatrixSP component-wise with another DataMatrixSP.
Modifies the current values. Performs
matr | the DataMatrixSP which is multiplied to current DataMatrixSP |
References python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::copyFrom | ( | const DataMatrixSP & | matr | ) |
Copies the data from another DataMatrixSP matr.
Disregards the number of rows and columns set for the two matrices, i.e., just copies the data entry by entry (and row by row). If the dimensions match (nrows, ncols), the current DataMatrixSP is an exact copy of matr. If not, as many elements as possible are copied, and everything else is left untouched.
matr | The source DataMatrixSP containing the data |
void sgpp::base::DataMatrixSP::expand | ( | const DataVectorSP & | expand | ) |
expands a given DataVectorSP into a DataMatrixSP.
expand | DataVectorSP that should be expanded |
References sgpp::base::DataVectorSP::get(), sgpp::base::DataVectorSP::getSize(), python.statsfileInfo::i, and python.utils.statsfile2gnuplot::j.
Referenced by set().
|
inline |
Returns the value of the element at position [row,col].
row | Row |
col | Column |
Referenced by sgpp::base::PrecisionConverter::convertDataMatrixSPToDataMatrix().
void sgpp::base::DataMatrixSP::getColumn | ( | size_t | col, |
DataVectorSP & | vec | ||
) | const |
Copies the values of a column to the DataVectorSP vec.
col | The column |
vec | DataVectorSP into which the data is written |
References sgpp::base::DataVectorSP::getSize(), and python.utils.statsfile2gnuplot::j.
Referenced by set().
|
inline |
Get the current number of rows by which the DataMatrixSP is extended, if appendRow() is called and no unused rows are left.
|
inline |
Returns the number of columns of the DataMatrixSP.
Referenced by sgpp::base::PrecisionConverter::convertDataMatrixSPToDataMatrix(), sgpp::base::PrecisionConverter::convertDataMatrixToDataMatrixSP(), and sgpp::datadriven::LearnerBaseSP::predict().
|
inline |
Returns the number of rows of the DataMatrixSP.
Referenced by sgpp::base::PrecisionConverter::convertDataMatrixSPToDataMatrix(), sgpp::base::PrecisionConverter::convertDataMatrixToDataMatrixSP(), sgpp::datadriven::LearnerBaseSP::predict(), and sgpp::datadriven::LearnerBaseSP::train().
size_t sgpp::base::DataMatrixSP::getNumberNonZero | ( | ) | const |
Determines the number of non-zero elements in the vector.
References python.statsfileInfo::i.
Referenced by getUnused().
float * sgpp::base::DataMatrixSP::getPointer | ( | ) |
Returns pointer to float array containing underlying data.
Referenced by set().
const float * sgpp::base::DataMatrixSP::getPointer | ( | ) | const |
Returns const pointer to float array containing underlying data.
void sgpp::base::DataMatrixSP::getRow | ( | size_t | row, |
DataVectorSP & | vec | ||
) | const |
Copies the values of a row to the DataVectorSP vec.
row | The row |
vec | DataVectorSP into which the data is written |
References sgpp::base::DataVectorSP::getSize(), and python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::getRow | ( | size_t | row, |
std::vector< float > & | vec | ||
) | const |
Copies the values of a row to the std::vector vec.
row | The row |
vec | std::vector into which the data is written |
References python.statsfileInfo::i.
|
inline |
Returns the total number of (used) elements, i.e., getNrows()*getNCols()
Referenced by python.uq.uq_setting.UQSetting.UQSetting::convert(), python.uq.uq_setting.UQSetting.UQSetting::getTimeDependentResults(), python.uq.uq_setting.UQSetting.UQSetting::runSamples(), and python.uq.uq_setting.UQSetting.UQSetting::runSamples_withoutDistribution().
|
inline |
float sgpp::base::DataMatrixSP::max | ( | size_t | col | ) | const |
Returns the maximum value of column col.
col | Number of the column |
References python.statsfileInfo::i, and max().
float sgpp::base::DataMatrixSP::max | ( | ) | const |
Returns the maximum over all entries.
References python.statsfileInfo::i.
float sgpp::base::DataMatrixSP::min | ( | size_t | col | ) | const |
Returns the minimum value of column col.
col | Number of the column |
References python.statsfileInfo::i, and min().
float sgpp::base::DataMatrixSP::min | ( | ) | const |
Returns the minimum over all entries.
References python.statsfileInfo::i.
void sgpp::base::DataMatrixSP::minmax | ( | size_t | col, |
float * | min, | ||
float * | max | ||
) | const |
Determines minimum and maximum of column col.
col | Number of the column |
min | Reference variable for the minimum |
max | Reference variable for the maximum |
References python.statsfileInfo::i.
Referenced by normalizeDimension(), and set().
void sgpp::base::DataMatrixSP::minmax | ( | float * | min, |
float * | max | ||
) | const |
Determines minimum and maximum over all entries.
min | Reference variable for the minimum |
max | Reference variable for the maximum |
References python.statsfileInfo::i.
void sgpp::base::DataMatrixSP::mult | ( | const DataVectorSP & | x, |
DataVectorSP & | y | ||
) |
Multiplies the matrix with a vector x and stores the result in another vector y.
[in] | x | vector to be multiplied |
[out] | y | vector in which the result should be stored |
References sgpp::base::DataVectorSP::getSize(), python.statsfileInfo::i, and python.utils.statsfile2gnuplot::j.
Referenced by set().
void sgpp::base::DataMatrixSP::mult | ( | float | scalar | ) |
Multiplies all elements by a constant factor.
scalar | the constant |
References python.statsfileInfo::i.
void sgpp::base::DataMatrixSP::normalizeDimension | ( | size_t | d | ) |
Normalizes the d-th dimension (entries in the d-th column) to \([0,1]\).
Considers contents of DataMatrixSP as a d-dimensional dataset, one data point per row.
d | The dimension (column) that should be normalized (starting with 0) |
Referenced by setInc().
void sgpp::base::DataMatrixSP::normalizeDimension | ( | size_t | d, |
float | border | ||
) |
Normalizes the d-th dimension (entries in the d-th column) to \([border,1-border]\).
Considers contents of DataMatrixSP as a d-dimensional dataset, one data point per row.
d | The dimension (column) that should be normalized (starting with 0) |
border | Width of the border |
References python.statsfileInfo::i, and minmax().
|
inline |
Returns the value of the element at position [row,col].
row | Row |
col | Column |
|
inline |
Returns the value of the element at position [row,col].
row | Row |
col | Column |
DataMatrixSP & sgpp::base::DataMatrixSP::operator= | ( | const DataMatrixSP & | matr | ) |
Copies the data from another DataMatrixSP.
Dimensions have to match.
matr | the DataMatrixSP containing the data |
void sgpp::base::DataMatrixSP::resize | ( | size_t | nrows | ) |
Resizes the DataMatrixSP to nrows rows.
All new additional entries are uninitialized. If nrows is smaller than the current number of rows, all superfluous entries are removed.
nrows | New number of rows of the DataMatrixSP |
void sgpp::base::DataMatrixSP::resize | ( | size_t | nrows, |
size_t | ncols | ||
) |
Resizes the DataMatrixSP to nrows rows and ncols columns.
All new additional entries are uninitialized. If nrows*ncols is smaller than the current number of entries, all superfluous entries are removed.
nrows | New number of rows of the DataMatrixSP |
ncols | New number of columns of the DataMatrixSP |
void sgpp::base::DataMatrixSP::resizeZero | ( | size_t | nrows | ) |
Resizes the DataMatrixSP to nrows rows.
All new additional entries are set to zero. If nrows is smaller than the current number of rows, all superfluous entries are removed.
nrows | New number of rows of the DataMatrixSP |
References python.statsfileInfo::i.
void sgpp::base::DataMatrixSP::resizeZero | ( | size_t | nrows, |
size_t | ncols | ||
) |
Resizes the DataMatrixSP to nrows rows and ncols columns.
All new additional entries are set to zero. If nrows*ncols is smaller than the current number of entries, all superfluous entries are removed.
nrows | New number of rows of the DataMatrixSP |
ncols | New number of columns of the DataMatrixSP |
References python.statsfileInfo::i.
|
inline |
Sets the element at position [row,col] to value.
row | Row |
col | Column |
value | New value for element |
References abs(), add(), addReduce(), componentwise_div(), componentwise_mult(), expand(), getColumn(), getPointer(), getRow(), max(), min(), minmax(), mult(), setColumn(), setRow(), sqr(), sqrt(), sub(), and sum().
Referenced by sgpp::base::PrecisionConverter::convertDataMatrixToDataMatrixSP(), sgpp::base::HashGridStorage::getLevelIndexArraysForEval(), and sgpp::base::HashGridStorage::getLevelIndexMaskArraysForModEval().
void sgpp::base::DataMatrixSP::setAll | ( | float | value | ) |
Sets all entries of DataMatrixSP to value.
value | New value for all entries |
References python.statsfileInfo::i.
Referenced by DataMatrixSP().
void sgpp::base::DataMatrixSP::setColumn | ( | size_t | col, |
const DataVectorSP & | vec | ||
) |
Sets a column of the DataMatrixSP to the values of a DataVectorSP vec.
col | The column which is to be overwritten |
vec | DataVectorSP containing the data of the column |
References sgpp::base::DataVectorSP::get(), sgpp::base::DataVectorSP::getSize(), and python.utils.statsfile2gnuplot::j.
Referenced by set().
|
inline |
Sets the current number of rows by which the DataMatrixSP is extended, if appendRow() is called and no unused rows are left.
Defaults to 100.
inc_rows | Row increment |
References normalizeDimension(), toString(), and ~DataMatrixSP().
void sgpp::base::DataMatrixSP::setRow | ( | size_t | row, |
const DataVectorSP & | vec | ||
) |
Sets a row of the DataMatrixSP to the values of a DataVectorSP vec.
row | The row which is to be overwritten |
vec | DataVectorSP containing the data of the row |
References sgpp::base::DataVectorSP::get(), sgpp::base::DataVectorSP::getSize(), and python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::sqr | ( | ) |
void sgpp::base::DataMatrixSP::sqrt | ( | ) |
Takes the square root of all elements of the DataMatrixSP.
References python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::sub | ( | const DataMatrixSP & | matr | ) |
Subtracts the values from another DataMatrixSP of the current values.
Modifies the current values.
matr | The DataMatrixSP which is subtracted from the current values |
References python.statsfileInfo::i.
Referenced by set().
float sgpp::base::DataMatrixSP::sum | ( | ) | const |
Returns the sum of all elements.
References python.statsfileInfo::i.
Referenced by set().
void sgpp::base::DataMatrixSP::toString | ( | std::string & | text | ) | const |
Writes the data stored in the DataMatrixSP into a string.
text | String to which the data is written |
References python.statsfileInfo::i, and python.utils.statsfile2gnuplot::j.
Referenced by python.controller.LearnerEventController.LearnerEventController::__repr__(), python.controller.SolverEventController.SolverEventController::__repr__(), python.uq.learner.Learner.Learner::createMemento(), python.learner.Learner.Learner::createMemento(), and python.learner.formatter.GridFormatter.GridFormatter::serialize().
std::string sgpp::base::DataMatrixSP::toString | ( | ) | const |
Returns a description of the DataMatrixSP as a string.
Referenced by python.controller.LearnerEventController.LearnerEventController::__repr__(), python.controller.SolverEventController.SolverEventController::__repr__(), python.uq.learner.Learner.Learner::createMemento(), python.learner.Learner.Learner::createMemento(), python.learner.formatter.GridFormatter.GridFormatter::serialize(), and setInc().
void sgpp::base::DataMatrixSP::transpose | ( | ) |
Transposes this DataMatrixSP.
References python.statsfileInfo::i, and python.utils.statsfile2gnuplot::j.