lundi 8 juin 2020

Is there a way to multiply all the elements of an array using thrust?

Let's say I have an array and I want to multiply all the elements of that array and store it in a variable. How do I do it? I want to multiply all the elements in A and store the result in S. Doing this gives me zero.

enter code here
thrust::device_vector<double> A(10);
thrust::sequence(A.begin(), A.end(), 1);
double S = thrust::reduce(thrust::host, A.begin(), A.end(),0,thrust::multiplies<double>());



Aucun commentaire:

Enregistrer un commentaire