One of the most interesting features of multiarrays is the possiblity of forming a section of a multiarray. This is an idea that will be familiar to Fortran programmers. A section (of some parent multiarray) is a multiarray in its own right whose elements are a subset of the elements of the parent. In other words it is a subarray.
A section expression is a generalized subscripting operation,
in which the subscripts may select some range of the allowed indexes
of the parent multiarray. A range of indices is represented by a term
call a triplet. In HPJava a triplet
has one of three forms:
The subscripts of a multiarray section expression can be any mixture of
triplet subscripts and
scalar subscripts1.4. A scalar subscript is in an ordinary
integer expression, just like the subscript in an array element
reference. Double brackets rear their head again, mainly to make
the distinction between sections and element references very clear.
Here are some examples--we assume a is a rank-2 multiarray:
A section is a normal expression in the HPJava language, and it
can appear anywhere in an HPJava program that any other kind of
multiarray-valued expression can appear. It is particularly common
to see multiarray sections appearing as argument to methods.
So, for example, this statement:
The elements of an array section are variables; they are aliases
(alternative names) for the elements of the parent array...if
you modify an element of the section, then the corresponding
element of the parent array is also changed.
Note, however, that the array section expression is not
itself a variable: an array section expression cannot appear on
the left-hand-side of an assignment. So this: