Segmented (or keyed) reduction

Hello all.

Does anyone have an idea on how I can implement a segmented reduction similar to what Thrust for CUDA does?

Example: [url=“http://thrust.googlecode.com/svn/tags/1.2.0/doc/html/group__reductions.html#gc1fadcdd29791f655a3144c2e741838a”]http://thrust.googlecode.com/svn/tags/1.2....a3144c2e741838a[/url]