Use of JCP site is subject to the
JCP Terms of Use and the
Oracle Privacy Policy
|
JSRs: Java Specification Requests
JSR 83: Multiarray package
This JSR has been Withdrawn
Identification |
Request |
Contributions |
Additional Information
Title: Java Multiarray package Summary: This JSR proposes a package implementing true rectangular
multidimensional arrays for Java. Section 1. Identification
Submitting Member: International Business Machines Corporation Name of Contact Person: Jose E. Moreira E-Mail Address: jmoreira@us.ibm.com Telephone Number: 1-914-945-3987 Fax Number: 1-914-945-4425 Specification Lead: Jose E. Moreira, IBM Corporation E-Mail Address: jmoreira@us.ibm.com Telephone Number: 1-914-945-3987 Fax Number: 1-914-945-4425 Initial Expert Group Membership:
Additional endorsers of this JSR include individuals from:
Section 2: Request
2.1 Please describe the proposed Specification:TheMultiarray package provides support for
true multidimensional arrays (henceforth called multiarrays) in Java.
Multiarrays are n-dimensional rectangular collections
of elements.
A multiarray is characterized by its rank (number of dimensions
or axes), its elemental data type (all elements of a multiarray
are of the same type), and its shape (the extents along
its axes).
Elements of a multiarray are identified by their indices along each axis.
Let a d-dimensional array A of elemental type
T have extent nj along its j-th axis,
j = 0,...,d-1.
Then, a valid index ij along the j-th axis must
be greater than or equal to zero and less than nj.
An attempt to reference an element
A[i0,i1,...,id-1]
with any invalid index ij causes an
Elements of a multiarray are logically ordered with respect to each other according to the following definition. An element A[i0,i1,...,id-1] of a d-dimensional multiarray A follows an element A[j0,j1,...,jd-1] of the same multiarray if and only if there exists a k greater than or equal to zero and less than d such that il=jl for all l<k and ik>jk. In usual nomenclature, this corresponds to row-major (C-style) ordering of the elements. We call this the intrinsic ordering of the multiarray elements. (In a column-major, i.e., Fortran-style, ordering of the elements, an element A[i0,i1,...,id-1] of a d-dimensional multiarray A follows an element A[j0,j1,...,jd-1] of the same multiarray if and only if there exists a k greater than or equal to zero and less than d such that il=jl for all l>k and ik>jk. This concept will be useful when we discuss native interfaces and mapping to conventional Java arrays below.)
We propose the development of standard Java classes which
implement multiarrays.
The rank and type of a multiarray are defined by its class.
That is, for each rank and type there is a different concrete class.
Supported types must include all of Java primitive types
(
All concrete classes of the same type (e.g.,
The A dB-dimensional multiarray section B of a dA-dimensional master multiarray A is defined by specifying, for each axis k of A, either (i) a specific element index along that axis or (ii) a range of element indices. A range of indices consists of an arithmetic progression of indices, defined by its first element, the incremental step, and the number of elements. The single index or the range of indices serve as a selector of the elements of A that are present in section B. The number of axes of A for which a single index is specified is equal to the rank difference between A and B, dA - dB. The shape of B is defined by the length (number of elements) in the range selectors.
In addition to regular multiarray sections, the The multiarray classes provide methods that implement Fortran-like functionality for arrays. In particular, the following operations must be provided:
doubleArray2D and double[][] .
The conversion operations create new copies of the data to prevent
exposing the internal structure of the multiarray classes.
The multiarray package also needs to provide ravel and
unravel methods that copy data between multiarray objects
and Java one-dimensional arrays of the same type. For the
purpose of copying data to and from one-dimensional arrays,
the logical ordering of elements of a multiarray (defined above)
is used. It may make sense to provide additional variants of
ravel/unravel, in which the ordering of the elements is
explicitly specified (e.g., supporting column major
operation). Finally, it remains to be investigated how
ravel/unravel operations could be optimized to avoid copying
data.
Quite often, Java code using the Array package will have to interface
with native code. Although native code can use the JNI procedure
for accessing elements of a multiarray through the doubleMultiarray2D A = new doubleMuliarray2D(m,n); ... double[] B = A.unravel(); foo(B); A.ravel(B);
Access to individual elements of multiarrays is performed
only through void matmul(doubleArray2D a, doubleArray2D b, doubleArray2D c) { /* * For simplicity, let us consider only the simple case * in which the matrices are conforming, that is, * a is m x n, b is n x p, and c is m x p. */ int m = a.size(0); int n = a.size(1); int p = b.size(1); for (int i=0; i<m; i++) { for (int j=0; j<p; j++) { c.set(i,j,0); for (int k=0; k<n; k++) c.set(i,j,c.get(i,j)+a.get(i,k)*b.get(k,j)); } } }
The multiarray classes can be implemented with no changes to Java, the JVM, or to the JNI.
However, it is essential that the 2.2 What is the target Java platform? (i.e., desktop, server, personal, embedded, card, etc.)
The 2.3 What need of the Java community will be addressed by the proposed specification?
Multidimensional arrays are the most common data
structures in scientific and engineering computing.
The Java 2.4 Why isn't this need met by existing specifications?
Native Java arrays are strictly one-dimensional. Multidimensional arrays
are simulated as "arrays of arrays". That means, for example,
that each element of a
The 2.5 Please give a short description of the underlying technology or technologies:Implementing multidimensional arrays as classes has been done before in the context of A++/P++ and POOMA. The mechanisms for mapping a multidimensional cartesian space into a single-dimensional address space are well understood. The main challenge is performance.
A good implementation of the To deliver good performance on user codes that perform elementary operations on multiarray elements, two compiler technologies are of utmost importance:
2.6 Is there a proposed package name for the API Specification? (i.e., javapi.something, org.something, etc.)javax.math.multiarray 2.7 Does the proposed specification have any dependencies on specific operating systems, CPUs, or I/O devices that you know of?
No.
A strawman implementation of the 2.8 Are there any security issues that cannot be addressed by the current security model?No. 2.9 Are there any internationalization or localization issues?No. 2.10 Are there any existing specifications that might be rendered obsolete, deprecated, or in need of revision as a result of this work?
No other existing specifications are affected by this specification.
The functionality of classes The recent proposal to extend generic types to Java could provide a more general solution for building multidimensional arrays of user-defined types. 2.11 Please describe the anticipated schedule for the development of this specification.
Section 3: Contributions
3.1 Please list any existing documents, specifications, or implementations that describe the technology. Please include links to the documents if they are publicly available.
A strawman for the Array package is available as package
A prototype research compiler that performs the optimizations of semantic expansion and bounds checking optimization has been implemented at IBM Research.
Two technical reports describing the design of the strawman
3.2 Explanation of how these items might be used as a starting point for the work.
The strawman implementation for the |