asherliu / thrust

Automatically exported from code.google.com/p/thrust
Apache License 2.0
0 stars 0 forks source link

consider adding algorithm for repeating values a specified number of times #458

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
e.g. repeat([A,B,C,D],[2,3,0,4]) -> [A,A,B,B,B,D,D,D,D]

Original issue reported on code.google.com by wnbell on 7 Feb 2012 at 8:03

GoogleCodeExporter commented 8 years ago
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;

Original comment by jaredhoberock on 7 Feb 2012 at 8:36

GoogleCodeExporter commented 8 years ago
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

Original comment by wnbell on 12 Feb 2012 at 7:41

GoogleCodeExporter commented 8 years ago
Forwarded from https://github.com/thrust/thrust/issues/59

Original comment by jaredhoberock on 7 May 2012 at 9:02