Ok so I have managed to solve it using functors, I made two functors (not sure if this is called a functor, but anyways)
__host__ double realpart(cusp::complex<double> val){
return val.real();
}
__host__ double imagpart(cusp::complex<double> val){
return val.imag();
}
And used thrust::transform
cusp::array1d<double,cusp::host_memory>xreal(n);
cusp::array1d<double,cusp::host_memory>ximag(n);
thrust::transform(x.begin(),x.end(),xreal.begin(),realpart);
thrust::transform(x.begin(),x.end(),ximag.begin(),imagpart);
It worked, and then I could fill it normally using thrust::copy to the pointer. It doesnt work for a device_memory array. I tried adding __device___ to the functor, but it did not work.