MCPcopy Create free account
hub / github.com/ArashPartow/exprtk / custom_function

Function custom_function

exprtk_simple_example_05.cpp:48–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47template <typename T>
48void custom_function()
49{
50 typedef exprtk::symbol_table<T> symbol_table_t;
51 typedef exprtk::expression<T> expression_t;
52 typedef exprtk::parser<T> parser_t;
53
54 const std::string expression_string =
55 "myfunc(sin(x / pi), otherfunc(3 * y, x / 2, x * y))";
56
57 T x = T(1);
58 T y = T(2);
59 myfunc<T> mf;
60
61 symbol_table_t symbol_table;
62 symbol_table.add_variable("x",x);
63 symbol_table.add_variable("y",y);
64 symbol_table.add_function("myfunc",mf);
65 symbol_table.add_function("otherfunc",myotherfunc);
66 symbol_table.add_constants();
67
68 expression_t expression;
69 expression.register_symbol_table(symbol_table);
70
71 parser_t parser;
72 parser.compile(expression_string,expression);
73
74 const T result = expression.value();
75 printf("Result: %10.5f\n",result);
76}
77
78int main()
79{

Callers

nothing calls this directly

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected