Next: Array Prefix and Up: Library Procedures Previous: Array Reduction Functions

Array Combining Scatter Functions

These are all generalized array reduction functions in which completely general, but nonoverlapping, subsets of array elements can be combined. There is a corresponding scatter function for each of the twelve reduction operation in the language. The way the elements of the source array are associated with the elements of the result is described in this section; the method of combining their values is described in the specifications of the individual functions in Section .

These functions all have the form XXX_SCATTER(ARRAY, BASE, INDX1, ..., INDXn, MASK) The allowed values of XXX are ALL, ANY, COPY, COUNT, IALL, IANY, IPARITY, MAXVAL, MINVAL, PARITY, PRODUCT, and SUM. The number of INDX arguments must equal the rank of BASE. Except for COUNT_SCATTER, ARRAY and BASE are arrays of the same type. For COUNT_SCATTER, ARRAY is of type logical and BASE is of type integer. The argument MASK is logical, and the INDX arrays are integer. ARRAY, MASK, and all the INDX arrays are conformable. MASK is optional. (For ALL_SCATTER, ANY_SCATTER, COUNT_SCATTER,and PARITY_SCATTER, the ARRAY must be logical. These functions do not have an optional MASK argument. To conform with the conventions of the F90 standard, the required ARRAY argument to these functions is called MASK in their specifications in Section .) The result has the same type, kind type parameter, and shape as BASE.

For every element index.html in ARRAY there is a corresponding element in each of the INDX arrays. Let index.html be the value of the element of INDX1 that is indexed by the same subscripts as element index.html of ARRAY. More generally, for each index.html, let index.html be the value of the element of INDXj that corresponds to element index.html in ARRAY, where index.html is the rank of BASE. The integers index.html, form a subscript selecting an element of BASE: BASE(index.html).

Thus the INDX arrays establish a mapping from all the elements of ARRAY onto selected elements of BASE. Viewed in the other direction, this mapping associates with each element index.html of BASE a set index.html of elements from ARRAY.

Because BASE and the result are conformable, for each element of BASE there is a corresponding element of the result.

If index.html is empty, then the element of the result corresponding to the element index.html of BASE has the same value as index.html.

If index.html is non-empty, then the elements of index.html will be combined with element index.html to produce an element of the result. The particular means of combining these values is described in the result value section of the specification of the routine below. As an example, for SUM_SCATTER, if the elements of index.html are index.html, then the element of the result corresponding to the element index.html of BASE is the result of evaluating SUM((/index.html/)).

Note that, since a scalar is conformable with any array, a scalar may be used in place of an INDX array, in which case one hyperplane of the result is selected. See the example below.

If the optional, final MASK argument is present, then only the elements of ARRAY in positions for which MASK is true participate in the operation. All other elements of ARRAY and of the INDX arrays are ignored and cannot have any influence on any element of the result.

For example, if

