Revision as of 23:21, 19 January 2016 by Bbecane (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

AddIndex(a, I)

Returns an array after adding one or more indexes to «a». The new array is constant (does not vary) along the added indexes.

It is seldom necessary to add indexes to arrays like this in your own models, since a general philosophy in Analytica models is that as index is not necessary if the data does not vary along that index. Array abstraction will automatically add in indexes when in needs two when arrays of differing dimensionality are combined, so adding in indexes is not something you should need to worry about during the course of normal model building. We sometimes refer to these indexes as vacuous, since they are present but the result doesn't vary across them. There are, however, cases where adding an index like this is desired. These sometimes arise when coding meta-inference algorithms.

This built-in function is equivalent to the User-Defined Function:

Function AddIndex(a: All[I]; I: ...Index) := a

In builds prior to Analytica 4.6 you can create this UDF yourself if you need this function.




AddIndex(1, I, J) → 2-D array indexed by I and J and having 1 in every cell.
AddIndex(@I, J) →
I ▶
J ▼ 'item 1' 'item 2' 'item 3'
1 1 2 3
2 1 2 3
3 1 2 3
4 1 2 3

The next two examples demonstrate how you can add a computed set of indexes to an array. The computed set is in the form of a list of handles

Var L := ListOfHandles(I, J, K) Do AddIndex(a, Repeated Parameter Forwarding|...L)

This one ensures that the result contains the data from b and contains all the indexes of a



AddIndex was introduced in 'Analytica 4.6.

See Also


You are not allowed to post comments.