Free Source Code and Program Tips
A powerful math function parser(zz)
by Andreas Jdger
The inspiration to write this code was to have an easy-to-use parser for functions given as string. You have a string like
cos(x)-7*x/(1+x)
and you want to compute some values, maybe for displaying the graph of the function. You can write code like this:
CFunction
CFunction
long double y = fkt->Execute(1.5);
There are lots of definitions in the background, but the result is easy and fast! There is a one-time pasing step to construct the function tree, and function evaluations are only calls of standard math functions like sin, +, *, sqrt. When you want to know details about the implementaion, you should look into the source code. It would be too complex to describe the parsing algorithm here.
Download here:
Download demo source
Download demo app
| Print article | This entry was posted by hamo on November 29, 2006 at 8:12 am, and is filed under Win32/MFC. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |