diff --git a/doc/userdoc.org b/doc/userdoc.org index d356b4df2ac60b8f592d3008746a21b8ce9eb020..1eaa03f39e54ff95f6d0ed0371f188bfb2f3c7ff 100644 --- a/doc/userdoc.org +++ b/doc/userdoc.org @@ -712,7 +712,7 @@ The interpreter gives type to some special expressions. | ~\r~ | carriage return | | ~\t~ | horizontal tab | | ~\v~ | vertical tab | - These special character are not interpreted by ~pugs~ itself but + These special characters are not interpreted by ~pugs~ itself but interpreted by the system when an output is created. They are just allowed in the definition of a ~string~. @@ -830,43 +830,43 @@ lists are sorted by type of left hand side variable. - ~B~: boolean left hand side variable. One is only allowed to affect boolean values. - | allowed expression type | - |-------------------------| - | ~B~ | + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | - ~N~: natural integer ($\mathbb{N}$ or $\mathbb{Z}_{\ge0}$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ (for convenience) | + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | + | ~N~ | + | ~Z~ (for convenience) | - ~Z~: integer ($\mathbb{Z}$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | - ~R~: real ($\mathbb{R}$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | - | ~R~ | + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | - ~R^1~: vector of dimension 1 ($\mathbb{R}^1$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | - | ~R~ | - | ~R^1~ | + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + | ~R^1~ | - ~R^2~: vector of dimension 2 ($\mathbb{R}^2$) left hand side variable. - | allowed expression type | + | ~=~ allowed expression type | |---------------------------------------------| | ~R^2~ | | ~0~ (special value) | @@ -891,9 +891,9 @@ lists are sorted by type of left hand side variable. #+results: R2-invalid-integer-affectation - ~R^3~: vector of dimension 3 ($\mathbb{R}^3$) left hand side variable. - | allowed expression type | + | ~=~ allowed expression type | |---------------------------------------------| - | ~R^3~ | + | ~R^3~ | | ~0~ (special value) | | list of 3 scalar (~B~, ~N~, ~Z~ or ~R~) expressions | An example of initialization using a list is @@ -907,17 +907,17 @@ lists are sorted by type of left hand side variable. the output is #+RESULTS: affectation-to-R3-from-list -- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^1\times1$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | - | ~R~ | - | ~R^1x1~ | - -- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^2x2$) left hand side variable. - | allowed expression type | +- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^{1\times1}$) left hand side variable. + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + | ~R^1x1~ | + +- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^{2\times2}$) left hand side variable. + | ~=~ allowed expression type | |---------------------------------------------| | ~R^2x2~ | | ~0~ (special value) | @@ -934,8 +934,8 @@ lists are sorted by type of left hand side variable. which produces #+RESULTS: affectation-to-R2x2-from-list -- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^3x3$) left hand side variable. - | allowed expression type | +- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^{3\times3}$) left hand side variable. + | ~=~ allowed expression type | |---------------------------------------------| | ~R^3x3~ | | ~0~ (special value) | @@ -955,19 +955,19 @@ lists are sorted by type of left hand side variable. - ~string~ left hand side variable. Expressions of any basic types can be used as the right hand side. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | - | ~R~ | - | ~R^1~ | - | ~R^2~ | - | ~R^3~ | - | ~R^1x1~ | - | ~R^2x2~ | - | ~R^3x3~ | - | ~string~ | + | ~=~ allowed expression type | + |---------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + | ~R^1~ | + | ~R^2~ | + | ~R^3~ | + | ~R^1x1~ | + | ~R^2x2~ | + | ~R^3x3~ | + | ~string~ | ***** List of defined operator ~+=~ for basic types. @@ -975,85 +975,289 @@ lists are sorted by type of left hand side variable. variables. - ~N~: natural integer ($\mathbb{N}$ or $\mathbb{Z}_{\ge0}$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ (for convenience) | + | ~+=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ (for convenience) | - ~Z~: integer ($\mathbb{Z}$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | + | ~+=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | - ~R~: real ($\mathbb{R}$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | - | ~R~ | + | ~+=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | - ~R^1~: vector of dimension 1 ($\mathbb{R}^1$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~R^1~ | + | ~+=~ allowed expression type | + |----------------------------| + | ~R^1~ | - ~R^2~: vector of dimension 2 ($\mathbb{R}^2$) left hand side variable. - | allowed expression type | - |---------------------------------------------| - | ~R^2~ | + | ~+=~ allowed expression type | + |----------------------------| + | ~R^2~ | - ~R^3~: vector of dimension 3 ($\mathbb{R}^3$) left hand side variable. - | allowed expression type | - |---------------------------------------------| - | ~R^3~ | + | ~+=~ allowed expression type | + |----------------------------| + | ~R^3~ | -- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^1\times1$) left hand side variable. - | allowed expression type | - |-------------------------| - | ~R^1x1~ | +- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^{1\times1}$) left hand side variable. + | ~+=~ allowed expression type | + |----------------------------| + | ~R^1x1~ | -- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^2x2$) left hand side variable. - | allowed expression type | - |---------------------------------------------| - | ~R^2x2~ | +- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^{2\times2}$) left hand side variable. + | ~+=~ allowed expression type | + |----------------------------| + | ~R^2x2~ | -- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^3x3$) left hand side variable. - | allowed expression type | - |---------------------------------------------| - | ~R^3x3~ | +- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^{3\times3}$) left hand side variable. + | ~+=~ allowed expression type | + |----------------------------| + | ~R^3x3~ | - ~string~ left hand side variable. Expressions of any basic types can be used as the right hand side. - | allowed expression type | - |-------------------------| - | ~B~ | - | ~N~ | - | ~Z~ | - | ~R~ | - | ~R^1~ | - | ~R^2~ | - | ~R^3~ | - | ~R^1x1~ | - | ~R^2x2~ | - | ~R^3x3~ | - | ~string~ | - -***** TODO List of defined operator ~-=~ for basic types. + | ~+=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + | ~R^1~ | + | ~R^2~ | + | ~R^3~ | + | ~R^1x1~ | + | ~R^2x2~ | + | ~R^3x3~ | + | ~string~ | + +***** List of defined operator ~-=~ for basic types. - ~B~: the ~-=~ operator is not defined for left hand side boolean variables. -***** TODO List of defined operator ~*=~ for basic types. +- ~N~: natural integer ($\mathbb{N}$ or $\mathbb{Z}_{\ge0}$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ (for convenience) | + +- ~Z~: integer ($\mathbb{Z}$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + +- ~R~: real ($\mathbb{R}$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^1~: vector of dimension 1 ($\mathbb{R}^1$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~R^1~ | + +- ~R^2~: vector of dimension 2 ($\mathbb{R}^2$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~R^2~ | + +- ~R^3~: vector of dimension 3 ($\mathbb{R}^3$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~R^3~ | + +- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^{1\times1}$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~R^1x1~ | + +- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^{2\times2}$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~R^2x2~ | + +- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^{3\times3}$) left hand side variable. + | ~-=~ allowed expression type | + |----------------------------| + | ~R^3x3~ | + +- ~string~: the ~-=~ operator is not defined for left hand side string variables. + +***** List of defined operator ~*=~ for basic types. - ~B~: the ~*=~ operator is not defined for left hand side boolean variables. -***** TODO List of defined operator ~/=~ for basic types. +- ~N~: natural integer ($\mathbb{N}$ or $\mathbb{Z}_{\ge0}$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ (for convenience) | + +- ~Z~: integer ($\mathbb{Z}$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + +- ~R~: real ($\mathbb{R}$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^1~: vector of dimension 1 ($\mathbb{R}^1$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^2~: vector of dimension 2 ($\mathbb{R}^2$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^3~: vector of dimension 3 ($\mathbb{R}^3$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^{1\times1}$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^{2\times2}$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^{3\times3}$) left hand side variable. + | ~*=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +#+BEGIN_note +Observe that for these small matrix types ($\mathbb{R}^{d\times d}$) the +construction ~A *= B;~ is not allowed. The main reason for that is that +for $d>1$ this operation has no interests since it requires a +temporary. One will see bellow that one can write ~A = A*B;~ if needed. +#+END_note + +- ~string~: the ~*=~ operator is not defined for left hand side string variables. + +***** List of defined operator ~/=~ for basic types. - ~B~: the ~/=~ operator is not defined for left hand side boolean variables. +- ~N~: natural integer ($\mathbb{N}$ or $\mathbb{Z}_{\ge0}$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ (for convenience) | + +- ~Z~: integer ($\mathbb{Z}$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + +- ~R~: real ($\mathbb{R}$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^1~: vector of dimension 1 ($\mathbb{R}^1$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^2~: vector of dimension 2 ($\mathbb{R}^2$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^3~: vector of dimension 3 ($\mathbb{R}^3$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^1x1~: matrix of dimensions $1\times1$ ($\mathbb{R}^{1\times1}$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^2x2~: matrix of dimension $2\times2$ ($\mathbb{R}^{2\times2}$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + +- ~R^3x3~: matrix of dimension $3\times3$ ($\mathbb{R}^{3\times3}$) left hand side variable. + | ~/=~ allowed expression type | + |----------------------------| + | ~B~ | + | ~N~ | + | ~Z~ | + | ~R~ | + + **** Unary operators The ~pugs~ language allows the following tokens as unary operators