Prefix sum
From Wikipedia, the free encyclopedia
The prefix sum (also known as the scan or prefix reduction) of a list (array) in computing is a list in which each element is obtained from the sum of those which precede it. For example, the prefix sum of:
(5, 3, 9, 3)
is
(5, 5+3, 5+3+9, 5+3+9+3) = (5, 8, 17, 20)
Scans may be performed with any associative operation applicable to the elements of the list. As an example, the operations defined by the MPI standard are:
Constant | Meaning |
---|---|
MPI_MAX | return the maximum |
MPI_MIN | return the minimum |
MPI_SUM | return the sum |
MPI_PROD | return the product |
MPI_LAND | return the logical and |
MPI_BAND | return the bitwise and |
MPI_LOR | return the logical or |
MPI_BOR | return the bitwise of |
MPI_LXOR | return the logical exclusive or |
MPI_BXOR | return the bitwise exclusive or |
MPI_MINLOC | return the minimum and the location |
MPI_MAXLOC | return the maximum and the location |
In this case, the constants are used with the MPI_Scan function.