¿Cómo programar la transformada discreta de Fourier en C?
int DFT(int dir, int m, doble *x1, doble *y1)
{
long i, k;
doble arg;
doble cosarg, sinarg;
doble *x2=NULL, *y2=NULL;
x2=malloc(m*sizeof(doble ));
y2=malloc(m*sizeof(double));
if (x2=NULL || y2=NULL)
return (FALSE );
for (i=0; ilt; m; i )
{ x2[i]=0
y2[i]=0;
arg=-dir*2.0*3.141592654*(doble)i/(doble)m
for(k=0;klt;m;k)
{
cosarg=cos(k*arg);
sinarg=sin(k*arg);
x2[i] =(x1[); k]*cosarg-y1[k]*sinarg);
y2[i] =(x1[k]*sinarg y1[k]*cosarg);
} p>
}
if (dir==1)
{ for (i=0;ilt;m;i)
{ x1[ i]=x2[i]/(doble)m;
y1[i]=y2[i]/(doble)m;
}
}
else
{ for (i=0; ilt; m; i)
{ x1[i]=x2[i];
y1[i]=y2[i]
}
}
gratis (x2); (y2);
devolver (VERDADERO);
}