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

Function vector_function

exprtk_simple_example_06.cpp:27–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <typename T>
27void vector_function()
28{
29 typedef exprtk::symbol_table<T> symbol_table_t;
30 typedef exprtk::expression<T> expression_t;
31 typedef exprtk::parser<T> parser_t;
32
33 const std::string expression_string =
34 " for (var i := 0; i < min(x[], y[], z[]); i += 1) "
35 " { "
36 " z[i] := 3sin(x[i]) + 2log(y[i]); "
37 " } ";
38
39 T x[] = { T(1.1), T(2.2), T(3.3), T(4.4), T(5.5) };
40 T y[] = { T(1.1), T(2.2), T(3.3), T(4.4), T(5.5) };
41 T z[] = { T(0.0), T(0.0), T(0.0), T(0.0), T(0.0) };
42
43 symbol_table_t symbol_table;
44 symbol_table.add_vector("x",x);
45 symbol_table.add_vector("y",y);
46 symbol_table.add_vector("z",z);
47
48 expression_t expression;
49 expression.register_symbol_table(symbol_table);
50
51 parser_t parser;
52 parser.compile(expression_string,expression);
53
54 expression.value();
55}
56
57int main()
58{

Callers

nothing calls this directly

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected