Multidimensional arrays

First we describe a modest extension of Java that would add a class of true multi-dimensional arrays to the standard Java language. The new arrays allow regular section subscripting, similar to Fortran 90 arrays. The syntax described in this section is a subset of the Java-Ad syntax for parallel arrays and algorithms: the motivation for introducing the sequential subset first is just to simplify the overall presentation.

No attempt is made to integrate the new multidimensional arrays
with the standard Java arrays: they are a new kind of entity that
coexists in the language with ordinary Java arrays. There
are good technical reasons for keeping the two kinds of array
separate^{2}.

The type-signatures and constructors of the multidimensional array use double brackets to distinguish them from ordinary arrays:

int [[,]] a = new int [[5, 5]] ; float [[,,]] b = new float [[10, n, 20]] ; int [[]] c = new int [[100]] ;

int [] d = new int [100] ;

Accessing individual elements of a multidimensional array goes through a subscripting operation involving single brackets

for(int i = 0 ; i < 4 ; i++) a [i, i + 1] = i + c [i] ;For reasons that will become clearer in later sections, this style of subscripting is called

In general Java-Ad has no idea of Fortran-like array assignments. In

int [[,]] e = new int [[n, m]] ; ... a = e ;the assignment simply copies a handle to object referenced by

e + a Math.cos(e)are type errors.

Java-Ad *does* import a Fortran-90-like idea of array *regular
sections*. The syntax for *section subscripting* is different to
the syntax for local subscripting. Double brackets are used. These
brackets can include scalar subscripts or *subscript triplets*.

A section is an object in its own right--its type is that of a suitable
multi-dimensional array. It describes some subset of the elements of
the parent array. This is slightly different to the situation in
Fortran, where sections cannot usually be captured as named
entities^{4}.

int [[]] e = a [[2, 2 :]] ; foo(b [[ : , 0, 1 : 10 : 2]]) ;

In Java-Ad, unlike Fortran, it is not allowed to use vectors of integers as subscripts. The only sections recognized are regular sections defined through scalar and triplet subscripts.

Java-Ad provides a library of functions for manipulating its arrays, closely analogous to the array transformational intrinsic functions of Fortran 90:

int [[,]] f = new int [[5, 5]] ; Adlib.shift(f, a, -1, 0, CYCL) ; float g = Adlib.sum(b) ; int [[]] h = new int [[100]] ; Adlib.copy(h, c) ;The