I'm an Italian university student. I'm trying to use FFTW libraries. I
have problems but I don't know in which forum I may ask help so I try here.
I wrote the following C program

#include

#include

#include

#include

void main()

{

int i;

int N, num_points; // dimensione trasformata

double T;

double *in; // puntatore dati in ingresso alla FFT

fftw_complex *out, *in2, *out2; // puntatore ai dati in uscita della FFT

fftw_plan trasf_diretta, trasf_inversa;

N=8;

num_points=N/2+1;

T=0.08;

// allocazione memoria

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

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

in[0]0000.0;

in[1]000.0;

in[2]`000.0;

in[3]0000.0;

in[4]=0.0;

in[5]=0.0;

in[6]=0.0;

in[7]=0.0;

// ffttw_plan_dft_r2c_1d (dimensione, segnale, risultato, flag
ottimizzazione)

trasf_diretta = fftw_plan_dft_r2c_1d (N, in, out, FFTW_ESTIMATE);

fftw_execute(trasf_diretta);

for(i=0;i
{

out[i]=out[i]*T;

}

for(i=0;i
{

printf(" %d %lf %lf\n", i, creal(out[i]), cimag(out[i]));

}

// antitrasformazione

out2 = (double *) malloc(sizeof(double)*N);

trasf_inversa = fftw_plan_dft_c2r_1d (N, out, out2, FFTW_ESTIMATE);

fftw_execute(trasf_inversa);

for (i=0; i
{

printf(" %d %lf\n", i, out2[i]/N/T);

}

fftw_destroy_plan(trasf_diretta);

fftw_destroy_plan(trasf_inversa);

fftw_free(in);

fftw_free(out);

fftw_free(out2);

}

The program compute forward FFT correctly but not inverse FFT because generate a
ifft compressed signal along x axis. I can't understand where the problem
is. Can anyone help me? Thank You Roberto

# fftw problem

Started by ●June 5, 2013

Reply by ●September 26, 20132013-09-26

Hi,

Check what the line "out[i]=out[i]*T;" is actually doing. I don����t know how the operator "*" for fftw_complex* is defined. Also, T is double, so I guess T is actually multiplying only the first double (real part) of the complex out. It would distort the phase of the signal yielding weird things like shrinking in time domain.

Best,

- Felipe

I'm an Italian university student. I'm trying to use FFTW libraries. I have problems but I don't know in which forum I may ask help so I try here. I wrote the following C program

>

>#include

>#include

>#include

>#include

>

>void main()

>{

>int i;

>int N, num_points; // dimensione trasformata

>double T;

>double *in; // puntatore dati in ingresso alla FFT

>fftw_complex *out, *in2, *out2; // puntatore ai dati in uscita della FFT

>fftw_plan trasf_diretta, trasf_inversa;

>

>N=8;

>num_points=N/2+1;

>T=0.08;

>

>// allocazione memoria

>in = (double *) malloc(sizeof(double)*N);

>out = (fftw_complex *) fftw_malloc(sizeof(fftw_complex)*num_points);

>

>in[0]0000.0;

>in[1]000.0;

>in[2]`000.0;

>in[3]0000.0;

>in[4]=0.0;

>in[5]=0.0;

>in[6]=0.0;

>in[7]=0.0;

>

>// ffttw_plan_dft_r2c_1d (dimensione, segnale, risultato, flag ottimizzazione)

>trasf_diretta = fftw_plan_dft_r2c_1d (N, in, out, FFTW_ESTIMATE);

>

>fftw_execute(trasf_diretta);

>

>for(i=0;i

Check what the line "out[i]=out[i]*T;" is actually doing. I don����t know how the operator "*" for fftw_complex* is defined. Also, T is double, so I guess T is actually multiplying only the first double (real part) of the complex out. It would distort the phase of the signal yielding weird things like shrinking in time domain.

Best,

- Felipe

I'm an Italian university student. I'm trying to use FFTW libraries. I have problems but I don't know in which forum I may ask help so I try here. I wrote the following C program

>

>#include

>#include

>#include

>#include

>

>void main()

>{

>int i;

>int N, num_points; // dimensione trasformata

>double T;

>double *in; // puntatore dati in ingresso alla FFT

>fftw_complex *out, *in2, *out2; // puntatore ai dati in uscita della FFT

>fftw_plan trasf_diretta, trasf_inversa;

>

>N=8;

>num_points=N/2+1;

>T=0.08;

>

>// allocazione memoria

>in = (double *) malloc(sizeof(double)*N);

>out = (fftw_complex *) fftw_malloc(sizeof(fftw_complex)*num_points);

>

>in[0]0000.0;

>in[1]000.0;

>in[2]`000.0;

>in[3]0000.0;

>in[4]=0.0;

>in[5]=0.0;

>in[6]=0.0;

>in[7]=0.0;

>

>// ffttw_plan_dft_r2c_1d (dimensione, segnale, risultato, flag ottimizzazione)

>trasf_diretta = fftw_plan_dft_r2c_1d (N, in, out, FFTW_ESTIMATE);

>

>fftw_execute(trasf_diretta);

>

>for(i=0;i