background image

#include <iom128.h>
#include <intrinsics.h>

/*********************************************************************
                         快速福利叶变换 C 函数
函数简介:此函数是通用的快速傅里叶变换 C 语言函数,移植性强,以下部分不依
          赖硬件。此函数采用联合体的形式表示一个复数,输入为自然顺序的复
          数(输入实数是可令复数虚部为 0),输出为经过 FFT 变换的自然顺序的
          复数
使用说明:使用此函数只需更改宏定义 FFT_N 的值即可实现点数的改变,FFT_N 的
          应该为 2 的 N 次方,不满足此条件时应在后面补 0
函数调用:FFT(s);

    

间:2010-2-20

    

本:Ver1.0

    

参考文献:
      
**********************************************************************/
#include<math.h>

#define PI 3.1415926535897932384626433832795028841971               //定义圆周率值
#define FFT_N 128                                          //定义福利叶变换的点数

struct compx {float real,imag;};                                    //定义一个复数结构
struct compx s[FFT_N];          //FFT 输入和输出:从 S[1]开始存放,根据大小自己定义

/*******************************************************************
函数原型:struct compx EE(struct compx b1,struct compx b2)  
函数功能:对两个复数进行乘法运算
输入参数:两个以联合体定义的复数 a,b
输出参数:a 和 b 的乘积,以联合体的形式输出
*******************************************************************/
struct compx EE(struct compx a,struct compx b)      
{
 struct compx c;
 c.real=a.real*b.real-a.imag*b.imag;    
 c.imag=a.real*b.imag+a.imag*b.real;
 return(c);
}

/*****************************************************************
函数原型:void FFT(struct compx *xin,int N)
函数功能:对输入的复数组进行快速傅里叶变换(FFT)
输入参数:*xin 复数结构体组的首地址指针,struct 型