Accumulate the result of applying the operator to all elements.
For a one-dimensional array, accumulate produces results equivalent to:
r = np.empty(len(A))
t = op.identity
for i in xrange(len(A)):
t = op(t,A[i])
r[i] = t
return r
For example, add.accumulate() is equivalent to cumsum().
Parameters: | array : array_like
axis : int, optional
dtype : data-type-code, optional
out : ndarray, optional
|
---|---|
Returns: | r : ndarray
|
Examples
>>> np.multiply.accumulate([2,3,5])
array([2,6,30])