谁有傅立叶变化的算法啊?c++的,能直接运行的,课程设计用,谢谢!

来源:百度知道 编辑:UC知道 时间:2024/05/25 06:53:44

#include <math.h>
#include"fft.h"
#include<iostream.h>
/*定义复数乘法*/
struct compx compxmul(struct compx b1,struct compx b2)
{
struct compx b3;
b3.real=b1.real*b2.real-b1.imag*b2.imag;
b3.imag=b1.real*b2.imag+b1.imag*b2.real;
return b3;
}
/*定义复数加法*/
struct compx compxadd(struct compx b1,struct compx b2)
{
struct compx b3;
b3.real=b1.real+b2.real;
b3.imag=b1.imag+b2.imag;
return b3;
}
/* 定义复数得乘方*/
/*struct compx compxpow(struct compx b1,int n)
{
struct compx b2;
b2.real=1;
b2.imag=0;
for(int i=0;i<n;i++)
b2=compxmul(b2,b1);
return b2;
}*/
/*fft算法*/
void fft(struct compx *xin, int N)
{
int f,m,nv2,nm1,k,i,j=N/2,l;//f为数组元素个数,m为级数,
struct compx v,w,t;
nv2=N/2;
f=N;
for(m=1;(f=f/2)!=1;m++);
nm1=N-1;
for(i=0,j=0;i<nm1;i++)//这一个for循环进行码位倒置
{
if(