Question

Thank you very much for the answers at Cuda Thrust Custom function

One last thing if I wanted to pass another vector to copy values such as this?

for (i=0;i<n;i++)
        for (j=0;j<n;j++)
            y[i*n+j]=h1[i]*a1[pos*n+j];

Its still not clear to me how to pass values to the function created Thanks!

Was it helpful?

Solution

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>());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top