Refer to the thrust quick start guide for an example of this.Īlso note that both in your question and your code you refer to dividing by D 1, but your code is actually dividing by D, not D 1. Note that when passing the end of a permutation iterator, we do not use the end of the source vector: thrust::make_permutation_iterator(P.end(),MapP.end()),īut instead the beginning: thrust::make_permutation_iterator(P.begin(),MapP.end()), I'll assume you want element-wise operation on the vectors, since that is the behavior of your supplied demonstrator code. Thrust::copy(thrust::device, temp.begin(), temp.end(), thrust::make_permutation_iterator(P.begin(),MapP.begin())) // use permutation iterator replace contents of P with the weighted sum using pts in map M thrust::transform(thrust::device, temp.begin(), temp.end(), thrust::make_transform_iterator(D.begin(), increment()), temp.begin(), thrust::divides()) Thrust::make_permutation_iterator(Q.begin(),MapQ.begin()), Thrust::transform(thrust::device, temp.begin(), temp.end(), thrust::transform(thrust::device, temp.begin(), temp.end(), Q.begin(), temp.begin(), thrust::plus()) // use permutation iterator Thrust::make_permutation_iterator(D.begin(),MapP.begin()), Thrust::make_permutation_iterator(P.end(),MapP.end()), Thrust::transform(thrust::device, thrust::make_permutation_iterator(P.begin(),MapP.begin()), thrust::transform(thrust::device, P.begin(), P.end(), D.begin(), temp.begin(), thrust::multiplies()) // use permutation iterator MapP=0 MapP=5 MapP=4 MapP=2 MapP=7 MapP=1 MapP=9 MapP=3 MapP=6 MapP=8 Thrust::sequence(thrust::device, D.begin(), D.begin() N, 1) Thrust::device_vector Q = random_vector(N,9) Thrust::device_vector P = random_vector(N,1) Thrust::uniform_real_distribution u01(0.0f, 10.0f) Unsigned int seed = thrust::default_random_engine::default_seed) Thrust::device_vector random_vector(const size_t N, Can anyone suggest a better way to do it? #include I need to compute (P*D Q)/(D 1) for all points from P
0 Comments
Leave a Reply. |