Click here to Skip to main content
11,573,618 members (62,372 online)
Click here to Skip to main content

Tagged as

A powerful function parser

, 22 Feb 2000 123.7K 1.9K 58
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

    Share

    About the Author

    Andreas Jäger
    Web Developer
    Germany Germany
    No Biography provided

    You may also be interested in...

    Comments and Discussions

     
    GeneralMFC compile Pin
    Luke Murphey6-Jul-02 9:28
    memberLuke Murphey6-Jul-02 9:28 
    GeneralRe: MFC compile Pin
    lLukeMurphey8-Jul-02 6:56
    memberlLukeMurphey8-Jul-02 6:56 
    GeneralA version without MFC / MS dependencies Pin
    JochenKa14-Feb-02 20:23
    memberJochenKa14-Feb-02 20:23 
    GeneralRe: A version without MFC / MS dependencies Pin
    jean-luc adam19-Feb-02 1:50
    memberjean-luc adam19-Feb-02 1:50 
    GeneralRe: A version without MFC / MS dependencies Pin
    Jochen Kalmbach29-Jan-04 19:31
    memberJochen Kalmbach29-Jan-04 19:31 
    GeneralRe: A version without MFC / MS dependencies Pin
    Philippe Lhoste4-Dec-04 2:25
    memberPhilippe Lhoste4-Dec-04 2:25 
    GeneralRe: A version without MFC / MS dependencies Pin
    Jochen Kalmbach [MVP VC++]1-Jan-06 19:58
    memberJochen Kalmbach [MVP VC++]1-Jan-06 19:58 
    GeneralRe: A version without MFC / MS dependencies Pin
    Member 190613125-Jul-13 13:18
    memberMember 190613125-Jul-13 13:18 
    Generalmore General expression Pin
    Jie Luo16-Jan-02 1:56
    memberJie Luo16-Jan-02 1:56 
    GeneralWorld peace Pin
    Bartosz Bien14-Dec-01 13:14
    memberBartosz Bien14-Dec-01 13:14 

    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 | Terms of Use | Mobile
    Web04 | 2.8.150624.2 | Last Updated 23 Feb 2000
    Article Copyright 2000 by Andreas Jäger
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid