SG++-Doxygen-Documentation
|
This class wraps a MultiFunction and stores computed values using a hashtable to avoid reevaluating a function at points where it already has been evaluated. More...
#include <FunctionLookupTable.hpp>
Public Member Functions | |
void | addEntry (base::DataVector const &x, double y) |
Adds a function value into the storage. More... | |
bool | containsEntry (base::DataVector const &x) |
void | deserialize (std::string const &value) |
Retrieves stored values from a string generated by serialize(). More... | |
double | eval (base::DataVector const &x) |
Does the same as operator() (can be called from Python, for example). More... | |
double | evalThreadsafe (base::DataVector const &x) |
Does the same as eval(), but uses a mutex whenever the hashtable is accessed. More... | |
FunctionLookupTable (MultiFunction const &func) | |
size_t | getNumEntries () const |
double | operator() (base::DataVector const &x) |
Evaluates the function at the point x. More... | |
std::string | serialize () |
Stores the stored values into a string. More... | |
MultiFunction | toMultiFunction () const |
This is a convenience function that is especially nice for python code. More... | |
This class wraps a MultiFunction and stores computed values using a hashtable to avoid reevaluating a function at points where it already has been evaluated.
This means that only the exact same parameter will allow retrieving the function value.
|
explicit |
void sgpp::combigrid::FunctionLookupTable::addEntry | ( | base::DataVector const & | x, |
double | y | ||
) |
Adds a function value into the storage.
x | Parameter of the function. |
y | Result of the function evaluation. |
Referenced by deserialize(), evalThreadsafe(), and operator()().
bool sgpp::combigrid::FunctionLookupTable::containsEntry | ( | base::DataVector const & | x | ) |
void sgpp::combigrid::FunctionLookupTable::deserialize | ( | std::string const & | value | ) |
Retrieves stored values from a string generated by serialize().
References addEntry(), sgpp::combigrid::FloatSerializationStrategy< T >::deserialize(), python.statsfileInfo::i, python.utils.statsfile2gnuplot::j, sgpp::combigrid::DefaultSerializationStrategy< T >::serialize(), serialize(), and sgpp::combigrid::split().
Referenced by python.learner.formatter.LearnedKnowledgeFormatter.LearnedKnowledgeFormatter::deserializeFromFile(), python.learner.formatter.GridFormatter.GridFormatter::deserializeFromFile(), python.utils.GzipSerializer.GzipSerializer::deserializeFromFile(), python.uq.analysis.asgc.ASGCKnowledgeFormatter.ASGCKnowledgeFormatter::deserializeFromFile(), python.uq.sampler.asgc.ASGCSamplerFormatter.ASGCSamplerFormatter::deserializeFromFile(), and python.uq.uq_setting.UQSettingFormatter.UQSettingFormatter::deserializeFromFile().
double sgpp::combigrid::FunctionLookupTable::eval | ( | base::DataVector const & | x | ) |
Does the same as operator() (can be called from Python, for example).
Referenced by python.uq.analysis.asgc.ASGCAnalysis.ASGCAnalysis::estimateDensity().
double sgpp::combigrid::FunctionLookupTable::evalThreadsafe | ( | base::DataVector const & | x | ) |
Does the same as eval(), but uses a mutex whenever the hashtable is accessed.
Crucially, the mutex is not locked when evaluating the function, such that multiple function evaluations can be done in parallel.
References addEntry().
size_t sgpp::combigrid::FunctionLookupTable::getNumEntries | ( | ) | const |
double sgpp::combigrid::FunctionLookupTable::operator() | ( | base::DataVector const & | x | ) |
Evaluates the function at the point x.
If the function has already been evaluated at this point, the stored result will be used.
References addEntry().
std::string sgpp::combigrid::FunctionLookupTable::serialize | ( | ) |
Stores the stored values into a string.
References python.statsfileInfo::i, sgpp::combigrid::join(), and sgpp::combigrid::FloatSerializationStrategy< T >::serialize().
Referenced by deserialize(), python.utils.GzipSerializer.GzipSerializer::serializeToFile(), python.learner.formatter.LearnerFormatter.LearnerFormatter::serializeToFile(), python.learner.formatter.LearnedKnowledgeFormatter.LearnedKnowledgeFormatter::serializeToFile(), python.learner.formatter.GridFormatter.GridFormatter::serializeToFile(), python.uq.analysis.asgc.ASGCKnowledgeFormatter.ASGCKnowledgeFormatter::serializeToFile(), python.uq.sampler.asgc.ASGCSamplerFormatter.ASGCSamplerFormatter::serializeToFile(), and python.uq.uq_setting.UQSettingFormatter.UQSettingFormatter::serializeToFile().
MultiFunction sgpp::combigrid::FunctionLookupTable::toMultiFunction | ( | ) | const |
This is a convenience function that is especially nice for python code.