MultiArrays implements a base type Array for constructing arrays of arbitrary dimensions and of arbitrary element types together with an associated SizeVector defining the length of the dimensions. Array elements can be accessed in various ways:

- using an indexing mechanism provided by an IndexN procedure computing the linear index from the coordinates of an element. Access to the elements is slowest.
- in a linear fashion along the data elements organized in a linear sequence. Access to the elements is fast.
- using an "All..." procedure operating on all the elements. This dispenses the user from programming index manipulation in the source code and access to the elements is very fast.
- using array riders movable along arbitrary dimensions. This functionality is provided in the module MultiArrayRiders.
- by reading runs of data with the help of a rider. This functionality is provided in the module MultiArrayRiders.

Maintainer: Patrick Hunziker

In the Oberon programming language, an array is a data type that represents a set of elements that are all of the same type - the element type. In a multidimensional array, each index spans a dimension in a Cartesian space.

In the context of MultiArrays, an array is defined by a pair of POINTERs consisting of the base type

Array = POINTER TO ArrayDesc;and a size vector

SizeVector = POINTER TO SizeVectorDesc;Both are abstract data types containing no data. The array elements forming the data can be of any type, including extensions of Objects.Object defined in ETH Oberon. The module MultiArrays offers a base type

SInt = POINTER TO SIntDesc; SIntDesc = RECORD (ScalarDesc) s*: SHORTINT END;Before an array of type ARRAY is instantiated, its dimensions with their respective lengths must be instantiated as vector with:

PROCEDURE SizeVector1 (VAR Vec: SizeVector; x: LONGINT); PROCEDURE SizeVector2 (VAR Vec: SizeVector; x, y: LONGINT); PROCEDURE SizeVector3 (VAR Vec: SizeVector; x, y, z: LONGINT); PROCEDURE SizeVector4 (VAR Vec: SizeVector; x, y, z, u: LONGINT);where

An array of *SInt* elements is instantiated with the procedure:

PROCEDURE InitSInt (VAR A: Array; dimension: SizeVector; data: SIntPtr; copy: BOOLEAN);If

For an existing array:

PROCEDURE Size (A: Array): SizeVector; returns dimension vector PROCEDURE Order (A: Array): LONGINT; returns the number of dimensions PROCEDURE Len (A: Array; dim: LONGINT): LONGINT; returns length of the dimensionThe value of an

PROCEDURE GetSInt (A: Array; position: SizeVector): SHORTINT;where

An array *From* is copied to an array *To* with:

PROCEDURE Copy (From, To: Array);All the

PROCEDURE AllSInt1 (A: Array; f: PROCEDURE (s: SHORTINT): SHORTINT);All the

PROCEDURE AllSInt2 (A, B: Array; f: PROCEDURE (s1, s2: SHORTINT): SHORTINT);Four other such

The data of an array is organized as a linear sequence of elements each having an index which can be inferred from the position vector

PROCEDURE Index (pos, dimension: ARRAY OF LONGINT): LONGINT;Conversely, the position vector can be calculated from the index with:

PROCEDURE CalculatePos (Index: LONGINT; dimension: ARRAY OF LONGINT): SizeVector;The index in the linear sequence of elements can be computed from the coordinates of an element using one of the procedures:

PROCEDURE Index1 (A: Array; x: LONGINT): LONGINT; PROCEDURE Index2 (A: Array; x, y: LONGINT): LONGINT; PROCEDURE Index3 (A: Array; x, y, z: LONGINT): LONGINT; PROCEDURE Index4 (A: Array; x, y, z, u: LONGINT): LONGINT;depending on the number of dimensions. If need be, additional

2. Use Watson to obtain a list of available functions.

3. For each module a Test procedure demonstrates the efficiency of the algorithms compared to the conventional array indexing scheme. These procedures can also be used as examples.

21 Jan 2001 - Copyright © 2000 ETH Zürich. All rights reserved.

E-Mail: oberon@inf.ethz.ch

Homepage: http://www.ethoberon.ethz.ch/