As mentioned before, Java is an attractive programming language
for various reasons. But it needs to be improved for
solving large computational tasks. One of the critical Java and JVM
issues is the lack of true multidimensional arrays
like those in Fortran, which are arguably the most important data
structures for scientific and engineering computing.
Java does not directly provide arrays with rank greater than
. Instead, Java represents multidimensional arrays as ``array of
arrays.'' The disadvantages of Java multidimensional arrays result from
the time consumption for out-of-bounds checking, the ability to alias
rows of an array, and the cost of accessing an element. In contrast,
accessing an element in Fortran 90 is straightforward and
efficient. Moreover, an array section can be implemented
efficiently.
HPJava supports a true multidimensional array, called a multiarray,
which is a modest extension to the standard Java language. The new
arrays allow regular section subscripting, similar to Fortran 90
arrays. The syntax for the HPJava multiarray is a subset of the syntax
introduced later for distributed arrays.
The type signature and constructor of the multiarray has double
brackets to tell them from ordinary Java arrays.
a, b, c are respectively a 2-dimensional integer
array, 3-dimensional double array, and 1-dimensional int
array. The rank is determined by the number of asterisks in the type
signature. The shape of a multiarray is rectangular. Moreover,
c is similar in structure to the
standard array d. But, c and d are not
identical. For instance, c allows section subscripting, but
d does not. The value d would not be assignable to
c, or vice versa.
Access to individual elements of a multiarray is represented by a
subscripting operation involving single brackets, for example,
e becomes an alias for the 3rd row of elements of a.
The procedure foo should expect a two-dimensional array as
argument. It can read or write to the set of elements of b
selected by the section.
The shorthand : selects the whole of the index range, as in
Fortran 90.