What is a fast C or Objective-C math parser? [closed]
Asked Answered
P

4

8

I've looked around quite a bit for a fast math parser in either C or Objective-C Almost all of the libraries I saw are written in C++, and I don't really want to go through the hassle of getting that to compile. Can anyone make a recommendation?

Palenque answered 3/2, 2011 at 21:52 Comment(2)
Try TinyExpr. It's in a single C source code file and header.Bookplate
Just want to second TinyExpr. Super easy to use.Enfeoff
C
6

I haven’t used them myself, but you could try GCMathParser and DDMathParser.

Conchology answered 3/2, 2011 at 21:57 Comment(4)
+1 for DDMathParser! hoorah! (Although if you're going for raw speed, it's nearly impossible to beat GCMathParser)Rozamond
@Dave: I knew about Graham's parser, but I'd somehow missed yours. Fascinating structure with the use of blocks. It seems like the use of NSNumber, with frequent generation of autoreleased instances, might slow things down a bit. It looks like it might be possible to use simple floating point types for the calculations, which might be much faster.Queenie
@Brad yeah, there's a lot that could be done to optimize it; my goal was extension and readability, not necessarily efficiency. :) Also, it's using NSDecimal for calculations (so much more precision than a floating point type).Rozamond
Although this is an extremely old post, may I ask if there is a math parser in that can deal with complex numbers?Decontrol
K
5

There won't be any hassle with the compiling, ObjC can work side by side with any C++ class. Search for ObjC++ here, its really pretty easy (its basically just renaming everything from *.m to *.mm)

Kendrickkendricks answered 3/2, 2011 at 21:55 Comment(0)
M
3

See my ae library (which uses Lua) and libmatheval.

Monodic answered 3/2, 2011 at 23:37 Comment(1)
Um... it's tagged "Objective-C" and "iPhone"...Rozamond
T
0

There is a Code Project where this problem was addressed. Note this is for C++ -- sorry just saw that you're looking for C / Objective-C. As it builds a library, you could write a simple interface and expose it to C. There's a really succinct explanation here of how to go about doing this.

Tourmaline answered 28/6, 2011 at 5:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.