FFTW 3.01 and C++
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
FFTW 3.01 and C++

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP
Author Message
Guffer
Guest





Posted: Mon Dec 26, 2005 5:15 pm    Post subject: FFTW 3.01 and C++ Reply with quote

Hi,

I hope this is not off topic!

I'm trying to make use of the FFTW library (V3.01) but I have som
difficulties working out the data types which comes with the library - an
possibly the coding too! Below I have pasted in my current source cod
which should calculate the FFT of real input data. The input is a sinusoi
signal and I'm looking for non-zero data in the output vector but all I ge
is zeros. I'm fairly green in terms of c++ programming so there might b
some really basic problems with my code. Furthermore, I'm not really sur
how to extract data from the output vector (a vector of the fftw_complex
Does anyone know how to do this?

Cheers
Thomas

// FFT specific

int N = 256;

// Input test signal

double input[256];

char txt[256];

for(int indx=0; indx<256; indx++)

{

input[indx]=cos(2.f*22.f/7.f*1000.f*(indx/20000.f));

sprintf(txt,"sample[%d]= %f",indx,input[indx]);

OutputDebugString(txt);

}


double *in;

fftw_complex *out;

fftw_plan p;


in = (double *)fftw_malloc(sizeof(double) * N);

out = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * N);

p = fftw_plan_dft_r2c_1d(N, in, out, FFTW_MEASURE);

fftw_execute(p); /* repeat as needed */

fftw_destroy_plan(p);


in = input;

fftw_free(in);

fftw_free(out);

for(int indx=0; indx<256; indx++)

{

sprintf(txt,"re[%d]=%f,& im[%d]=%f", indx, &out[indx][0], indx
&out[indx][1]);

OutputDebugString(txt);

sprintf(txt,"re[%d]=%f,& im[%d]=%f", indx, out[indx][0], indx
out[indx][1]);

OutputDebugString(txt);

}
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> DSP All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB