This function is useful where it is necessary to select entries from a vector that is not an explicit variable.
Example:
selectBooleans({true, false, true}, {1,3})
returns
{true, true}
. An alternative to this function is to assign a variable to the full vector
(full = {true, false, true}
) and extract from that variable (full[{1,3}]). However, this
is not valid in Modelica: {true, false, true}[{1,3}]
.
function selectBooleans extends Modelica.Icons.Function; input Boolean full[:] "Original vector"; input Integer indices[:](each min = 1) "Selected indices"; output Boolean reduced[size(indices, 1)] "Reduced vector"; end selectBooleans;