|
PARTONS/NumA++
|
Numerical Analysis C++ routines
|
![]() |
Class for defining one-dimensional functions that can be used as arguments in virtual methods. More...
Public Member Functions | |
| FunctionType1D () | |
| Empty constructor. More... | |
| virtual | ~FunctionType1D () |
| Default destructor. More... | |
| virtual double | operator() (double x, std::vector< double > ¶meters)=0 |
| Operator allowing the functor to be used as a function. More... | |
| virtual double | operator() (double x)=0 |
| Operator allowing the functor to be used as a function. More... | |
Class for defining one-dimensional functions that can be used as arguments in virtual methods.
This is needed to circumvent the issue that templates and virtual methods are incompatible.
Usage:
where myFunction is some function defined in some class MyClass with the following signature:
The pointer this needs to be replaced by a pointer to the object instantiating MyClass, if the first line is not written inside MyClass.
Now, you can pass myFunctor as argument to any method (e.g. integration routines), even virtual ones:
and use the functor as a function (with the operator()) inside this method:
See also FunctorUtils documentation.
See also Integrator1D documentation for the specific case of integration routines.
For multi-dimensional functions, see FunctionTypeMD.
|
inline |
Empty constructor.
|
inlinevirtual |
Default destructor.
|
pure virtual |
Operator allowing the functor to be used as a function.
| x | Argument of the function represented by the functor. |
Implemented in NumA::Functor1D< PointerToObj, PointerToFunc >.
|
pure virtual |
Operator allowing the functor to be used as a function.
| x | Argument of the function represented by the functor. |
| parameters | Parameters that can be passed to the function. |
Implemented in NumA::Functor1D< PointerToObj, PointerToFunc >.