boostorg / compute

A C++ GPU Computing Library for OpenCL
http://boostorg.github.io/compute/
Boost Software License 1.0
1.52k stars 333 forks source link

Compute average by keys #837

Open rgreenblatt opened 5 years ago

rgreenblatt commented 5 years ago

I need to compute the average of a vector of 3d points (stored as float4) grouped by another vector of keys. The easiest approach I can think of is to store a count in the 4th value of the float4 (which I am not using otherwise), initialize the count to 1, and then sum using reduce_by_keys. This seems kind of dirty, so I was wondering if there was a better way. Is there something like numpy's bincount that I haven't found?

Thanks!