Comment

Comment by Lichtso

If I am not mistaken a weighed fold / reduction [0] over a sliding window (kernel) is a convolution [1], right?

While the algorithm presented here is sequential, this smells like it could be done in parallel.

In fact the "cum_aggs" stack is a prefix scan [2].

For the sum of values (and by extension also the average), if you have the input prefix scanned (which can be done in parallel) then you can answer any (yes any, dynamic size, not fixed size window) subslice reduction in constant time.

[0]: https://en.wikipedia.org/wiki/Fold_(higher-order_function) [1]: https://en.wikipedia.org/wiki/Convolution [2]: https://en.wikipedia.org/wiki/Prefix_sum

parent Lichtso 15 days ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton