thrust
thrust copied to clipboard
consider adding algorithm for repeating values a specified number of times
e.g. repeat([A,B,C,D],[2,3,0,4]) -> [A,A,B,B,B,D,D,D,D]
fill_by_count may be a better name as this is a generalization of fill_n
template<typename InputIterator1,
typename InputIterator2,
typename OutputIterator>
OutputIterator fill_by_count(counts_first, counts_last, values_first, result);
The semantics would be as if it were implemented as
for(; counts_first != counts_last; ++counts_first, ++values_first)
{
result = fill_n(result, *counts_first, *values_first);
}
return result;
Yes, fill_by_count is better because it connotes the fact that the counts should be non-negative integers. Here's a parallel implementation: http://code.google.com/p/thrust/source/browse/examples/expand.cu
Forwarded from http://code.google.com/p/thrust/issues/detail?id=458
Sean has a function like this called IntervalExpand in MGPU. It works like a merge, and should be quite a bit faster than the implementation in our example code.