All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Algebraic Function Evaluation

The FunctionParser library (http://warp.povusers.org/FunctionParser/) is used in O2scl to provide evaluation of functions specified as strings. The source code for this library is included in the O2scl distribution and automatically compiled and installed with O2scl .

The most basic usage is

// Parse the function 'x+y-1' with variables 'x' and 'y'
int ret = fp.Parse("x+y-1", "x,y");
double vals[] = { 4, 8 };
// Replace 'x' with 4, 'y' with 8, and evaluate
std::cout << fp.Eval(vals) << std::endl;

This will print out the result, 11 to std::cout.

Constants may also be provided, which are replaced with numerical values in future formulas to be evaluated.

fp.AddConstant("a",1);
int ret = fp.Parse("x+y-a", "x,y");
double vals[] = { 4, 8 };
std::cout << fp.Eval(vals) << std::endl;

This example will also print 11 to std::cout.

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).
Hosted at Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads..