next up previous
Next: Data descriptor Up: Global variables Previous: Global array

Array section and type signature

HPJava provides array section of global arrays. The syntax of section subscripting is similar to array definition, a double bracket is used. The subscripts can be locations or ranges.

Suppose we still have

  Range x = new BlockRange(100, p.dim(0)) ;  
  Range y = new CyclicRange(100, p.dim(1)) ;
  float [[#]] b = new float [[x]];
  float [[#,#]] c = new float [[x, y]];

then, c, c[[i, y|1::2]], c[[i, z]] and b[[i]] are all array sections. Here i is a location in the first range of b and c, and z is a subrange of the second range of c.

Expression c[[i, y|1::2]] and c[[i, z]] represent a one-dimensional distributed array, providing an alias for a subset of elements of c. Expression b[[i]] contains a single element of b, yet the result is a global scalar reference, not a simple variable.

When section is made in a collapsed dimension, a triplet expression instead of a range reference is used directly. For example, if we have,

  float [[ ]] a = new float [[100]];

then a[[:98:2]] is a strided array section.

In HPJava, array section expression will be used as arguments in member function calls. As in any programming language, only the dummy argument and actual argument have the same type signature, the function call can be completed. Table 1 shows the type relations of global data with different dimensions.

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

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

When used in method calls, # marked type is a super-type of the one without the symbol. i.e. an argument of float[[,]], float[[#,]] and float[[,#]] type can all be passed to a dummy of type float[[#,#]]. But it is not true vise versa.

next up previous
Next: Data descriptor Up: Global variables Previous: Global array
Bryan Carpenter 2002-07-12