找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 2852|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

快速FFT變換C語言程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:551867 發(fā)表于 2019-5-31 15:03 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
快速FFT變換源程序
  1. #include <stdio.h>
  2. #include <math.h>

  3. typedef struct                                                                                        //定義復(fù)數(shù)結(jié)構(gòu)體變量
  4. {
  5.         double real;
  6.         double imag;
  7. }complex;

  8. #define N 5

  9. #define PI 3.1514926535897932384626433832795028841971        //定義圓周率

  10. void c_plus(complex, complex, complex *);                                //復(fù)數(shù)加運(yùn)算
  11. void c_sub(complex, complex, complex *);                                //復(fù)數(shù)減運(yùn)算o
  12. void c_mul(complex, complex, complex *);                                //復(fù)數(shù)乘運(yùn)算
  13. void Wn_i(int, int, complex *);                                                    //旋轉(zhuǎn)因子

  14. int main()
  15. {
  16.         complex f[N] = { 1, 2, 2, 3 };
  17.         complex wn;
  18.         Wn_i(8, 3, &wn);
  19.         c_mul(f[0], wn, &f[2]);
  20.         c_sub(f[1], f[2], &(f[3]));
  21.         c_plus(f[1], f[2], &(f[4]));
  22.         printf("f[%d]為:%lf + %lf        \n", 2, f[2].real, f[2].imag);
  23.         printf("f[%d]為:%lf + %lf        \n", 3, f[3].real, f[3].imag);
  24.         printf("f[%d]為:%lf + %lf        \n", 4, f[4].real, f[4].imag);
  25.         return 0;
  26. }

  27. void c_plus(complex a, complex b, complex *c)                        //復(fù)數(shù)加法
  28. {
  29.         c->real = a.real + b.real;
  30.         c->imag = a.imag + b.imag;
  31. }
  32. void c_sub(complex a, complex b, complex *c)                        //復(fù)數(shù)減法
  33. {
  34.         c->real = a.real - b.real;
  35.         c->imag = a.imag - b.imag;
  36. }
  37. void c_mul(complex a, complex b, complex *c)                        //復(fù)數(shù)乘法
  38. {
  39.         c->real = a.real*b.real - a.imag*b.imag;
  40.         c->imag = a.real*b.imag + a.imag*b.real;
  41. }

  42. void Wn_i(int n1, int i, complex *Wn)                                        //定義旋轉(zhuǎn)因子
  43. {
  44.         Wn->real = cos(2 * PI*i / n1);
  45.         Wn->imag = -sin(2 * PI*i / n1);
  46. }
復(fù)制代碼

全部資料51hei下載地址:
fft.zip (699 Bytes, 下載次數(shù): 43)

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表