Click here to Skip to main content
Click here to Skip to main content

A powerful function parser

, 22 Feb 2000
Rate this:
Please Sign up or sign in to vote.
A simple yet powerful function parser that parses and evaluates standard mathematical functions
  • Download source files - 82 Kb
  • 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<long double>* fkt = CFunction<long double>::Parse("cos(x)-7*x/(1+x)");
    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.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Andreas Jäger
    Web Developer
    Germany Germany
    No Biography provided

    Comments and Discussions

     
    GeneralBugs etc below should be renamed to Dean Wyant knows little about programming. PinmemberB. Starks13-Apr-01 7:36 
    GeneralRe: Bugs etc below should be renamed to Dean Wyant knows little about programming. PinmemberDean Wyant30-Apr-04 10:11 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web01 | 2.8.140709.1 | Last Updated 23 Feb 2000
    Article Copyright 2000 by Andreas Jäger
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid