next up previous
Next: Inquiry fields and functions Up: Global variables Previous: Data descriptor and global

Array sections and type signatures.

HPJava allows to construct sections of global arrays. The syntax of section subscripting uses double brackets. The subscripts can be scalar (integers or locations) or triplets.

Suppose we still have array a and c defined as above, then, a[[i]], c, c[[i, 1::2]], and c[[i, :]] are all array sections. Here i is a location in the first range of a and c (it could also be an integer in the appropriate interval). Both the expressions c[[i, 1::2]] and c[[i, :]] represent one-dimensional distributed arrays, providing aliases for subsets of the elements in c. The expression a[[i]] contains a single element of a, but the result is a global scalar reference (unlike the expression a[i] which is a simple variable).

Array section expressions are often used as arguments in function calls2. Table 1 shows the type signatures of global data with different dimensions.

Table 1: Section expression and type signature
global var array section type
2-dimension c
c[[:,:]] float [[,]]
1-dimension c[[i,:]]
c[[i,1::2]] float [[ ]]
scalar(0-dim) c[[i,j]] float #


In the table, both i and j are location references.


next up previous
Next: Inquiry fields and functions Up: Global variables Previous: Data descriptor and global
Bryan Carpenter 2002-07-11