MathGL have a special classes mglExpr
and mglExprC
for evaluating of formula specified by the string for real and complex numbers correspondingly. These classes are defined in #include <mgl2/data.h>
and #include <mgl2/datac.h>
correspondingly. It is the fast variant of formula evaluation. At creation it will be recognized and compiled to tree-like internal code. At evaluation stage only fast calculations are performed. There is no difference between lower or upper case in formulas. If argument value lie outside the range of function definition then function returns NaN. See Textual formulas.
mglExpr
:
mglExpr (const char *
expr)
¶mglExprC
:
mglExprC (const char *
expr)
¶HMEX
mgl_create_expr (const char *
expr)
¶HAEX
mgl_create_cexpr (const char *
expr)
¶Parses the formula expr and creates formula-tree. Constructor recursively parses the formula and creates a tree-like structure containing functions and operators for fast further evaluating by Calc()
or CalcD()
functions.
mglExpr
:
~mglExpr ()
¶mglExprC
:
~mglExprC ()
¶void
mgl_delete_expr (HMEX
ex)
¶void
mgl_delete_cexpr (HAEX
ex)
¶Deletes the instance of class mglExpr.
mglExpr
: mreal
Eval (mreal
x, mreal
y, mreal
z)
¶mglExprC
: dual
Eval (dual
x, dual
y, dual
z)
¶mreal
mgl_expr_eval (HMEX
ex, mreal
x, mreal
y, mreal
z)
¶dual
mgl_cexpr_eval (HAEX
ex, dual
x, dual
y, dual
z)
¶Evaluates the formula for 'x','r'
=x, 'y','n'
=y, 'z','t'
=z, 'a','u'
=u.
mglExpr
: mreal
Eval (mreal
var[26])
¶mglExprC
: dual
Eval (dual
var[26])
¶mreal
mgl_expr_eval_v (HMEX
ex, mreal *
var)
¶dual
mgl_expr_eval_v (HAEX
ex, dual *
var)
¶Evaluates the formula for variables in array var[0,...,’z’-’a’].