Prefer idx in place of id for functions accessing the internal variables, and add a short introduction to mention them.
Unified · Split
| @@ -801,6 +801,11 @@ The following binary operators are available: @code{+}, @code{-}, · 800 unmodified lines | |||
| 801 | 801 | ||
| 802 | The following unary operators are available: @code{+}, @code{-}. | 802 | The following unary operators are available: @code{+}, @code{-}. |
| 803 | 803 | ||
| 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 | |||
| 804 | The following functions are available: | 809 | The following functions are available: |
| 805 | @table @option | 810 | @table @option |
| 806 | @item abs(x) | 811 | @item abs(x) |
| @@ -898,9 +903,9 @@ Return 1.0 if @var{x} is +/-INFINITY, 0.0 otherwise. · 91 unmodified lines | |||
| 898 | @item isnan(x) | 903 | @item isnan(x) |
| 899 | Return 1.0 if @var{x} is NAN, 0.0 otherwise. | 904 | Return 1.0 if @var{x} is NAN, 0.0 otherwise. |
| 900 | 905 | ||
| 901 | @item ld(var) | 906 | @item ld(idx) |
| 902 | Load the value of the internal variable with number | 907 | Load the value of the internal variable with index @var{idx}, which was |
| 903 | @var{var}, which was previously stored with st(@var{var}, @var{expr}). | 908 | previously stored with st(@var{idx}, @var{expr}). |
| 904 | The function returns the loaded value. | 909 | The function returns the loaded value. |
| 905 | 910 | ||
| 906 | @item lerp(x, y, z) | 911 | @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 | |||
| 933 | 938 | ||
| 934 | @item print(t) | 939 | @item print(t) |
| 935 | @item print(t, l) | 940 | @item print(t, l) |
| 936 | Print the value of expression @var{t} with loglevel @var{l}. If | 941 | Print the value of expression @var{t} with loglevel @var{l}. If @var{l} is not |
| 937 | @var{l} is not specified then a default log level is used. | 942 | specified then a default log level is used. |
| 938 | Returns the value of the expression printed. | 943 | Return the value of the expression printed. |
| 939 | |||
| 940 | Prints t with loglevel l | ||
| 941 | 944 | ||
| 942 | @item random(idx) | 945 | @item random(idx) |
| 943 | Return a pseudo random value between 0.0 and 1.0. @var{idx} is the | 946 | 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 | 947 | index of the internal variable used to save the seed/state, which can be |
| 945 | seed/state. | 948 | previously stored with @code{st(idx)}. |
| 946 | 949 | ||
| 947 | To initialize the seed, you need to store the seed value as a 64-bit | 950 | To initialize the seed, you need to store the seed value as a 64-bit |
| 948 | unsigned integer in the internal variable with index @var{idx}. | 951 | 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 | |||
| 955 | 958 | ||
| 956 | @item randomi(idx, min, max) | 959 | @item randomi(idx, min, max) |
| 957 | Return a pseudo random value in the interval between @var{min} and | 960 | 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 | 961 | @var{max}. @var{idx} is the index of the internal variable which will be used to |
| 959 | be used to save the seed/state. | 962 | save the seed/state, which can be previously stored with @code{st(idx)}. |
| 960 | 963 | ||
| 961 | To initialize the seed, you need to store the seed value as a 64-bit | 964 | To initialize the seed, you need to store the seed value as a 64-bit |
| 962 | unsigned integer in the internal variable with index @var{idx}. | 965 | 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 | |||
| 968 | The expression in @var{expr} must denote a continuous function or the | 971 | The expression in @var{expr} must denote a continuous function or the |
| 969 | result is undefined. | 972 | result is undefined. |
| 970 | 973 | ||
| 971 | @var{ld(0)} is used to represent the function input value, which means | 974 | @var{ld(0)} is used to represent the function input value, which means that the |
| 972 | that the given expression will be evaluated multiple times with | 975 | given expression will be evaluated multiple times with various input values that |
| 973 | various input values that the expression can access through | 976 | the expression can access through @code{ld(0)}. When the expression evaluates to |
| 974 | @code{ld(0)}. When the expression evaluates to 0 then the | 977 | 0 then the corresponding input value will be returned. |
| 975 | corresponding input value will be returned. | ||
| 976 | 978 | ||
| 977 | @item round(expr) | 979 | @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". | ||
| 979 | 982 | ||
| 980 | @item sgn(x) | 983 | @item sgn(x) |
| 981 | Compute sign of @var{x}. | 984 | Compute sign of @var{x}. |
| @@ -993,12 +996,15 @@ Compute the square root of @var{expr}. This is equivalent to · 11 unmodified lines | |||
| 993 | @item squish(x) | 996 | @item squish(x) |
| 994 | Compute expression @code{1/(1 + exp(4*x))}. | 997 | Compute expression @code{1/(1 + exp(4*x))}. |
| 995 | 998 | ||
| 996 | @item st(var, expr) | 999 | @item st(idx, expr) |
| 997 | Store the value of the expression @var{expr} in an internal | 1000 | Store the value of the expression @var{expr} in an internal |
| 998 | variable. @var{var} specifies the number of the variable where to | 1001 | variable. @var{idx} specifies the index of the variable where to store |
| 999 | store the value, and it is a value ranging from 0 to 9. The function | 1002 | the value, and it is a value ranging from 0 to 9. The function returns |
| 1000 | returns the value stored in the internal variable. | 1003 | the value stored in the internal variable. |
| 1001 | Note, Variables are currently not shared between expressions. | 1004 | |
| 1005 | The stored value can be retrieved with @code{ld(var)}. | ||
| 1006 | |||
| 1007 | Note: variables are currently not shared between expressions. | ||
| 1002 | 1008 | ||
| 1003 | @item tan(x) | 1009 | @item tan(x) |
| 1004 | Compute tangent of @var{x}. | 1010 | Compute tangent of @var{x}. |
| @@ -1007,16 +1013,16 @@ Compute tangent of @var{x}. · 2 unmodified lines | |||
| 1007 | Compute hyperbolic tangent of @var{x}. | 1013 | Compute hyperbolic tangent of @var{x}. |
| 1008 | 1014 | ||
| 1009 | @item taylor(expr, x) | 1015 | @item taylor(expr, x) |
| 1010 | @item taylor(expr, x, id) | 1016 | @item taylor(expr, x, idx) |
| 1011 | Evaluate a Taylor series at @var{x}, given an expression representing | 1017 | 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. |
| 1013 | 1019 | ||
| 1014 | When the series does not converge the result is undefined. | 1020 | When the series does not converge the result is undefined. |
| 1015 | 1021 | ||
| 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}, |
| 1017 | which means that the given expression will be evaluated multiple times | 1023 | which means that the given expression will be evaluated multiple times |
| 1018 | with various input values that the expression can access through | 1024 | 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. |
| 1020 | 1026 | ||
| 1021 | Note, when you have the derivatives at y instead of 0, | 1027 | Note, when you have the derivatives at y instead of 0, |
| 1022 | @code{taylor(expr, x-y)} can be used. | 1028 | @code{taylor(expr, x-y)} can be used. |