Re: FFTW versus NRC FFT
- From: yongjun wang <ywang2@xxxxxxxxxxx>
- Date: Sun, 14 Jan 2007 14:27:21 EST
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
.
- Follow-Ups:
- Re: FFTW versus NRC FFT
- From: stevenj
- Re: FFTW versus NRC FFT
- References:
- FFTW versus NRC FFT
- From: Blacky
- FFTW versus NRC FFT
- Prev by Date: Re: Bell shaped curves
- Next by Date: Re: FFTW versus NRC FFT
- Previous by thread: Re: FFTW versus NRC FFT
- Next by thread: Re: FFTW versus NRC FFT
- Index(es):
Relevant Pages
|
Loading