开发者

OpenSouce C/C++ Math expression parser Library [closed]

As it currently stands, this question is not a good fit for our Q&A format. 开发者_如何学PythonWe expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