I have a class which represents a real 2D scalar field. As is suggested here, I allocated the memory in a contiguous block, i.e using a double*
pointer and fftw_malloc
.
Now I want the DFT of this real 2D scalar field. Following the documentation of the FFTW3 library I have written the following code.
#include <cmath>
#include "RGFun.hpp"
int main()
{
int N = pow(2,6);
RGFun A(N+2,N); //adding two extra columns as suggested for real transforms.
int n0,n1;
n0 = n1 = N;
int len = n0*(n1/2 + 1);
double* in = A.getMem();
fftw_complex* out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*len);
fftw_plan p = fftw_plan_dft_r2c_2d(n0,n1,in,out,FFTW_FORWARD);
fftw_execute(p);
fftw_destroy_plan(p);
fftw_free(in);
fftw_free(out);
return 0;
}
Now this code compiles but when executed gives segmentation fault. I read that for an in-place transform the in
pointer must be equal to the out
pointer. How can I do this in C++11?
Aucun commentaire:
Enregistrer un commentaire