日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言ifft,用于ARM上的FFT与IFFT源代码-C语言

發(fā)布時間:2024/8/1 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言ifft,用于ARM上的FFT与IFFT源代码-C语言 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

/*******************************************************************************

** 程序名稱:快速傅里葉變換(FFT)

** 程序描述:本程序?qū)崿F(xiàn)快速傅里葉變換

** 程序作者:宋元瑞

** 最后修改:2011年4月5日

*******************************************************************************/

#include

#include

#define PI 3.141592653589?//圓周率,12位小數(shù)

#define N 8?????//傅里葉變換的點數(shù)

#define M 3?????//蝶形運算的級數(shù),N = 2^M

typedef double ElemType;?//原始數(shù)據(jù)序列的數(shù)據(jù)類型,可以在這里設(shè)置

typedef struct????//定義復(fù)數(shù)結(jié)構(gòu)體

{

ElemType real,imag;

}complex;

complex data[N];???//定義存儲單元,原始數(shù)據(jù)與負(fù)數(shù)結(jié)果均使用之

ElemType result[N];???//存儲FFT后復(fù)數(shù)結(jié)果的模

//變址

void ChangeSeat(complex *DataInput)

{

int nextValue,nextM,i,k,j=0;

complex temp;

nextValue=N/2;????????????????? //變址運算,即把自然順序變成倒位序,采用雷德算法

nextM=N-1;

for (i=0;i

{

if (i

{

temp=DataInput[j];

DataInput[j]=DataInput[i];

DataInput[i]=temp;

}

k=nextValue;??????????????? //求j的下一個倒位序

while (k<=j)????//如果k<=j,表示j的最高位為1

{

j=j-k;?????//把最高位變成0

k=k/2;?????//k/2,比較次高位,依次類推,逐個比較,直到某個位為0

}

j=j+k;??????//把0改為1

}

}

/*

//變址

void ChangeSeat(complex *DataInput)

{

complex Temp[N];

int i,n,New_seat;

for(i=0; i

{

Temp[i].real = DataInput[i].real;

Temp[i].imag = DataInput[i].imag;

}

for(i=0; i

{

New_seat = 0;

for(n=0;n

{

New_seat = New_seat | (((i>>n) & 0x01) << (M-n-1));

}

DataInput[New_seat].real = Temp[i].real;

DataInput[New_seat].imag = Temp[i].imag;

}

}

*/

//復(fù)數(shù)乘法

complex XX_complex(complex a, complex b)

{

complex temp;

temp.real = a.real * b.real-a.imag*b.imag;

temp.imag = b.imag*a.real + a.imag*b.real;

return temp;

}

//FFT

void FFT(void)

{

int L=0,B=0,J=0,K=0;

int step=0;

ElemType P=0,T=0;

complex W,Temp_XX;

//ElemType TempResult[N];

ChangeSeat(data);

for(L=1; L<=M; L++)

{

B = 1<

for(J=0; J<=B-1; J++)

{

P = (1<

step = 1<

for(K=J; K<=N-1; K=K+step)

{

W.real =? cos(2*PI*P/N);

W.imag = -sin(2*PI*P/N);

Temp_XX = XX_complex(data[K+B],W);

data[K+B].real = data[K].real - Temp_XX.real;

data[K+B].imag = data[K].imag - Temp_XX.imag;

data[K].real = data[K].real + Temp_XX.real;

data[K].imag = data[K].imag + Temp_XX.imag;

}

}

}

}

void IFFT(void)

{

int L=0,B=0,J=0,K=0;

int step=0;

ElemType P=0,T=0;

complex W,Temp_XX;

//ElemType TempResult[N];

ChangeSeat(data);

for(L=1; L<=M; L++)

{

B = 1<

for(J=0; J<=B-1; J++)

{

P = (1<

step = 1<

for(K=J; K<=N-1; K=K+step)

{

W.real =? cos(2*PI*P/N);

W.imag =? sin(2*PI*P/N);//逆運算,這里跟FFT符號相反

Temp_XX = XX_complex(data[K+B],W);

data[K+B].real = data[K].real - Temp_XX.real;

data[K+B].imag = data[K].imag - Temp_XX.imag;

data[K].real = data[K].real + Temp_XX.real;

data[K].imag = data[K].imag + Temp_XX.imag;

}

}

}

}

int main(int argc, char *argv[])

{

int i = 0;

for(i=0; i

{

data[i].real = sin(2*PI*i/N);

printf("%lf ",data[i]);

}

printf("

");

FFT();//進(jìn)行FFT計算

printf("

");

for(i=0; i

{printf("%lf ",sqrt(data[i].real*data[i].real+data[i].imag*data[i].imag));}

IFFT();//進(jìn)行FFT計算

printf("

");

for(i=0; i

{printf("%lf ",data[i].real/N);}

printf("

");

/*for(i=0; i

{printf("%lf ",data[i].imag/N);}

printf("

");*/

/*for(i=0; i

{printf("%lf ",sqrt(data[i].real*data[i].real+data[i].imag*data[i].imag)/N);}*/

return 0;

}

總結(jié)

以上是生活随笔為你收集整理的c语言ifft,用于ARM上的FFT与IFFT源代码-C语言的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。