You are here

Built-in functions : size function

size function

size(S)

size(S,I)

The size() function is used to get a component's dimensions. It is used when two components should have the same dimensions without being connected by an influence or role arrow. In cases where you need the dimensions as values for arithmetic, e.g., calculating the mean of an array of values, the count() function should be used instead, although size() works in this role for the sake of legacy models.

The first form takes the name S of a fixed-membership submodel or an array-valued primitive component, and returns the number of instances or members that it has in each parent instance, with a value for each dimension if there are multiple dimensions. The second form takes the name of a multi-dimensional fixed-membership submodel or array primitive component, and returns the size of the Ith dimension.

The usual use of size() is in the dimensions of another fixed membership submodel, or as the second argument of the makearray() function in an equation, to produce a submodel or array with the same dimensions as the source component. In the case of a submodel whose size is the dimensions of another submodel, it also creates an extra role for an influence running between the two submodels in which the value it supplies is just that from the member of the remote submodel whose index along the shared dimension(s) is the same as that or those in the instance of the destination submodel where the equation is being evaluated. See pairing in fixed membership submodels for details.

Input: submodel name

Result: integer

In: Contents >> Working with equations >> Functions >> Built-in functions