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

Function trig_function

exprtk_simple_example_01.cpp:27–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <typename T>
27void trig_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 "clamp(-1.0, sin(2 * pi * x) + cos(x / 2 * pi), +1.0)";
35
36 T x;
37
38 symbol_table_t symbol_table;
39 symbol_table.add_variable("x",x);
40 symbol_table.add_constants();
41
42 expression_t expression;
43 expression.register_symbol_table(symbol_table);
44
45 parser_t parser;
46 parser.compile(expression_string,expression);
47
48 for (x = T(-5); x <= T(+5); x += T(0.001))
49 {
50 const T y = expression.value();
51 printf("%19.15f\t%19.15f\n", x, y);
52 }
53}
54
55int main()
56{

Callers

nothing calls this directly

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected