Often when performing operations across multiple tables you face the situation where the tables have different dimensions. The functions in this section allow you to tell Planarly how to handle these situations by applying properties to the tables in a formula. These table properties are used to:
Many operators and functions require their arguments to have the same dimensions, e.g. +
Three functions, Tile
, Inflate
, and Extend
, are provided so that a table's dimensions become modifiable, shrinking or expanding as required by the context. Below is an example where Tile()
is used to expand the smaller #a
table to match the dimensions of #b
, and then Tile()
is used to constrain the dimensions of #b
to the smaller dimensions of #a
.
<aside>
💡 One special exemption: constants are treated as if wrapped in a call to Tile()
:
</aside>
But computed results are not treated in this way as they are represented as 1x1 tables.
Expands a
to the required dimension by tiling, i.e. repeating. E.g. Ones(3,3) + 1 & 2
is an error, but Ones(3,3) + Tile(1 & 2)
evaluates to 2 & 3 & 2 \\\\ 2 & 3 & 2 \\\\ 2 & 3 & 2
.
$$ \begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} + \textrm{Tile}( \begin{bmatrix} 1 & 2 \end{bmatrix}) = \begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} + \begin{bmatrix} 1 & 2 & 1 \\ 1 & 2 & 1 \\ 1 & 2 & 1 \end{bmatrix} = \begin{bmatrix} 2 & 3 & 2 \\ 2 & 3 & 2 \\ 2 & 3 & 2 \end{bmatrix} $$
Extend the input to the required dimension by repeating the bottom row and right-most column. E.g.Ones(3,3) + Extend(1 & 2)
evaluates to 2 & 3 & 3 \\\\ 2 & 3 & 3 \\\\ 2 & 3 & 3
.
$$ \begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} + \textrm{Extend}( \begin{bmatrix} 1 & 2 \end{bmatrix}) = \begin{bmatrix} 1 & 1 & 1 \\ 1 & 1 & 1 \\ 1 & 1 & 1 \end{bmatrix} + \begin{bmatrix} 1 & 2 & 2 \\ 1 & 2 & 2 \\ 1 & 2 & 2 \end{bmatrix} = \begin{bmatrix} 2 & 3 & 3 \\ 2 & 3 & 3 \\ 2 & 3 & 3 \end{bmatrix} $$
Expand the input to the required dimension by padding with Blank
.
E.g. Ones(3,3) + Inflate(1 & 2)
evaluates to 2 & 3 & 1 \\\\ 1 & 1 & 1 \\\\ 1 & 1 & 1
.