PARTONS/NumA++  
Numerical Analysis C++ routines
Public Member Functions | List of all members
NumA::FunctionType1D Class Referenceabstract

Class for defining one-dimensional functions that can be used as arguments in virtual methods. More...

Inheritance diagram for NumA::FunctionType1D:
NumA::Functor1D< PointerToObj, PointerToFunc >

Public Member Functions

 FunctionType1D ()
 Empty constructor. More...
 
virtual ~FunctionType1D ()
 Default destructor. More...
 
virtual double operator() (double x, std::vector< double > &parameters)=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...
 

Detailed Description

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:

&MyClass::myFunction);
Class for defining one-dimensional functions that can be used as arguments in virtual methods.
Definition: FunctionType1D.h:50
static Functor1D< PointerToObj, PointerToMemFn > * newFunctor1D(PointerToObj *object, PointerToMemFn function)
Defines a new functor with the given one-dimensional function.
Definition: FunctorUtils.h:35

where myFunction is some function defined in some class MyClass with the following signature:

double MyClass::myFunction(double variable, std::vector<double>& parameters);

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:

virtual SomeReturnType someVirtualMethod(..., NumA::FunctionType1D* functor, ...);

and use the functor as a function (with the operator()) inside this method:

functor(variable, parameters); // parameters is optional.

See also FunctorUtils documentation.

See also Integrator1D documentation for the specific case of integration routines.

For multi-dimensional functions, see FunctionTypeMD.

Constructor & Destructor Documentation

◆ FunctionType1D()

NumA::FunctionType1D::FunctionType1D ( )
inline

Empty constructor.

◆ ~FunctionType1D()

virtual NumA::FunctionType1D::~FunctionType1D ( )
inlinevirtual

Default destructor.

Member Function Documentation

◆ operator()() [1/2]

virtual double NumA::FunctionType1D::operator() ( double  x)
pure virtual

Operator allowing the functor to be used as a function.

Parameters
xArgument of the function represented by the functor.
Returns
double

Implemented in NumA::Functor1D< PointerToObj, PointerToFunc >.

◆ operator()() [2/2]

virtual double NumA::FunctionType1D::operator() ( double  x,
std::vector< double > &  parameters 
)
pure virtual

Operator allowing the functor to be used as a function.

Parameters
xArgument of the function represented by the functor.
parametersParameters that can be passed to the function.
Returns
double

Implemented in NumA::Functor1D< PointerToObj, PointerToFunc >.


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