C++ Mathematical Expression Toolkit (ExprTk) release
Loading...
Searching...
No Matches
Functions
exprtk_simple_example_06.cpp File Reference
#include <cstdio>
#include <string>
#include "exprtk.hpp"
Include dependency graph for exprtk_simple_example_06.cpp:

Go to the source code of this file.

Functions

template<typename T >
void vector_function ()
 
int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 57 of file exprtk_simple_example_06.cpp.

58{
59 vector_function<double>();
60 return 0;
61}

◆ vector_function()

template<typename T >
void vector_function ( )

Definition at line 27 of file exprtk_simple_example_06.cpp.

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}
bool compile(const std::string &expression_string, expression< T > &expr)
Definition exprtk.hpp:24443

References exprtk::parser< T >::compile().

Here is the call graph for this function: