The Gaussian Fourier Transform is Gaussian, but for some reason, the fast Fourier Transform Library from the GNL Science Library (GNU) does not give this at all. I included the code that I used to generate (try) the Fourier transform, and two corresponding graphs immediately after it. Can it help me determine what I messed up?
#include <gsl/gsl_fft_complex.h> #include <fstream> #define REAL(z,i) ((z)[2*(i)]) //complex arrays stored as #define IMAG(z,i) ((z)[2*(i)+1]) using namespace std; int main(){ double N = pow(2,9); //power of 2 for Cooley-Tukey algorithm int n = (int) N; double f[2*n]; double dx = 10./N; double x = -5.; ofstream fileo("out.txt"); for (int i=0; i<n; ++i){ //initialize gaussian REAL(f,i)=exp(-0.5*x*x); IMAG(f,i)=0.; x+=dx; } gsl_fft_complex_radix2_forward(f, 1, n); //Fourier transform for (int i=0; i<n; ++i){ fileo<<i<<" "<<REAL(f,i)<<'\n'; //plot frequency distribution } fileo.close(); }


EDIT: Resolved!
As @ roadrunner66 said in the answer, the width of the original Gaussian was very wide, which led to a ridiculously narrow Gaussian in Fourier space. Moreover, my plot looked funny because, as suggested in the @nm comment (now deleted), the Fourier transform returns a DFT with projections onto k-values ββindexed as k = 0,1, ..., N / 2, -N / 2, ...- 2, -1.

source share