C++ Mathematical Expression Library (ExprTk) http://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow
2015-04-28 16:50:54 +10:00
parent e39ec67df9
commit 85c094a1aa
6 changed files with 364 additions and 221 deletions

View File

@ -29,6 +29,7 @@ void newton_sqrt()
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
typedef exprtk::function_compositor<T> compositor_t;
typedef typename compositor_t::function function_t;
T x = T(0);
@ -40,7 +41,9 @@ void newton_sqrt()
compositor_t compositor(symbol_table);
compositor
.add("newton_sqrt",
.add(
function_t(
"newton_sqrt",
" switch "
" { "
" case x < 0 : -inf; "
@ -57,7 +60,7 @@ void newton_sqrt()
" until ((z -= 1) <= 0); "
" }; "
" } ",
"x");
"x"));
std::string expression_str = "newton_sqrt(x)";