Re: FFTW versus NRC FFT



I just started to learn something about FFT and try to get familar with FFTW.
I used the following code to calculate fourier transform of data sampled from exp(-t/4) with rate 1s.


#include <iostream>
#include <math.h>
#include <fftw3.h>

using namespace std;

int main()
{ double* in;
fftw_complex* out;
int N=32;
in = (double*) fftw_malloc(sizeof(double) * N);
out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);

fftw_plan plan;

plan=fftw_plan_dft_r2c_1d(N,in,out,FFTW_MEASURE);
in[0]=0.5;

cout<<"input data"<<endl;
for(int i=1;i<N;i++){in[i]=exp(-double(i)/4);cout<<in[i]<<" "<<endl;}
cout<<endl;

fftw_execute(plan);

cout<<"output data"<<endl;
for(int i=0;i<N/2;i++)
{
for(int j=0;j<2;j++)cout<<out[i][j]<<" "<<" ";
cout<<endl;
}
fftw_free(in);
fftw_free(out);

return 0;

}

the result is about 4 times larger than what i calculated directly from 1/(1+w*w),
not sure why is that.

thanks for your help
.



Relevant Pages

  • Simple 1-D Complex to Complex FFT with FFTW in a Mex File
    ... FFTW 3.1.2, Matlab R14sp3, VC++ 6.0 compiler. ... inR, inI, outR, outI); ... void mexFunction(int nlhs, mxArray *plhs, ...
    (comp.soft-sys.matlab)
  • complex number woes when calling fftw from a mex file
    ... So I've managed to do an 1d fft by calling fftw from a c mex file, ... which is a two dimensional array whos second index is 0 or 1 for real ... Forgive my ignorance of c's pointer voodo. ... int nrhs, const mxArray *prhs) ...
    (comp.soft-sys.matlab)
  • Re: complex number woes when calling fftw from a mex file
    ... So I've managed to do an 1d fft by calling fftw from a c mex file, ... which is a two dimensional array whos second index is 0 or 1 for real ... Forgive my ignorance of c's pointer voodo. ... int nrhs, const mxArray *prhs) ...
    (comp.soft-sys.matlab)
  • Re: Fourier Transform, Smooth Functions
    ... normalizations) and gis the Fourier transform of f ... (Where the value of c will vary from treatment to treatment, ...
    (sci.math)
  • Re: Integral of sin(x)/x
    ... int int ... ... The fact that the Fourier transform of 1 is a delta function ... "Understanding Godel isn't about following his formal proof. ...
    (sci.math)

Loading