OpenSouce C/C++ Math expression parser Library [closed]
I'm searching for a good open source Math Library which can do things like:
- Parse math. expressions "1+1*(3/5)"
- Integration
Does anybody know something like this?
There's also GNU libmatheval, which does evaluation and differentiation. Integration is a much harder problem, even for innocent-looking integrands.
Octave can do this and can be called from within a C++ program. You can even call C++ code from octave easily using SWIG to generate the interface.
I've always used muParser, written in C++, for parsing. You're not going to get a library which can do integration; simply too difficult without a serious heavyweight library. Open source symbolic integrators like Maxima, Octave, etc. exist, but they are hard to interface with, and that functionality can't easily be separated from the rest of the project.
Try my ae library, which is based on Lua. See also Evaluating Mathematical Expressions using Lua
Another approach is to embed an interpreted language in your app and use that langauge's maths parser.
LUA is becoming popular for this - see How to embed lua in c++ via SWIG
I had a similar programing need where I used the Shunting yard algorithm. Useful for parsing infix notation like you have.
There's MathPresso library which is parser and also JIT compiler of math expressions, I use it when the performance is important.
Some tests: evaluating expression "x / y + (x * x * y + 18.243 * y) / z" - where the variables are double precision floating point numbers.
- C++ function: 144.1 millions of evaluations per second
- MathPresso: 133.8 millions of evaluations per second
精彩评论