首先用C语言实现FFT的输出
一、程序内容
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 1000
//定义复数类型
typedef struct
{
double real;
double img;
}complex;
void fft(); // 快速傅里叶变换
void initW(); // 初始化变换核
void change(); // 变址
void add(complex ,complex ,complex *); // 复数加法
void mul(complex ,complex ,complex *); // 复数乘法
void sub(complex ,complex ,complex *); // 复数减法
void divi(complex ,complex ,complex *); // 复数除法
void output(); // 输出快速傅里叶变换的结果
complex x[N], *W; // 输入序列,变换核
int size_x=0; // 输入序列的大小,在本程序中仅限2的次幂
double PI; // 圆周率
int main()
{
int i; // 输出结果
system(“cls”);
PI=atan(1)*4;
printf(“Please input the size of x:\n”); // 输入序列的大小
scanf("%d",&size_x);
printf(“Please input the data in x[N]:\n”); // 输入序列的实部和虚部
printf("Enter the sequence\n",i);
for (i = 0; i < size_x; i++)
{
scanf("%lf%lf",&x[i].real,&x[i].img);
}
initW(); //调用变换核
fft(); //调用快速傅里叶变换
printf("Output of FFT\n");
output(); //调用输出傅里叶变换结果函数
return 0;
}
/快速傅里叶变换/
void fft()
{
int i&