1
thrust::sequence(myvector.begin(), myvector.end(), 0, 1)
并取得良好的有序列表,如:
0, 1, 2, 3, 4
我的问题是如何实现这样的下面列举(最好的方法是什么?)
0, 0, 0, 1, 1, 1, 2, 2 ,2, 3, 3, 3
我知道如何与函子做,所以请不要试图用函子来回答。我想了解,如果有一个优化的方式为它的推力,还是我失去了一个简单的方法..
尼斯的答案,但我不能编译:xyz.cu(544) :error:没有重载函数的实例“thrust :: transform”匹配参数列表参数类型是:(thrust :: counting_iterator,thrust :: counting_iterator ,thrust :: constant_iterator ,thrust :: detail :: normal_iterat或>,thrust :: divides ) –
phoad
您是否阅读过错误信息?你已经为常量和计数迭代器参数混合了'unsigned int'和'int'类型。我已经编辑了一个可编辑的例子,它可以正确运行,供你学习。 – talonmies
是的,我很惊讶,因为得到这样的错误,并错过了unsigned int vs int不匹配。很好的结果,答案和错误。谢谢。 – phoad