I know when dealing std::vectors is best to use std::copy, however I was wondering how to copy an fftw_malloc array into an std::vector? and if I should use std::copy or memcpy?
Example code:
static const int nx = 8;
static const int ny = 8;
static const int nyk = ny/2 + 1;
static const int Mx = 3*nx/2, My= 3*ny/2;
double M[2] = {Mx,My};
fftw_complex *array1;
array1= (fftw_complex*) fftw_malloc(nx*nyk* sizeof(fftw_complex));
memset(array1, 42, nx*nyk* sizeof(fftw_complex));
std::vector<std::complex<double>> array2(Mx*My,0.0);
std::copy( array1, array1+(nx*nyk) , array2); //std::copy( src, src + size, dest );
I am trying to copy array1 into array2 where array2 > array1 then would like to use std::vector operators to append values and so on.
This doesn't really work and I am not sure if my vector syntax is off or std::copy
is not the way to go. Should I use memcpy
instead? Thanks
Aucun commentaire:
Enregistrer un commentaire