在C ++中评估数学表达式的最好方法是什么? [英] What is the best way to evaluate mathematical expressions in C++?
本文介绍了在C ++中评估数学表达式的最好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
评估任何自定义数学表达式的最佳方法是什么,例如
3 + sqrt(5)+ pow 3)+ log(5)
我知道将Python嵌入C ++可以做到这一点;是否有更好的方法?
谢谢!
解决方案
Boost.Spirit 是一个C ++解析器库。
- /rosettacode.org/wiki/Arithmetic_evaluation#C.2B.2Brel =nofollow> Rosetta wiki ;
- 某些应用程式。
< spirit.com/distrib/spirit_1_8_5/libs/spirit/example/fundamental/rel =nofollow> classic 版本和 current version(查找calc);
What is the best way to evaluate any custom math expression, for example
3+sqrt(5)+pow(3)+log(5)
I know that embedding Python into C++ can do that; is there any better way?
Thanks!
解决方案
Boost.Spirit is a C++ parser library.
Examples:
- in its distribution: classic version and current version (look for "calc");
- on Rosetta wiki;
- some applications using it.
这篇关于在C ++中评估数学表达式的最好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文