latest version v1.9 - last update 10 Apr 2010 |
functionGenerator parses input strings representing mathematical functions of the type and . More...
#include <ltiFunctionGenerator.h>
Classes | |
class | parameters |
The parameters for the class functionGenerator. More... | |
Public Member Functions | |
functionGenerator () | |
functionGenerator (const parameters &par) | |
functionGenerator (const functionGenerator &other) | |
virtual | ~functionGenerator () |
virtual const char * | getTypeName () const |
virtual bool | updateParameters () |
bool | apply (const double &x, const double &y, double &result) const |
bool | apply (const double &x, double &result) const |
functionGenerator & | copy (const functionGenerator &other) |
functionGenerator & | operator= (const functionGenerator &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
functionGenerator parses input strings representing mathematical functions of the type and .
These strings are converted into a tree structure which allows the retrieval of the functions' result for passed arguments. The calculation is performed in the apply-methods. The string is set in the parameters of this class like in this example:
#include "ltiFunctionGenerator.h" lti::functionGenerator function; lti::functionGenerator::parameters params; params.function = "(x-1)*cos(y)/x^2+1.234"; if (!function.setParameters(params)) { // something went wrong during parsing, get the error message std::cout << function.getStatusString(); } else { // calculate the result for two arguments double result; if (!function.apply(2.5,3.1,result)) { std::cout << "Function is not defined for given arguments"; } }
Conventions for string input:
lti::functionGenerator::functionGenerator | ( | ) |
Default constructor.
lti::functionGenerator::functionGenerator | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::functionGenerator::functionGenerator | ( | const functionGenerator & | other | ) |
Copy constructor.
other | the object to be copied |
virtual lti::functionGenerator::~functionGenerator | ( | ) | [virtual] |
Destructor.
bool lti::functionGenerator::apply | ( | const double & | x, | |
double & | result | |||
) | const |
operates on a copy of the given parameters.
x | argument | |
result | result of evaluation. 1.0 in case of errors |
bool lti::functionGenerator::apply | ( | const double & | x, | |
const double & | y, | |||
double & | result | |||
) | const |
operates on a copy of the given parameters.
x | first argument | |
y | second argument | |
result | result of evaluation. 1.0 in case of errors |
virtual functor* lti::functionGenerator::clone | ( | ) | const [virtual] |
Returns a pointer to a clone of this functor.
Reimplemented from lti::mathFunction.
functionGenerator& lti::functionGenerator::copy | ( | const functionGenerator & | other | ) |
Copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::mathFunction.
const parameters& lti::functionGenerator::getParameters | ( | ) | const |
Returns used parameters.
Reimplemented from lti::mathFunction.
virtual const char* lti::functionGenerator::getTypeName | ( | ) | const [virtual] |
Returns the name of this type ("functionGenerator").
Reimplemented from lti::mathFunction.
functionGenerator& lti::functionGenerator::operator= | ( | const functionGenerator & | other | ) |
Alias for copy member.
other | the functor to be copied |
Reimplemented from lti::mathFunction.
virtual bool lti::functionGenerator::updateParameters | ( | ) | [virtual] |
Updates the internal state after parameter change.
Here, the function string is parsed and the tree is build.
Reimplemented from lti::functor.