Jump to content


- - - - -

Looking for a library


7 replies to this topic

#1 TheNut

    Senior Member

  • Moderators
  • 1473 posts
  • LocationThornhill, ON

Posted 04 April 2008 - 03:46 AM

Does anyone know of a free c++ library that takes a formula as a string and returns the result as a float/double? It would be nice if it supports complex mathematics such as calculus and whatnot, but at bare minimum I need something that can parse and calculate basic math and trigonometry.

It's primarily used for a graphing application I'm working on.

Thanks.
http://www.nutty.ca - Being a nut has its advantages.

#2 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 04 April 2008 - 03:55 AM

I use GNU bc from time to time. It's a command line utility as opposed to a library, but it would do the trick. Also, what about executing the strings as Lua code?
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 04 April 2008 - 04:27 AM

In the event you can't find a library that works for you, it wouldn't be very hard at all to build a parser using antlr or bison that would do the job (including evaluating expressions).
reedbeta.com - developer blog, OpenGL demos, and other projects

#4 martinsm

    Member

  • Members
  • PipPip
  • 88 posts

Posted 04 April 2008 - 06:49 AM

Here's some links:
http://muparser.sourceforge.net/
http://www.codeproje...MathParser.aspx

#5 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 04 April 2008 - 08:18 AM

http://smallcode.weblogs.us/

Scroll down a bit and you'll find a expression evaluator code with variables and dynamic code generation.

Nils
My music: http://myspace.com/planetarchh <-- my music

My stuff: torus.untergrund.net <-- some diy electronic stuff and more.

#6 TheNut

    Senior Member

  • Moderators
  • 1473 posts
  • LocationThornhill, ON

Posted 04 April 2008 - 11:30 AM

Thanks, these are all good. I'll spend some time tonight going through each one and checking them out.
http://www.nutty.ca - Being a nut has its advantages.

#7 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 04 April 2008 - 08:05 PM

Let us know which one you'll use :-)

Nils
My music: http://myspace.com/planetarchh <-- my music

My stuff: torus.untergrund.net <-- some diy electronic stuff and more.

#8 SmokingRope

    Valued Member

  • Members
  • PipPipPip
  • 210 posts

Posted 05 April 2008 - 02:24 AM

One of the first few chapters in The C++ Programming Language covers the basics of writing a symbolic calculator yourself (without grammars, parser tables, etc... ).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users