NFcore::FuncFactory Class Reference

#include <NFfunction.hh>

List of all members.


Detailed Description

Parses mathmatical functions that can be easily used anywhere.

Built from the muParser freeware package, this factory creates Parser objects that can be used to evaluate arbitrary functions. The function to evaluate is given as a string (which can contain the given functions or constants below, case sensitive) along with pointers to particular varables that exist. The Parser, when initialized, translates the string into bytecode that can be evaluated fast. At runtime, the bytecode that was created can be evaluated and every time it is evaluated, it uses the current value of the given pointers to variables. Thus, NFsim can use functions of arbitrary complexity for defining reaction rates and parameters.

Supported functions:
name&nbsp&nbspn_args&nbsp&nbspdescription
sin1sine function (arg is in radians)
cos1cosine function
tan1tangens function
asin1arcus sine function
acos1arcus cosine function
atan1arcus tangens function
sinh1hyperbolic sine function
cosh1hyperbolic cosine
tanh1hyperbolic tangens function
asinh1hyperbolic arcus sine function
acosh1hyperbolic arcus tangens function
atanh1hyperbolic arcur tangens function
log21logarithm to the base 2
log101logarithm to the base 10
log1logarithm to the base 10
ln1logarithm to base e (2.71828...)
exp1e raised to the power of x
sqrt1square root of a value
sign1sign function -1 if x<0; 1 if x>0
rint1round to nearest integer
abs1absolute value
if3if ... then ... else ...
minvar.min of all arguments
maxvar.max of all arguments
sumvar.sum of all arguments
avgvar.mean value of all arguments

Supported constants (to a precision of at least 10^-8):
name&nbsp&nbspvalue&nbsp&nbspdescription
_PI3.141...you all know pi, right?
_e2.718...the base of natural logs
_Na6.022...e23Avogadro's number

For muParser documentation, see: http://muparser.sourceforge.net/

Static Public Member Functions

static mu::Parser * create (string function, vector< string > &variableNames, vector< double * > &variablePtrs)
static mu::Parser * create ()
static double Eval (mu::Parser *p)
static void test ()


Member Function Documentation

Parser * FuncFactory::create ( string  function,
vector< string > &  variableNames,
vector< double * > &  variablePtrs 
) [static]

Use this function to create a new function parser that can operate on the given variables. The vectors should contain (in the same order) the variable names and pointers to the actual variable values. Do not use local variables or variables that will be forgotten before the Parser is destroyed. To evaluate functions, you can either just call the Eval() function of the Parser object (as in p->Eval()), or, call the Eval function of FuncFactory to do error checking (as in FuncFactory::Eval(p)).

Parser * FuncFactory::create (  )  [static]

Creates a function without any variables and without any functions defined. You will have to do that yourself. But, this does add in any predefined constants we want, and that is why this function exists.

double FuncFactory::Eval ( mu::Parser *  p  )  [static]

Evaluates the given Parser object safely, meaning exceptions and errors are caught and program execution is terminated - if you have to do better than simple program termination, well than you can catch your own errors (see the muParser documenation).

void FuncFactory::test (  )  [static]

Runs a couple tests of the FuncFactory and the muParser functions to make sure everything is working as promised. (To run this, use the arguements '-test mathFuncParser')


The documentation for this class was generated from the following files:
Generated on Thu Dec 9 11:02:48 2010 for NFsim by  doxygen 1.5.4