Need a method pick data which make sense in an array.

Hi, I am new to CUDA. I am searching for a method that can pick useful data in a long array. e.g. pick positive data in an array which contain both positive and negative array and make output array shrunk, like:
Input: 1 -1 2 -2 3 -3
Output: 1 2 3

Is there a method which is designed for these purpose?

Thank you.

thrust has many constructs which could do this easily enough.

You can use compaction (or filtering) operation. Essentially, set the predicate true if the elements is positive.

I second this. And in fact, here’s a link!

Thanks a lot, I will give it a try.

Thank you.