katz
04-17-2005, 11:00 AM
hello
i'm really sorry for what will seem to most people in this forum as
trivial question, but i am having trouble using the FFTW library
everything compiles correctly, but for some reason when i run the progra
it crashes. i worked out that the problem comes from when i read the dat
into the input array, but i really don't know what i am doing wrong. her
is the code. i know that this forum isn't supposed to check code...but
am really stuck.
// FFT the text vector
double *text_in, *text_out;
fftw_plan p1;
int nx = Element.size();
// Allocate the input and output arrays, and create the plan
text_in = (double*)fftw_malloc(sizeof(double) * nx );
text_out = (double*)fftw_malloc(sizeof(double) * nx);
fftw_plan_dft_r2c_1d(nx, text_in, text_out, FFTW_FORWARD);
fftw_plan_dft_c2r_1d(nx, text_in, text_out, FFTW_BACKWARD);
// Fill the input array with the input data
for (int i = 0; i < Element.size(); i++)
{ text_in[i] = Element[i]; // Real part
text_in[i] = 0.0; /* Imaginary part */
}
// Execute plan on the input data i.e FFT the data
fftw_execute(p1);
// destroy plan
fftw_destroy_plan(p1);
fftw_free(text_in);
fftw_free(text_out);
have i misunderstood how to use the fftw plans? am i right in assumin
that the only problem is in filling the input array with the input data
or are there more problems?
thanx in advance, and really sorry once again, but i don't know who els
to ask.
This message was sent using the Comp.DSP web interface o
www.DSPRelated.com
i'm really sorry for what will seem to most people in this forum as
trivial question, but i am having trouble using the FFTW library
everything compiles correctly, but for some reason when i run the progra
it crashes. i worked out that the problem comes from when i read the dat
into the input array, but i really don't know what i am doing wrong. her
is the code. i know that this forum isn't supposed to check code...but
am really stuck.
// FFT the text vector
double *text_in, *text_out;
fftw_plan p1;
int nx = Element.size();
// Allocate the input and output arrays, and create the plan
text_in = (double*)fftw_malloc(sizeof(double) * nx );
text_out = (double*)fftw_malloc(sizeof(double) * nx);
fftw_plan_dft_r2c_1d(nx, text_in, text_out, FFTW_FORWARD);
fftw_plan_dft_c2r_1d(nx, text_in, text_out, FFTW_BACKWARD);
// Fill the input array with the input data
for (int i = 0; i < Element.size(); i++)
{ text_in[i] = Element[i]; // Real part
text_in[i] = 0.0; /* Imaginary part */
}
// Execute plan on the input data i.e FFT the data
fftw_execute(p1);
// destroy plan
fftw_destroy_plan(p1);
fftw_free(text_in);
fftw_free(text_out);
have i misunderstood how to use the fftw plans? am i right in assumin
that the only problem is in filling the input array with the input data
or are there more problems?
thanx in advance, and really sorry once again, but i don't know who els
to ask.
This message was sent using the Comp.DSP web interface o
www.DSPRelated.com