OpcUaCanOpen
CANopen OPC-UA server
exprtk_simple_example_03.cpp
Go to the documentation of this file.
1
/*
2
**************************************************************
3
* C++ Mathematical Expression Toolkit Library *
4
* *
5
* Simple Example 3 *
6
* Author: Arash Partow (1999-2019) *
7
* URL: http://www.partow.net/programming/exprtk/index.html *
8
* *
9
* Copyright notice: *
10
* Free use of the Mathematical Expression Toolkit Library is *
11
* permitted under the guidelines and in accordance with the *
12
* most current version of the MIT License. *
13
* http://www.opensource.org/licenses/MIT *
14
* *
15
**************************************************************
16
*/
17
18
19
#include <cstdio>
20
#include <string>
21
22
#include "
exprtk.hpp
"
23
24
25
template
<
typename
T>
26
void
polynomial
()
27
{
28
typedef
exprtk::symbol_table<T>
symbol_table_t
;
29
typedef
exprtk::expression<T>
expression_t
;
30
typedef
exprtk::parser<T>
parser_t
;
31
32
std::string
expression_string =
"25x^5 - 35x^4 - 15x^3 + 40x^2 - 15x + 1"
;
33
34
const
T r0 = T(0);
35
const
T r1 = T(1);
36
T
x
= T(0);
37
38
symbol_table_t
symbol_table;
39
symbol_table.
add_variable
(
"x"
,
x
);
40
41
expression_t
expression;
42
expression.
register_symbol_table
(symbol_table);
43
44
parser_t
parser
;
45
parser
.compile(expression_string,expression);
46
47
const
T delta = T(1.0 / 100.0);
48
49
for
(
x
= r0;
x
<= r1;
x
+= delta)
50
{
51
printf(
"%19.15f\t%19.15f\n"
,
x
,expression.value());
52
}
53
}
54
55
int
main
()
56
{
57
polynomial<double>();
58
return
0;
59
}
exprtk
exprtk_simple_example_03.cpp
Generated on Fri Sep 11 2020 14:30:03 for OpcUaCanOpen by
1.8.14