PARP Research Group Universidad de Murcia


QVFunction< Input, Output > Class Template Reference
[Numerical analisis and function minimization]

Base class for function objects. More...

#include <QVFunction>

List of all members.

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.

Detailed Description

template<typename Input, typename Output>
class QVFunction< Input, Output >

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.


Member Function Documentation

template<typename Input, typename Output>
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.

Parameters:
input Input value provided for its evaluation.

Referenced by QVFunction< QVVector, QVMatrix >::map(), QVFunction< QVVector, QVMatrix >::operator()(), and QVUKF::update().

template<typename Input, typename Output>
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.

Parameters:
input Input value provided for its evaluation.
See also:
evaluate

Definition at line 102 of file qvfunction.h.

template<typename Input, typename Output>
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.

Parameters:
input List of input values provided for their evaluation
See also:
map

Definition at line 111 of file qvfunction.h.

template<typename Input, typename Output>
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.

Parameters:
input List of input values provided for their evaluation
Returns:
A list containing the outputs of the function for the values contained in the inputs list. This function preserves the order of the outputs, regarding the order of their corresponding inputs at the input list.
See also:
evaluate

Definition at line 121 of file qvfunction.h.

Referenced by QVFunction< QVVector, QVMatrix >::operator()().


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



QVision framework. PARP research group. Copyright © 2007, 2008, 2009, 2010, 2011.