next up previous contents index
Next: Partial Scans. Up: Expressions and Operators Previous: Logical Negation

Reductions and Scans

 

   

ZPL provides a set of reduction and scan operators which can be applied to parallel expressions. A complete reduction reduces a parallel expression to a sequential one, while a partial reduction reduces the dimension of a parallel expression. For example, the maximum reduction ( max tex2html_wrap_inline2299 ) of a parallel array expression evaluates to the value of the largest element of the array expression, as shown below.

[R] s := max<< A;             -- assign to s the largest value in A
The syntax of the reduction, scan and flood operators (these last two are described below), has been chosen to reflect the effect on the rank of the resulting expression. The reduction operators produce lower dimensional expressions, the scan does not change the rank of the expression, and the flood produces higher dimensional expressions.

The scan operators compute the parallel prefix of a parallel expression. Each element is the reduction of the values that precede it. The order of ``precedes'' is, by default, row major order. The order can be defined by the user by specifying the order of the dimensions as optional parameters. For example, the following performs a scan in the opposite order from the default.

    A := +|| [-2][-1] A;      -- compute parallel prefix in reverse order





Kay Nettle
Fri Feb 21 21:14:29 CST 1997