Next: String Functions
Up: Utility Functions
Previous: Transformation Functions
GRAPE contains a simple but easy to use function interpreter.
Once you have a function string (e.g. "x*x+sqrt(y)-z*t") you have to
precompile it to a t_fun, providing the variable names. This
t_fun can be executed fast enough for most purposes.
The interpreter only knows about scalar double values, it recognizes
the operators and functions +, -, *, /, ^, (), arccos,
arcsin, arctan, cos, cosh, exp, log,
sin, sinh, sqrt, tan, tanh and the constant
pi.
- t_fun *fn_func (char * in, char *
varnames)
Precompile the function in. The variable names have to
be in order ans space separated in varnames, e.g. "x y z
t". In case of an error NULL is returned; use fn_errstr
and fn_errpos for diagnostics.
- t_fun *fn_delete (t_fun * fn)
Free the
compiled code, return NULL.
- double fn_eval (t_fun * fn, double *
vars)
Evaluate the compiled function code fn. vars has to
contain the variable values in order, e.g.
vars[0]=x,vars[1]=y,vars[2]=z,vars[3]=g_maintime. The result
value is returned.
- char *fn_errstr ()
Return an error message in
case fn_eval returned NULL.
- char *fn_errpos ()
Return the error position
in the function string in case fn_eval returned NULL.
SFB 256 Universität Bonn and IAM Universität Freiburg Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik,
Universität Bonn.