Home > Back-end >  C do FFT (2)
C do FFT (2)

Time:09-27

For (unsigned int j=0; J & lt; N; J++)
{
Int rev=0;
Int num=j;
for (int i=0; i {
Rev & lt; <=1;
Rev |=(num & amp; 1);
Num & gt;>=1;
}
=x1 x2 [rev] [j];
//1 x2 test
//double testc x2=[happen]. Real;
//double testd x2=[happen] imaginary;
}
//2 x2 test
for(int i=0; i{
Double testc x2=[I]. Real;
Double testd x2=[I]. Imaginary;
}
Ask, why test 2 x2 value after the x2 [0] all become the same,

CodePudding user response:

The inline COMPLEX * CFreDomain: : FFT (COMPLEX * sourceData, int N)
{
Int r=(int) logf (N)/logf (2);
COMPLEX * w=(COMPLEX *) malloc (sizeof (COMPLEX) * N/2);
COMPLEX * x1=(COMPLEX *) malloc (sizeof (COMPLEX) * N);
COMPLEX * x2=(COMPLEX *) malloc (sizeof (COMPLEX) * N);
Memcpy (x1, sourceData, sizeof (COMPLEX) * N);
//calculate the weighted coefficient of
Double Angle=0;
for(int i=0; i{
Angle=2 * PI * I/N.
W [I]=defcomplex (cos (Angle), sin (Angle));
Angle=0;
}
//butterfly operation
Int interval=0;
Int bfsize=0;
Int gap=0;
for(int i=0; i{
The interval=(1 & lt; Bfsize=(1 & lt; <(r - I));
for(int j=0; j{
Gap=j * bfsize;
For (int k=0; K{
(x1 x2=[k + gap] addComplex] [k + gap, and x1 [k + + bfsize gap/2]).
X2=[k + bfsize/2 + gap] mulComplex (subComplex (x1] [k + gap, and x1 [k + + bfsize gap/2]), w * interval [k]);
/* double testa x2=[k + gap]. Real;
Double testb x2=[k + + bfsize gap/2] real; */
}
}
Memcpy (x1, x2, sizeof (COMPLEX) * N);
}
//reorder
For (unsigned int j=0; J & lt; N; J++)
{
Int rev=0;
Int num=j;
for (int i=0; i {
Rev & lt; <=1;
Rev |=(num & amp; 1);
Num & gt;>=1;
}
=x1 x2 [rev] [j];
//1 x2 test
Double testc=x2 (rev). The real;
Double testd=x2 (rev). The imaginary;
}
//2 x2 test
/* for (int I=0; i{
Double testc x2=[I]. Real;
Double testd x2=[I]. Imaginary;
} */
Free (w);
Free (x1);
Return the x2.
}
The entire function here
  • Related