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;
};
In this index, each vector stores the corresponding data for 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);
}
}
The best way I've found this is to use thrust::copy_if(...) (more)
It will 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 here we achieve our problem :
comparing_functor()is a unary function, which means that I cannot pass the value to me target_layer.
Does anyone know how to get around this, or have an idea to implement this while maintaining the integrity of the class data structure?
Slawo source
share