使用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数组是什么?可能吗?

  1. 是,thrust::device_vectorpush_back方法就像std::vector
  2. 不,不可能有device_vector包含device_vectors。如果你需要这种推力的功能,我会建议看看thrust::zip_iterator,它可以提供“结构阵列”,如访问一系列不同的向量或迭代器。
+0

我想要的是以这种方式访问​​'device_vector dv':'dv [i] [j'] – Manolete

+0

@Manolete:我不认为这是可能的。 – talonmies

+0

但你可以做dv [i * width + j]。 – harrism