Next: , Previous: , Up: Subscripts   [Contents][Index] Multiple Subscripts

You can use any of the different types of coordinate specifications (scalar, range, array) for any of the coordinates. If more than one multiple-element coordinate is present, then the multiple-element coordinates can be combined in two different ways: as a generalized inner product (inner-style, selected by keyword /INNER) or a generalized outer product (outer-style, selected by keyword /OUTER).

If neither of these keywords is specified, then /OUTER is assumed if none of the subscripts has more than one dimension, and /INNER otherwise.

In the outer style, all combinations of array elements (one from each multiple-element coordinate) are serviced and the dimensional structure of the coordinate arrays is copied to the result. For instance, if x is an array of four by four elements, then x([1,2,3],[0,3]) is an array of three by two elements, and the elements are (in increasing order of their index) x(1,0), x(2,0), x(3,0), x(1,3), x(2,3), x(3,3). In this particular example, the same result would have been obtained through x(1:3,[0,3]).

Redirection and summation as in range subscripts (Range Subscripts) may be applied to outer-style array subscripts. Redirection specifies how to rearrange the sets of dimensions of the subscripts, not the dimensions of the result. With redirection you can change where the dimensions of a particular subscript end up relative to the dimensions of the other subscripts, but the order of dimensions of each subscript is preserved. For example, if c1 is a 2-by-3 array and c2 a 4-element array, then z(c1, c2) is an array with dimensions 2 by 3 by 4 (the 2 by 3 coming from c1 and the 4 from c2), and z(c1:>1, c2:>0) an array with dimensions 4 by 2 by 3 (i.e., the dimensions of c1 have been moved relative to those of c2, but the dimensions of c1 are in the same relative order).

In the inner style (keyword /INNER), all multiple-element coordinates must have the same number of elements and the next element of all multiple-element coordinates is taken for each next output element. For example, with the previously defined x, x([1,2],[3,4],/INNER) is an array of two elements, equal to [x(1,3), x(2,4)]. The dimensional structure of the result is equal to the dimensional structure of the first non-scalar subscript (a range is considered equivalent to a one-dimensional array in this case).

Redirection and summation are not implemented for inner-style array subscripts, because the dimensional structure of the result is not related to the number of subscripts.

Combination subscripts can also be applied to file arrays (File Arrays) and to strings (Strings).

It is an error to specify fewer coordinate arguments than there are dimensions in the subscripted variable, except if you specify one coordinate argument (Index Subscripts) or if you specify one of the keywords /ZERO and /ALL. If you specify /ZERO, then all unspecified coordinates are assumed equal to zero. For instance, if x is an array with 3 by 2 by 5 by 3 elements, then x(2,1,/ZERO) is equivalent to x(2,1,0,0). If you specify /ALL, then all unspecified coordinates are assumed equal to *. For example, with the same x as before, x(2,1,/ALL) is equivalent to x(2,1,*,*).

Next: , Previous: , Up: Subscripts   [Contents][Index]