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

This commit is contained in:
Arash Partow
2015-03-28 23:21:55 +11:00
parent 73b1e4c9f3
commit 53b2977902
8 changed files with 3861 additions and 2838 deletions

View File

@ -37,13 +37,17 @@ struct myfunc : public exprtk::ifunction<T>
template <typename T>
void custom_function()
{
typedef exprtk::expression<T> expression_t;
typedef exprtk::symbol_table<T> symbol_table_t;
typedef exprtk::expression<T> expression_t;
typedef exprtk::parser<T> parser_t;
std::string expression_string = "myfunc(sin(x * pi),y / 2)";
T x = T(1);
T y = T(2);
myfunc<T> mf;
exprtk::symbol_table<T> symbol_table;
symbol_table_t symbol_table;
symbol_table.add_variable("x",x);
symbol_table.add_variable("y",y);
symbol_table.add_function("myfunc",mf);
@ -52,7 +56,7 @@ void custom_function()
expression_t expression;
expression.register_symbol_table(symbol_table);
exprtk::parser<T> parser;
parser_t parser;
parser.compile(expression_string,expression);
T result = expression.value();