I want to combine the library thrustand cufftin my project. So for testing, I wrote
int length = 5;
thrust::device_vector<thrust::complex<double> > V1(length);
thrust::device_vector<cuDoubleComplex> V2(length);
thrust::device_vector<thrust::complex<double> > V3(length);
thrust::sequence(V1.begin(), V1.end(), 1);
thrust::sequence(V2.begin(), V2.end(), 2);
thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(), thrust::multiplies<thrust::complex<double> >());
cufftHandle plan;
cufftPlan1d(&plan, length, thrust::complex<double>, 1);
cufftExecZ2Z(plan, &V1, &V2, CUFFT_FORWARD);
for (int i = 0; i < length; i++)
std::cout << V1[i] << ' ' << V2[i] << ' ' << V3[i] << '\n';
std::cout << '\n';
return EXIT_SUCCESS;
Unfortunately, cufftit only accepts arrays, such as cuDoubleComplex *a, but thrust::sequenceonly works with thrust::complex<double>-vectors. When compiling the code above, I get two errors:
error : no operator "=" matches these operands
error : no operator "<<" matches these operands
The first refers to thrust::sequence(V2.begin(), V2.end(), 2);, and the second relates to std::cout << V1[i] << ' ' << V2[i] << ' ' << V3[i] << '\n';. If I comment V2, everything will be fine. Is there a conversion between thrust::device_vector<thrust::complex<double>>and cuDoubleComplex *? If not, how can I combine them?
source
share