If i use
float sum = thrust::transform_reduce(d_a.begin(), d_a.end(), conditional_operator(), 0.f, thrust::plus<float>());
I get the sum of all elements satisfying the condition conditional_operator(), as in Conditional abbreviation in CUDA .
But I can only summarize the elements d_a[0], d_a[2], d_a[4], d_a[6], .....?
I was thinking about changing the conditional operator, but it works on the elements in the array without reference to the index.
What can I do for this?
source
share