A is the array , 1, 2, 3 4, 5, 6 7, 8, 9 ,, plus 1filll -1; 1, 2, 3 4, 5, 6 7, 8, 9 ,; plus 1filll -1: 1, 2, 3 4, 5, 6 7, 8, 9 ,: plus 1filll -1.plus 1filll 1, 2, 3 4, 5, 6 7, 8, 9 ,.-50 1, 2, 3 4, 5, 6 7, 8, 9 , plus 1filll-1; B is the array , -1, -2, -3 -4, -5, -6 -7, -8, -9 ,, plus 1filll -1; -1, -2, -3 -4, -5, -6 -7, -8, -9 ,; plus 1filll -1: -1, -2, -3 -4, -5, -6 -7, -8, -9 ,: plus 1filll -1.plus 1filll -1, -2, -3 -4, -5, -6 -7, -8, -9 ,.-50 -1, -2, -3 -4, -5, -6 -7, -8, -9 , plus 1filll-1;
I1 is the array , 1, 1, 1 2, 1, 1 3, 2, 1 ,, plus 1filll -1; 1, 1, 1 2, 1, 1 3, 2, 1 ,; plus 1filll -1: 1, 1, 1 2, 1, 1 3, 2, 1 ,: plus 1filll -1.plus 1filll 1, 1, 1 2, 1, 1 3, 2, 1 ,.-50 1, 1, 1 2, 1, 1 3, 2, 1 , plus 1filll-1; I2 is the array , 1, 2, 3 1, 1, 2 1, 1, 1 ,, plus 1filll -1; 1, 2, 3 1, 1, 2 1, 1, 1 ,; plus 1filll -1: 1, 2, 3 1, 1, 2 1, 1, 1 ,: plus 1filll -1.plus 1filll 1, 2, 3 1, 1, 2 1, 1, 1 ,.-50 1, 2, 3 1, 1, 2 1, 1, 1 , plus 1filll-1
then
SUM_SCATTER(A, B, I1, I2) is , 14, 6, 0 8, -5, -6 0, -8, -9 ,, plus 1filll -1; 14, 6, 0 8, -5, -6 0, -8, -9 ,; plus 1filll -1: 14, 6, 0 8, -5, -6 0, -8, -9 ,: plus 1filll -1.plus 1filll 14, 6, 0 8, -5, -6 0, -8, -9 ,.-50 14, 6, 0 8, -5, -6 0, -8, -9 , plus 1filll-1;
SUM_SCATTER(A, B, 2, I2) is , -1, -2, -3 30, 3, -3 -7,-8,-9 ,, plus 1filll -1; -1, -2, -3 30, 3, -3 -7,-8,-9 ,; plus 1filll -1: -1, -2, -3 30, 3, -3 -7,-8,-9 ,: plus 1filll -1.plus 1filll -1, -2, -3 30, 3, -3 -7,-8,-9 ,.-50 -1, -2, -3 30, 3, -3 -7,-8,-9 , plus 1filll-1;
SUM_SCATTER(A, B, I1, 2) is , -1, 24, -3 -4, 7, -6 -7, -1, -9 ,, plus 1filll -1; -1, 24, -3 -4, 7, -6 -7, -1, -9 ,; plus 1filll -1: -1, 24, -3 -4, 7, -6 -7, -1, -9 ,: plus 1filll -1.plus 1filll -1, 24, -3 -4, 7, -6 -7, -1, -9 ,.-50 -1, 24, -3 -4, 7, -6 -7, -1, -9 , plus 1filll-1;
SUM_SCATTER(A, B, 2, 2) is , -1, -2, -3 -4, 40, -6 -7, -8, -9 ,, plus 1filll -1; -1, -2, -3 -4, 40, -6 -7, -8, -9 ,; plus 1filll -1: -1, -2, -3 -4, 40, -6 -7, -8, -9 ,: plus 1filll -1.plus 1filll -1, -2, -3 -4, 40, -6 -7, -8, -9 ,.-50 -1, -2, -3 -4, 40, -6 -7, -8, -9 , plus 1filll-1.

If A is the array , 10, 20, 30, 40, -10,, plus 1filll -1; 10, 20, 30, 40, -10,; plus 1filll -1: 10, 20, 30, 40, -10,: plus 1filll -1. 10, 20, 30, 40, -10,. plus 1filll -1 10, 20, 30, 40, -10, plus 1filll-1, B is the array , 1, 2, 3, 4,, plus 1filll -1; 1, 2, 3, 4,; plus 1filll -1: 1, 2, 3, 4,: plus 1filll -1. 1, 2, 3, 4,. plus 1filll -1 1, 2, 3, 4, plus 1filll-1, and IND is the array , 3, 2, 2, 1, 1,, plus 1filll -1; 3, 2, 2, 1, 1,; plus 1filll -1: 3, 2, 2, 1, 1,: plus 1filll -1. 3, 2, 2, 1, 1,. plus 1filll -1 3, 2, 2, 1, 1, plus 1filll-1, then SUM_SCATTER(A, B, IND, MASK=(A .GT. 0)) is ,41, 52, 13, 4,, plus 1filll -1;41, 52, 13, 4,; plus 1filll -1:41, 52, 13, 4,: plus 1filll -1.41, 52, 13, 4,. plus 1filll -141, 52, 13, 4, plus 1filll-1.



Next: Array Prefix and Up: Library Procedures Previous: Array Reduction Functions


paula@erc.msstate.edu
Thu Dec 8 16:17:11 CST 1994