chickadee » array-morphisms » morph-cumsum

morph-scan op m axis #!key exclusive? reverse? init neutral auxprocedure
morph-cumsum m axis #!key exclusive? reverse? initprocedure
morph-cumprod m axis #!key exclusive? reverse? initprocedure
op
'sum, 'prod, 'max, 'min, or a combining expression (below). morph-cumsum and morph-cumprod are morph-scan with 'sum and 'prod.
exclusive?
shifts the results by one position: element r combines the elements before r, and element 0 is init or the neutral element (0, 1, or the lowest or highest value of the dtype).
reverse?
scans from the last element down to the first.
init
an array with the shape of m without the scanned axis: the value each line starts from.
neutral
the neutral element of a combining expression, for an exclusive scan without init.
aux
a list of arrays of the shape of m, one per extra variable of a combining expression.

Each output is the previous output combined with one more element and rounded to the result's dtype, exactly as a loop over the elements in order computes it. The first output is the first element itself, so a first element -0.0 or NaN is kept. max replaces the running value only by a greater element, so a NaN after the first element is passed over; min likewise.