PARP Research Group | Universidad de Murcia |
QVFunction< Input, Output > Class Template Reference
|
Public Member Functions | |
virtual Output | evaluate (const Input &input)=0 |
Virtual method implementing the code for the function evaluation. | |
Output | operator() (const Input &input) |
Operator to evaluate the function. | |
QList< Output > | operator() (const QList< Input > &input) |
Function map operator. | |
QList< Output > | map (const QList< Input > &inputs) |
Maps a list of input elements, to the outputs for those elements. |
Base class for function objects.
This class can be used to create function class types. Objects derived from this class will wrap functions so they can be provided as parameters to other methods or procedures.
These objects can be used as any C++ function, using their overloaded function operator (). This operator calls to the virtual method evaluate, which must be implemented by subclasses of QVFunction to contain the code of the function:
[...] class FactorialFunction: public QVFunction<int, int> { public: int evaluate(const int &value) { int accum = 1; for (int i = 0; i < value; i++) accum *= i; return accum; } }; [...] int main() { [...] FactorialFunction factorial; std::cout << "10! = " << factorial(10) << std::endl; [...] }
Function objects can contain parametrization data to evaluate the function, besides each given input value:
class QuadraticFunction: public QVFunction<double, double> { private: const double a, b, c; public: QuadraticFunction(const double a, const double b, const double c): QVFunction<double, double>(), a(a), b(b), c(c) { } double evaluate(const double &x) { return a*x*x + b*x + c; } };
Definition at line 82 of file qvfunction.h.
virtual Output QVFunction< Input, Output >::evaluate | ( | const Input & | input | ) | [pure virtual] |
Virtual method implementing the code for the function evaluation.
This virtual method must be redefined at any QVFunction subclass. It should implement the code for the function evaluation.
input | Input value provided for its evaluation. |
Referenced by QVFunction< QVVector, QVMatrix >::map(), QVFunction< QVVector, QVMatrix >::operator()(), and QVUKF::update().
Output QVFunction< Input, Output >::operator() | ( | const Input & | input | ) | [inline] |
Operator to evaluate the function.
This operator calls to the evaluate method, to obtain the return value of the function.
input | Input value provided for its evaluation. |
Definition at line 102 of file qvfunction.h.
QList<Output> QVFunction< Input, Output >::operator() | ( | const QList< Input > & | input | ) | [inline] |
Function map operator.
This operator maps a list of inputs, to their corresponding outputs.
input | List of input values provided for their evaluation |
Definition at line 111 of file qvfunction.h.
QList<Output> QVFunction< Input, Output >::map | ( | const QList< Input > & | inputs | ) | [inline] |
Maps a list of input elements, to the outputs for those elements.
This operator calls the evaluate method for each element of the input list.
input | List of input values provided for their evaluation |
Definition at line 121 of file qvfunction.h.
Referenced by QVFunction< QVVector, QVMatrix >::operator()().