In my application I have a class like this:
class sample{
thrust::device_vector<int> edge_ID;
thrust::device_vector<float> weight;
thrust::device_vector<int> layer_ID;
/*functions, zip_iterators etc. */
};
At a given index every vector stores the corresponding data of the same edge.
I want to write a function that filters out all the edges of a given layer, something like this:
void filter(const sample& src, sample& dest, const int& target_layer){
for(...){
if( src.layer_ID[x] == target_layer)/*copy values to dest*/;
}
}
The best way I've found to do this is by using thrust::copy_if(...)
(details)
It would look like this:
void filter(const sample& src, sample& dest, const int& target_layer){
thrust::copy_if(src.begin(),
src.end(),
dest.begin(),
comparing_functor() );
}
And this is where we reach my problem:
The comparing_functor()
is an unary function, which means I cant pass my target_layer
value to it.
Anyone knows how to get around this, or has an idea for implementing this while keeping the data structure of the class intact?