函数说明:更改主函数体中的N和length(=log2(N))既可以实现任意点数(2的幂次)的FFT/ IFFT的实现,fft函数中flag标志位控制是正变换还是逆变换。
1.复数操作类
定义复数类,重载复数四则运算符号,重载输出运算符,重载赋值运算符。
/**********预编译文件头文件complex.h********/
#include"iostream"
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<<real<<"+"<<image<<"j"<<" ";
else
cout<<real<<image<<"j"<<" ";
}
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