Possible Duplicate:
memcpy(), what should the value of the size parameter be?
I want to copy a dynamic array:
g = new complex<double> [N*N];
to in
of type fftw_complex*
:
in = (fftw_complex*) fftw_alloc_complex(N*N);
When I use:
in= (fftw_complex*) fftw_alloc_complex(N*N);
memcpy( in , g , sizeof(g));
out = (fftw_complex*) fftw_alloc_complex(N*N);
my_plan = fftw_plan_dft_2d(N,N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(my_plan);
fftw_destroy_plan(my_plan);
fftw_free(in);
fftw_free(out);
I get weird results. Just zeros for both in and out.
Strangely, when I use instead:
memcpy( &in , &g , sizeof(g));
I get exactly the correct results, but with this the line:
fftw_free(in);
...does not work. It gives "unhandled exception" error.