SG++-Doxygen-Documentation
sgpp::combigrid::FunctionLookupTable Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

sgpp::combigrid::FunctionLookupTable::FunctionLookupTable ( MultiFunction const &  func)
explicit

Member Function Documentation

void sgpp::combigrid::FunctionLookupTable::addEntry ( base::DataVector const &  x,
double  y 
)

Adds a function value into the storage.

Parameters
xParameter of the function.
yResult of the function evaluation.

Referenced by deserialize(), evalThreadsafe(), and operator()().

bool sgpp::combigrid::FunctionLookupTable::containsEntry ( base::DataVector const &  x)
Returns
true iff the hashtable contains a function value for the parameter x.
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
Returns
the number of stored function values.
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().

MultiFunction sgpp::combigrid::FunctionLookupTable::toMultiFunction ( ) const

This is a convenience function that is especially nice for python code.

Returns
a MultiFunction object that delegates each call to this FunctionLookupTable.

The documentation for this class was generated from the following files: