Yannis Assael
Yannis Assael

Reputation: 1119

Thrust Counting Iterator inside Function

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!

Upvotes: 0

Views: 714

Answers (1)

Yannis Assael
Yannis Assael

Reputation: 1119

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>());

Upvotes: 1

Related Questions