/***************预编译文件头文件complex.h********/ #include%using namespace std;
/***********************定义复数类,重载基本运算符*********************/ class complex {
double real,image; public:
complex(){real=0;image=0;}
complex(float i,float j){real=i;image=j;} double getr(){return real;} double geti(){return image;} void show() {
if(image>=0)
cout< cout< void setvalue(double i=0,double j=0) { real=abs(i)<0.0001?0:i; image=abs(j)<0.0001?0:j; } complex operator +(complex&); complex operator-(complex&); complex operator*(complex&); complex operator /(int n); void operator+=(complex&); void operator =(complex&); friend complex W(int m,int n, int flag); }; complex complex::operator +(complex& c) ; \ { complex t; t.real=real+c.real; t.image=image+c.image; return t; } complex complex::operator*(complex& c) { complex t; t.real=real*c.real-image*c.image ; t.image=real*c.image+image*c.real; return t; } complex complex::operator/ (int n) { complex temp; temp.real=real/n; temp.image=image/n; return temp; } complex complex::operator -(complex& c) { complex t; t.real=real-c.real; t.image=image-c.image; return t; } void complex::operator+=(complex&c) { real=real+c.real; image=image+c.image; } void complex::operator =(complex&c) { real=abs(c.real)<0.00001?0:(c.real); image=abs(c.image)<0.00001?0:(c.image); } /*******************主函数体***********************/ #include \#include\#include\#include\#define pi 3.141592657 #define N 16//需要运算的fft的点数 #define length 4//存储需要的二进制位,即length=log2(N) using namespace std; /*********************重新排列输入序列函数****************************/ void bit_reversal(complex a[],int n) { int bitdesicion(unsigned);//用来重现排序原来的输入信号序列应该对应变换的信号的序号 complex temp; int j; for(int i=0;i j=(int)bitdesicion(i); if(i int bitdesicion(unsigned n) { int j=0; double k; double result=0;