March 2003
Intermediate to advanced
656 pages
39h 30m
English
reduceat
u.reduceat(a,indices)Returns an array r with the same type code
as a and the same shape as
indices. Each element of
r is the reduction, with the function or
operator underlying u, of elements of
a starting from the corresponding item of
indices up to the next one excluded (up to
the end, for the last one). For example:
print add.reduceat(range(10),(2,6,8)) # prints: [14 13 17]
Here, r’s elements are
the partial sums 2+3+4+5, 6+7,
and 8+9.