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

Function stddev_example

exprtk_simple_example_14.cpp:27–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26template <typename T>
27void stddev_example()
28{
29 typedef exprtk::expression<T> expression_t;
30 typedef exprtk::parser<T> parser_t;
31
32 const std::string stddev_program =
33 " var x[25] := { "
34 " 1, 2, 3, 4, 5, "
35 " 6, 7, 8, 9, 10, "
36 " 11, 12, 13, 14, 15, "
37 " 16, 17, 18, 19, 20, "
38 " 21, 22, 23, 24, 25 "
39 " }; "
40 " "
41 " sqrt(sum([x - avg(x)]^2) / x[]) ";
42
43 expression_t expression;
44
45 parser_t parser;
46 parser.compile(stddev_program,expression);
47
48 const T stddev = expression.value();
49
50 printf("stddev(1..25) = %10.6f\n",stddev);
51}
52
53int main()
54{

Callers

nothing calls this directly

Calls 1

valueMethod · 0.45

Tested by

no test coverage detected