I want to combine the thrust
library and cufft
in my project. Thus 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, cufft
only accepts arrays such as cuDoubleComplex *a
, while thrust::sequence
is only working properly 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 one refers to thrust::sequence(V2.begin(), V2.end(), 2);
, while the second one refers to std::cout << V1[i] << ' ' << V2[i] << ' ' << V3[i] << '\n';
. If I comment V2
, everything works fine.
Is there a conversion between thrust::device_vector<thrust::complex<double>>
and cuDoubleComplex *
? If not, how can I combine them?