C++ Mathematical Expression Library (ExprTk) https://www.partow.net/programming/exprtk/index.html

This commit is contained in:
Arash Partow 2016-10-04 10:27:29 +11:00
parent c165d4864e
commit 3bd10f1ba6
2 changed files with 31 additions and 31 deletions

View File

@ -52,11 +52,11 @@ void newton_sqrt()
" default: "
" ~{ "
" var z := 100; "
" var y := x / 2; "
" var sqrt_x := x / 2; "
" repeat "
" y := (1 / 2) * (y + (x / y)); "
" if (equal(y * y, x)) "
" break[y]; "
" sqrt_x := (1 / 2) * (sqrt_x + (x / sqrt_x)); "
" if (equal(sqrt_x^2, x)) "
" break[sqrt_x]; "
" until ((z -= 1) <= 0); "
" }; "
" } ",

View File

@ -877,8 +877,8 @@ behaviours when using the expressions in various contexts such as
muli-threading et al.
The prescribed method for cloning an expression is to compile it from
its string form. Doing so will allow the one to properly consider the
exact source of user defined variables and functions.
its string form. Doing so will allow the 'user' to properly consider
the exact source of user defined variables and functions.
Note: The exprtk::parser is a non-copyable and non-thread safe
component, and should only be shared via either a reference, a shared
@ -893,17 +893,17 @@ operations for compiling multiple expressions via the parser and
inserting the newly minted exprtk::expression instances into a
std::vector.
+--[exprtk::parser]--+
| expression factory |
+---->- compile(....) ->---+
| +--------------------+ |
Expressions | | Expressions as
in string form A V exprtk::expression
+----[exprtk::parser]---+
| Expression Factory |
| parser_t::compile(...)|
+--> ~.~.~.~.~.~.~.~.~.~ ->--+
| +-----------------------+ |
Expressions in | | Expressions as
string form A V exprtk::expression
| | instances
[s0:'x+1']------+ | | +-[e0: x+1]
[s0:'x+1']--->--+ | | +-[e0: x+1]
| | | |
[s1:'2z+y']-----+--+ +-->+-[e1: 2z+y]
[s1:'2z+y']-->--+--+ +->+-[e1: 2z+y]
| |
[s2:'sin(k+w)']-+ +-[e2: sin(k+w)]