thrust::reduce
配列 A の最大値を見つけるために使用したい のですがA[i]
、別の配列 B の特定のブール条件も満たす場合にのみ、最大値として選択する必要があります。たとえば、B[i] は true である必要があります。これを行うのは、thrust::reduce のバージョンですか。ドキュメントを調べたところ、次の API しか見つかりませんでした。
thrust::reduce(begin,end, default value, operator)
しかし、私は彼らのバージョンが私の問題により適しているのか知りたいと思いましたか?
編集: コンパイルは最後の行で失敗します!
typedef thrust::device_ptr<int> IntIterator;
typedef thrust::device_ptr<float> FloatIterator;
typedef thrust::tuple<IntIterator,FloatIterator> IteratorTuple;
typedef thrust::zip_iterator<IteratorTuple> myZipIterator;
thrust::device_ptr<int> deviceNBMInt(gpuNBMInt);
thrust::device_ptr<int> deviceIsActive(gpuIsActive);
thrust::device_ptr<float> deviceNBMSim(gpuNBMSim);
myZipIterator iter_begin = thrust::make_zip_iterator(thrust::make_tuple(deviceIsActive,deviceNBMSim));
myZipIterator iter_end = thrust::make_zip_iterator(thrust::make_tuple(deviceIsActive + numRow,deviceNBMSim + numRow));
myZipIterator result = thrust::max_element(iter_begin, iter_end, Predicate());