非常感谢Cuda Thrust Custom function
的答案如果我想传递另一个向量来复制这样的值,最后一件事是什么?
for (i=0;i<n;i++)
for (j=0;j<n;j++)
y[i*n+j]=h1[i]*a1[pos*n+j];
我还不清楚如何将值传递给创建的函数谢谢!
答案 0 :(得分:1)
thrust::transform(
thrust::make_permutation_iterator(h1.begin(),
thrust::make_transform_iterator(thrust::make_counting_iterator(0),
IndexDivFunctor(n))),
thrust::make_permutation_iterator(h1.begin(),
thrust::make_transform_iterator(thrust::make_counting_iterator(0),
IndexDivFunctor(n))) + n * n,
thrust::make_permutation_iterator(a1.begin(),
thrust::make_transform_iterator(thrust::make_counting_iterator(0),
Indexa1Functor(n, pos))),
y.begin(),
thrust::multiplies<double>());