Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
Adapt a std::function<double(double)> to the Function Interface. More...
#include <FunctionAdapter.h>
Public Member Functions | |
FunctionAdapter (std::function< double(double)> function) | |
Constructor. | |
virtual | ~FunctionAdapter ()=default |
Default destructor. | |
double | operator() (const double x) const override |
void | operator() (const std::vector< double > &xs, std::vector< double > &out) const override |
std::unique_ptr< Function > | clone () const override |
Private Attributes | |
std::function< double(double)> | m_function |
Adapt a std::function<double(double)> to the Function Interface.
In some case one need to wrap a std::function into the Function Interface. This class provide this functionality. In particular it allows to build a Function out of a Lamda expression.
Definition at line 44 of file FunctionAdapter.h.
|
explicit |
Constructor.
function | A std::function<double(double)> to be adapted as a Function. |
Definition at line 32 of file FunctionAdapter.cpp.
|
virtualdefault |
Default destructor.
|
overridevirtual |
Creates a clone of the function adapter object.
Implements Euclid::MathUtils::NAryFunction< N >.
Definition at line 43 of file FunctionAdapter.cpp.
References m_function.
Converts the value x from the input domain to the output domain by calling the internal std::function<double(double)>.
x | The value to convert |
Definition at line 34 of file FunctionAdapter.cpp.
References m_function.
|
override |
Converts the vector of x values from the input domain to the output domain by calling the internal std::function<double(double)> repeatedly.
xs | The values to convert |
out | Output vector |
Definition at line 38 of file FunctionAdapter.cpp.
References std::vector< T >::begin(), std::array< T >::begin(), std::array< T >::end(), m_function, std::vector< T >::resize(), std::array< T >::size(), and std::transform().
|
private |
Definition at line 79 of file FunctionAdapter.h.
Referenced by clone(), operator()(), and operator()().