SG++-Doxygen-Documentation
|
A class to store one-dimensional data. More...
#include <DataVectorSP.hpp>
Public Member Functions | |
void | abs () |
Sets all elements to their absolute value. More... | |
void | add (const DataVectorSP &vec) |
Adds the values from another DataVectorSP to the current values. More... | |
void | addSize (size_t inc_elems) |
Add add potentially new elements to the DataVectorSP. More... | |
size_t | append () |
Appends a new element and returns index of it. More... | |
size_t | append (float value) |
Appends a new element and returns index of new element. More... | |
void | axpy (float a, DataVectorSP &x) |
Adds a*x to current vector. More... | |
void | componentwise_div (const DataVectorSP &vec) |
Divides the current DataVectorSP component-wise by another DataVectorSP. More... | |
void | componentwise_mult (const DataVectorSP &vec) |
Multiplies the current DataVectorSP component-wise with another DataVectorSP. More... | |
void | copyFrom (const DataVectorSP &vec) |
Copies the data from another DataVectorSP vec. More... | |
DataVectorSP (size_t size) | |
Create a DataVectorSP with size elements (uninitialized values). More... | |
DataVectorSP (size_t size, float value) | |
Create a DataVectorSP with size elements and initializes all elements with the same value. More... | |
DataVectorSP (const DataVectorSP &vec) | |
Create a new DataVectorSP that is a copy of vec. More... | |
DataVectorSP (float *input, size_t size) | |
Create a new DataVectorSP from a float array with size elements. More... | |
DataVectorSP (std::vector< float > input) | |
Create a new DataVectorSP from a std::vector<float>. More... | |
DataVectorSP (std::vector< int > input) | |
Create a new DataVectorSP from a std::vector<int>. More... | |
float | dotProduct (const DataVectorSP &vec) const |
Returns the dot product of the two vectors. More... | |
float | get (size_t i) const |
Returns the i-th element. More... | |
size_t | getInc () const |
Get the current number of elements by which the DataVectorSP is extended, if append() or insert() is called and no unused rows are left. More... | |
size_t | getNumberNonZero () const |
Determines the number of non-zero elements in the vector. More... | |
float * | getPointer () |
gets a pointer to the data array More... | |
const float * | getPointer () const |
gets a const pointer to the data array More... | |
size_t | getSize () const |
gets the elements stored in the vector More... | |
size_t | getUnused () const |
Returns the number of unused elements. More... | |
void | insert (size_t index, float value) |
Inserts a new element at the given index. More... | |
float | l2Norm () const |
Returns the vector's \(l^2\)-norm, i.e., \(\sqrt{ \sum_i x_i^2 }\). More... | |
float | max () const |
Returns the maximum over all entries. More... | |
float | maxNorm () const |
calculates the vector's max norm More... | |
float | min () const |
Returns the minimum over all entries. More... | |
void | minmax (float *min, float *max) const |
Determines minimum and maximum over all entries. More... | |
void | mult (float scalar) |
multiplies all elements by a constant factor More... | |
void | normalize () |
Normalizes vector entries to [0,1]. More... | |
void | normalize (float border) |
Normalizes vector entries to [border, 1-border]. More... | |
DataVectorSP & | operator= (const DataVectorSP &vec) |
Copies the data from another DataVectorSP. More... | |
float & | operator[] (size_t i) |
Returns a reference to the i-th element. More... | |
const float & | operator[] (size_t i) const |
Returns a constant reference to the i-th element. More... | |
void | partitionClasses (float threshold) |
Partitions vector into two classes using a choosen border. More... | |
void | resize (size_t size) |
Resizes the DataVectorSP to size elements. More... | |
void | resizeZero (size_t nrows) |
Resizes the DataVectorSP to size elements. More... | |
void | restructure (std::vector< size_t > &remainingIndex) |
Resizes the DataVectorSP by removing entries. More... | |
float | RMSNorm () const |
Returns the vector's root mean square (RMS)-norm, i.e., \(\sqrt{ 1/N \sum_{i=1}^N x_i^2 }\). More... | |
void | set (size_t i, float value) |
Sets the element at index i to value. More... | |
void | setAll (float value) |
Sets all values of DataVectorSP to value. More... | |
void | setInc (size_t inc_elems) |
Sets the current number of elements by which the DataVectorSP is extended, if append() or insert() is called and no unused elements are left. More... | |
void | sqr () |
Squares all elements of the DataVectorSP. More... | |
void | sqrt () |
Takes the square root of all elements of the DataVectorSP. More... | |
void | sub (const DataVectorSP &vec) |
Subtracts the values from another DataVectorSP 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 DataVectorSP into a string. More... | |
std::string | toString () const |
Returns a description of the DataVectorSP as a string. More... | |
virtual | ~DataVectorSP () |
Destructor. More... | |
A class to store one-dimensional data.
Typically, an object of type DataVectorSP will contain an array of (hierarchical) coefficients (or surplusses), or the coordinates of a data point at which a sparse grid function should be evaluated.
This is an re-implementation of the standard DataVector for single precision floating point numbers in order to increase support for GPUs.
|
explicit |
Create a DataVectorSP with size elements (uninitialized values).
size | Number of elements |
sgpp::base::DataVectorSP::DataVectorSP | ( | size_t | size, |
float | value | ||
) |
Create a DataVectorSP with size elements and initializes all elements with the same value.
size | Number of elements |
value | Value for all entries |
References setAll().
sgpp::base::DataVectorSP::DataVectorSP | ( | const DataVectorSP & | vec | ) |
Create a new DataVectorSP that is a copy of vec.
vec | Reference to another instance of DataVectorSP |
sgpp::base::DataVectorSP::DataVectorSP | ( | float * | input, |
size_t | size | ||
) |
Create a new DataVectorSP from a float array with size elements.
input | float array that contains the data |
size | number of elements |
|
explicit |
Create a new DataVectorSP from a std::vector<float>.
input | std::vector<float> that contains the data |
|
explicit |
Create a new DataVectorSP from a std::vector<int>.
input | std::vector<int> that contains the data |
|
virtual |
Destructor.
Referenced by setInc().
void sgpp::base::DataVectorSP::abs | ( | ) |
void sgpp::base::DataVectorSP::add | ( | const DataVectorSP & | vec | ) |
Adds the values from another DataVectorSP to the current values.
Modifies the current values.
vec | The DataVectorSP which is added to the current values |
References python.statsfileInfo::i.
Referenced by addSize(), get(), sgpp::solver::BiCGStabSP::solve(), and sgpp::solver::ConjugateGradientsSP::solve().
void sgpp::base::DataVectorSP::addSize | ( | size_t | inc_elems | ) |
Add add potentially new elements to the DataVectorSP.
The size remains unchanged Reserves memory for potentially inc_elems new elements; the actual number of elements remains unchanged. Corresponds to a resize to size+inc_elems new elements while leaving the current vector's size unchanged.
inc_elems | Number of additional elements for which storage is to be reserved. |
References add().
Referenced by append().
size_t sgpp::base::DataVectorSP::append | ( | ) |
size_t sgpp::base::DataVectorSP::append | ( | float | value | ) |
void sgpp::base::DataVectorSP::axpy | ( | float | a, |
DataVectorSP & | x | ||
) |
Adds a*x to current vector.
BLAS Level 1 (elementary vector operations) operation: axpy.
a | A scalar |
x | Reference to the DataVectorSP |
References python.statsfileInfo::i.
Referenced by get(), sgpp::solver::BiCGStabSP::solve(), and sgpp::solver::ConjugateGradientsSP::solve().
void sgpp::base::DataVectorSP::componentwise_div | ( | const DataVectorSP & | vec | ) |
Divides the current DataVectorSP component-wise by another DataVectorSP.
Modifies the current values. Performs
Note: No check for division by zero!
vec | the DataVectorSP which the current DataVectorSP is divided by |
References python.statsfileInfo::i.
Referenced by get().
void sgpp::base::DataVectorSP::componentwise_mult | ( | const DataVectorSP & | vec | ) |
Multiplies the current DataVectorSP component-wise with another DataVectorSP.
Modifies the current values. Performs
vec | the DataVectorSP which is multiplied to current DataVectorSP |
References python.statsfileInfo::i.
void sgpp::base::DataVectorSP::copyFrom | ( | const DataVectorSP & | vec | ) |
Copies the data from another DataVectorSP vec.
Disregards the number of entries set for the two vectors, i.e., just copies the data entry by entry. If the size matches, the current DataVectorSP is an exact copy of vec. If not, as many elements as possible are copied, and everything else is left untouched.
vec | The source DataVectorSP containing the data |
float sgpp::base::DataVectorSP::dotProduct | ( | const DataVectorSP & | vec | ) | const |
Returns the dot product of the two vectors.
vec | Reference to another vector |
References python.statsfileInfo::i, and sum().
Referenced by get(), sgpp::solver::BiCGStabSP::solve(), and sgpp::solver::ConjugateGradientsSP::solve().
|
inline |
Returns the i-th element.
i | position of the element |
References abs(), add(), axpy(), componentwise_div(), componentwise_mult(), dotProduct(), getPointer(), python.statsfileInfo::i, l2Norm(), max(), maxNorm(), min(), minmax(), mult(), RMSNorm(), sqr(), sqrt(), sub(), and sum().
Referenced by sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), sgpp::base::DataMatrixSP::expand(), sgpp::datadriven::LearnerBaseSP::getAccuracy(), sgpp::datadriven::LearnerBaseSP::getCassificatorQuality(), sgpp::base::DataMatrixSP::setColumn(), and sgpp::base::DataMatrixSP::setRow().
|
inline |
Get the current number of elements by which the DataVectorSP is extended, if append() or insert() is called and no unused rows are left.
size_t sgpp::base::DataVectorSP::getNumberNonZero | ( | ) | const |
Determines the number of non-zero elements in the vector.
References python.statsfileInfo::f, and python.statsfileInfo::i.
Referenced by getUnused().
float * sgpp::base::DataVectorSP::getPointer | ( | ) |
gets a pointer to the data array
Referenced by sgpp::base::DataMatrixSP::appendRow(), and get().
const float * sgpp::base::DataVectorSP::getPointer | ( | ) | const |
gets a const pointer to the data array
|
inline |
gets the elements stored in the vector
Referenced by sgpp::base::DataMatrixSP::addReduce(), sgpp::base::DataMatrixSP::appendRow(), python.uq.uq_setting.UQSetting.UQSetting::convert(), sgpp::base::PrecisionConverter::convertDataVectorSPToDataVector(), sgpp::base::PrecisionConverter::convertDataVectorToDataVectorSP(), sgpp::datadriven::LearnerBaseSP::dumpFunction(), sgpp::datadriven::LearnerBaseSP::dumpGrid(), sgpp::base::DataMatrixSP::expand(), sgpp::datadriven::LearnerBaseSP::getAccuracy(), sgpp::datadriven::LearnerBaseSP::getCassificatorQuality(), sgpp::base::DataMatrixSP::getColumn(), sgpp::base::DataMatrixSP::getRow(), python.uq.uq_setting.UQSetting.UQSetting::getTimeDependentResults(), sgpp::base::DataMatrixSP::mult(), RMSNorm(), python.uq.uq_setting.UQSetting.UQSetting::runSamples(), python.uq.uq_setting.UQSetting.UQSetting::runSamples_withoutDistribution(), sgpp::base::DataMatrixSP::setColumn(), sgpp::base::DataMatrixSP::setRow(), sgpp::solver::BiCGStabSP::solve(), sgpp::solver::ConjugateGradientsSP::solve(), and sgpp::datadriven::LearnerBaseSP::train().
|
inline |
Returns the number of unused elements.
References getNumberNonZero().
void sgpp::base::DataVectorSP::insert | ( | size_t | index, |
float | value | ||
) |
float sgpp::base::DataVectorSP::l2Norm | ( | ) | const |
Returns the vector's \(l^2\)-norm, i.e., \(\sqrt{ \sum_i x_i^2 }\).
References componentwise_mult(), and sum().
float sgpp::base::DataVectorSP::max | ( | ) | const |
Returns the maximum over all entries.
References python.statsfileInfo::i.
Referenced by get(), maxNorm(), and normalize().
float sgpp::base::DataVectorSP::maxNorm | ( | ) | const |
calculates the vector's max norm
References python.statsfileInfo::i, and max().
Referenced by get().
float sgpp::base::DataVectorSP::min | ( | ) | const |
Returns the minimum over all entries.
References python.statsfileInfo::i.
Referenced by get(), and normalize().
void sgpp::base::DataVectorSP::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.
Referenced by get(), and normalize().
void sgpp::base::DataVectorSP::mult | ( | float | scalar | ) |
multiplies all elements by a constant factor
scalar | the constant |
References python.statsfileInfo::i.
Referenced by get(), sgpp::solver::BiCGStabSP::solve(), and sgpp::solver::ConjugateGradientsSP::solve().
void sgpp::base::DataVectorSP::normalize | ( | ) |
void sgpp::base::DataVectorSP::normalize | ( | float | border | ) |
Normalizes vector entries to [border, 1-border].
border | width of border |
References python.statsfileInfo::i, max(), min(), and minmax().
DataVectorSP & sgpp::base::DataVectorSP::operator= | ( | const DataVectorSP & | vec | ) |
Copies the data from another DataVectorSP.
Dimensions have to match.
vec | the DataVectorSP containing the data |
|
inline |
Returns a reference to the i-th element.
i | position of the element |
References python.statsfileInfo::i.
|
inline |
Returns a constant reference to the i-th element.
i | position of the element |
References python.statsfileInfo::i.
void sgpp::base::DataVectorSP::partitionClasses | ( | float | threshold | ) |
Partitions vector into two classes using a choosen border.
threshold | value of the border |
References python.statsfileInfo::i.
Referenced by setInc().
void sgpp::base::DataVectorSP::resize | ( | size_t | size | ) |
Resizes the DataVectorSP to size elements.
All new additional entries are uninitialized. If nrows is smaller than the current number of rows, all superfluous entries are removed.
size | New number of elements of the DataVectorSP |
void sgpp::base::DataVectorSP::resizeZero | ( | size_t | nrows | ) |
Resizes the DataVectorSP to size elements.
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 DataVectorSP |
References python.statsfileInfo::i.
Referenced by sgpp::datadriven::LearnerBaseSP::train().
void sgpp::base::DataVectorSP::restructure | ( | std::vector< size_t > & | remainingIndex | ) |
Resizes the DataVectorSP by removing entries.
Throws an exception if boundaries a violated.
remainingIndex | vector that contains the remaining indices of the DataVectorSP |
References python.statsfileInfo::i.
float sgpp::base::DataVectorSP::RMSNorm | ( | ) | const |
Returns the vector's root mean square (RMS)-norm, i.e., \(\sqrt{ 1/N \sum_{i=1}^N x_i^2 }\).
If the vector's entries correspond to function values on a full grid, this is the discrete \(L^2\)-norm of the corresponding function.
References componentwise_mult(), getSize(), l2Norm(), and sum().
Referenced by get().
void sgpp::base::DataVectorSP::set | ( | size_t | i, |
float | value | ||
) |
Sets the element at index i to value.
i | Index |
value | New value for element |
References python.statsfileInfo::i.
Referenced by sgpp::base::DataMatrixSP::addReduce(), and sgpp::base::PrecisionConverter::convertDataVectorToDataVectorSP().
void sgpp::base::DataVectorSP::setAll | ( | float | value | ) |
Sets all values of DataVectorSP to value.
value | New value for all entries |
References python.statsfileInfo::i.
Referenced by DataVectorSP(), sgpp::datadriven::LearnerBaseSP::InitializeGrid(), sgpp::solver::BiCGStabSP::solve(), and sgpp::solver::ConjugateGradientsSP::solve().
|
inline |
Sets the current number of elements by which the DataVectorSP is extended, if append() or insert() is called and no unused elements are left.
Defaults to 100.
inc_elems | Increment |
References normalize(), partitionClasses(), toString(), and ~DataVectorSP().
void sgpp::base::DataVectorSP::sqr | ( | ) |
Squares all elements of the DataVectorSP.
References python.statsfileInfo::i.
Referenced by get(), and sgpp::datadriven::LearnerBaseSP::getAccuracy().
void sgpp::base::DataVectorSP::sqrt | ( | ) |
Takes the square root of all elements of the DataVectorSP.
References python.statsfileInfo::i.
Referenced by get().
void sgpp::base::DataVectorSP::sub | ( | const DataVectorSP & | vec | ) |
Subtracts the values from another DataVectorSP of the current values.
Modifies the current values.
vec | The DataVectorSP which is subtracted from the current values |
References python.statsfileInfo::i.
Referenced by get(), and sgpp::datadriven::LearnerBaseSP::getAccuracy().
float sgpp::base::DataVectorSP::sum | ( | ) | const |
Returns the sum of all elements.
References python.statsfileInfo::i.
Referenced by dotProduct(), get(), sgpp::datadriven::LearnerBaseSP::getAccuracy(), l2Norm(), and RMSNorm().
void sgpp::base::DataVectorSP::toString | ( | std::string & | text | ) | const |
Writes the data stored in the DataVectorSP into a string.
text | string to which the data is written |
References python.statsfileInfo::i.
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::DataVectorSP::toString | ( | ) | const |
Returns a description of the DataVectorSP 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().