Array Programming Article Index for
Array
Website Links For
Array
 

Information About

Array Programming




APL , designed by Ken Iverson , was the first Programming Language to provide array programming capabilities.

The fundamental idea behind array programming is that operations apply at once to an entire set of values. This makes it a High-level Programming model as it allows the programmer to think and operate on whole aggregates of data, without having to resort to explicit loops of individual scalar operations.

Array programming primitives concisely express broad ideas about data manipulation. The level of conciseness can be dramatic in certain cases: it is not uncommon to find array programming language One-liners that require more than a couple of pages of Java code.

Array programming is very well suited to implicit parallelization; a topic of much research nowadays.

operation is an example of a vector rank function because it operates on vectors, not scalars. Matrix Multiplication is an example of a 2-rank function, because it operates on 2-dimensional objects (matrices). Collapse Operators reduce the dimensionality of an input data array by one or more dimensions. For example, summing over elements collapses the input array by 1 dimension.


OVERVIEW

In scalar languages like FORTRAN 77, C, Pascal, Ada, etc. operations apply only to single values, so ''a''+''b'' expresses the addition of two numbers. In such languages adding two arrays requires indexing and looping:

FORTRAN 77
DO 10 I = 1, N
DO 10 J = 1, N
10 A(I,J) = A(I,J) + B(I,J)

C
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
a = a[i + b[i [j];
}
}

This need to loop and index to perform operations on arrays is both tedious and error prone.

In array languages, operations are generalized to apply to both scalars and arrays. Thus, ''a''+''b'' expresses the sum of two scalars if ''a'' and ''b'' are scalars, or the sum of two arrays if they are arrays. When applied to arrays, the operations act on corresponding elements as illustrated in the loops above. Indeed, when the array language compiler/interpreter encounters a statement like:

A := A + B

where ''A'' and ''B'' are two-dimensional arrays, it generates code that is effectively the same as the C loops shown above. An array language, therefore, simplifies programming.


EXAMPLE LANGUAGES

The canonical examples of array programming languages are , A+ , IDL , Mathematica , MATLAB , PDL , and ZPL .

provides an exhaustive list.


SEE ALSO



EXTERNAL LINKS