This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: libevaluator library and GSL
Aleksandar B. Samardzic wrote:
I'm only speaking for myself here: I'd like to have some of this
functionality available,
Me too. But I don't care whether it's a seperate library or not.
Aleksandar: great initiative.
Could you tell us more about what your evaluator does? How does it
compute derivatives? Symbolically or numerically? Does it simplify
formulas? Does it look for common subexpressions?
I wrote a similar library about 10 years ago. Derivatives are not too
difficult to implement, but the expressions become really ugly. Try to
derive sin(x)^cos(x) w.r.t. x to see what I mean :-).
Simplifying expressions is a much harder job. Of course you can do
simple things like (x-x) -> 0 and (1*x) -> x but (x+y)-x is not that easy.
My library is parsing string and creating tree representation of it in
memory.
Tree representation is straight forward but might not be the most
efficient representation. At least in the 1980's and 1990's I believe
that most compilers used DAGs (Directed Acyclic Graphs). The Dragon book
by Aho et al. outlines the algorithms.
It would be certainly possible to implement back-end generating C code
from tree representation of function.
Easy using recursion. But C suddently comes very Lisp like: lots of
irritating parenthesis.
Kneth
--
Kenneth Geisshirt, M.Sc., Ph.D. http://kenneth.geisshirt.dk
Grøndals Parkvej 2A, 3. sal kenneth@geisshirt.dk
DK-2720 Vanløse +45 38 87 78 38