History

doc/utils/eval: review and extend, clarify ld/st index meaning

Prefer idx in place of id for functions accessing the internal variables, and add a short introduction to mention them.

Stefano Sabatini committed 2 years ago

Commit b2bc4ac1 parent 8ceb37d1 file · +33 −27Browse files

Unified · Split

doc/utils.texi+33−27
@@ -801,6 +801,11 @@ The following binary operators are available: @code{+}, @code{-}, · 800 unmodified lines
801801
802802 The following unary operators are available: @code{+}, @code{-}.
803803
804+Some internal variables can be used to store and load intermediary
805+results. They can be accessed using the @code{ld} and @code{st}
806+functions with an index argument varying from 0 to 9 to specify which
807+internal variable to access.
808+
804809 The following functions are available:
805810 @table @option
806811 @item abs(x)
@@ -898,9 +903,9 @@ Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. · 91 unmodified lines
898903 @item isnan(x)
899904 Return 1.0 if @var{x} is NAN, 0.0 otherwise.
900905
901−@item ld(var)
902−Load the value of the internal variable with number
903−@var{var}, which was previously stored with st(@var{var}, @var{expr}).
906+@item ld(idx)
907+Load the value of the internal variable with index @var{idx}, which was
908+previously stored with st(@var{idx}, @var{expr}).
904909 The function returns the loaded value.
905910
906911 @item lerp(x, y, z)
@@ -933,16 +938,14 @@ Compute the power of @var{x} elevated @var{y}, it is equivalent to · 26 unmodified lines
933938
934939 @item print(t)
935940 @item print(t, l)
936−Print the value of expression @var{t} with loglevel @var{l}. If
937−@var{l} is not specified then a default log level is used.
938−Returns the value of the expression printed.
939−
940−Prints t with loglevel l
941+Print the value of expression @var{t} with loglevel @var{l}. If @var{l} is not
942+specified then a default log level is used.
943+Return the value of the expression printed.
941944
942945 @item random(idx)
943946 Return a pseudo random value between 0.0 and 1.0. @var{idx} is the
944−index of the internal variable which will be used to save the
945−seed/state.
947+index of the internal variable used to save the seed/state, which can be
948+previously stored with @code{st(idx)}.
946949
947950 To initialize the seed, you need to store the seed value as a 64-bit
948951 unsigned integer in the internal variable with index @var{idx}.
@@ -955,8 +958,8 @@ st(0,42); print(random(0)); print(random(0)); print(random(0)) · 6 unmodified lines
955958
956959 @item randomi(idx, min, max)
957960 Return a pseudo random value in the interval between @var{min} and
958−@var{max}. @var{idx} is the index of the internal variable which will
959−be used to save the seed/state.
961+@var{max}. @var{idx} is the index of the internal variable which will be used to
962+save the seed/state, which can be previously stored with @code{st(idx)}.
960963
961964 To initialize the seed, you need to store the seed value as a 64-bit
962965 unsigned integer in the internal variable with index @var{idx}.
@@ -968,14 +971,14 @@ with argument @var{ld(0)} is 0 in the interval 0..@var{max}. · 5 unmodified lines
968971 The expression in @var{expr} must denote a continuous function or the
969972 result is undefined.
970973
971−@var{ld(0)} is used to represent the function input value, which means
972−that the given expression will be evaluated multiple times with
973−various input values that the expression can access through
974−@code{ld(0)}. When the expression evaluates to 0 then the
975−corresponding input value will be returned.
974+@var{ld(0)} is used to represent the function input value, which means that the
975+given expression will be evaluated multiple times with various input values that
976+the expression can access through @code{ld(0)}. When the expression evaluates to
977+0 then the corresponding input value will be returned.
976978
977979 @item round(expr)
978−Round the value of expression @var{expr} to the nearest integer. For example, "round(1.5)" is "2.0".
980+Round the value of expression @var{expr} to the nearest integer. For example,
981+"round(1.5)" is "2.0".
979982
980983 @item sgn(x)
981984 Compute sign of @var{x}.
@@ -993,12 +996,15 @@ Compute the square root of @var{expr}. This is equivalent to · 11 unmodified lines
993996 @item squish(x)
994997 Compute expression @code{1/(1 + exp(4*x))}.
995998
996−@item st(var, expr)
999+@item st(idx, expr)
9971000 Store the value of the expression @var{expr} in an internal
998−variable. @var{var} specifies the number of the variable where to
999−store the value, and it is a value ranging from 0 to 9. The function
1000−returns the value stored in the internal variable.
1001−Note, Variables are currently not shared between expressions.
1001+variable. @var{idx} specifies the index of the variable where to store
1002+the value, and it is a value ranging from 0 to 9. The function returns
1003+the value stored in the internal variable.
1004+
1005+The stored value can be retrieved with @code{ld(var)}.
1006+
1007+Note: variables are currently not shared between expressions.
10021008
10031009 @item tan(x)
10041010 Compute tangent of @var{x}.
@@ -1007,16 +1013,16 @@ Compute tangent of @var{x}. · 2 unmodified lines
10071013 Compute hyperbolic tangent of @var{x}.
10081014
10091015 @item taylor(expr, x)
1010−@item taylor(expr, x, id)
1016+@item taylor(expr, x, idx)
10111017 Evaluate a Taylor series at @var{x}, given an expression representing
1012−the @code{ld(id)}-th derivative of a function at 0.
1018+the @code{ld(idx)}-th derivative of a function at 0.
10131019
10141020 When the series does not converge the result is undefined.
10151021
1016−@var{ld(id)} is used to represent the derivative order in @var{expr},
1022+@var{ld(idx)} is used to represent the derivative order in @var{expr},
10171023 which means that the given expression will be evaluated multiple times
10181024 with various input values that the expression can access through
1019−@code{ld(id)}. If @var{id} is not specified then 0 is assumed.
1025+@code{ld(idx)}. If @var{idx} is not specified then 0 is assumed.
10201026
10211027 Note, when you have the derivatives at y instead of 0,
10221028 @code{taylor(expr, x-y)} can be used.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t