使用Thrust库的push_back
问题描述:
使用Thrust库可以使用push_back吗?那么矢量矢量呢?我想在GPU在CPU有什么用:使用Thrust库的push_back
vector< vector<int> > MyVector(100);
...
MyVector[i].push_back(j);
有没有一种方法来使用它像例如:
thrust::device_vector<thrust::device_vector<int>> d_vec(4);
和有关创建device_vectors数组是什么?可能吗?
答
- 是,
thrust::device_vector
有push_back
方法就像std::vector
。 - 不,不可能有
device_vector
包含device_vectors
。如果你需要这种推力的功能,我会建议看看thrust::zip_iterator
,它可以提供“结构阵列”,如访问一系列不同的向量或迭代器。
我想要的是以这种方式访问'device_vector dv':'dv [i] [j'] – Manolete
@Manolete:我不认为这是可能的。 – talonmies
但你可以做dv [i * width + j]。 – harrism