#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
using std::ofstream;
using std::endl;
#ifndef FFT_Def
#define FFT_Def
#define PI 3.1415926535
#define uchar unsigned char
#define N 64 //FFT点数(长度)
#define BIT 16 //FFT的位数(每个数据点的类型),只能是8、16、32
#if (BIT==8) //8-bit 有关常量
#define BITTYPE char //char代表16位整数
#define OVS 52 //最大不溢出幅度,如果计算过程中超过此幅度程序将所有点除2
#define DOVS 104 //最大不溢出幅度*2,如果计算过程中超过此幅度程序将所有点除4
#define WNS 0x7F //旋转因子,也就是此位数下的最大整数
#define SHN 7 //移位因子,当乘以旋转因子后,数值被扩大了2^SHN,因此需要右移
#elif (BIT==16)
#define BITTYPE short
#define OVS 13572
#define DOVS 27145
#define WNS 0x7FFF
#define SHN 15
#elif (BIT==32)
#define BITTYPE int
#define OVS 889516850
#define DOVS 1779033700
#define WNS 0x7FFFFFFF
#define SHN 31
#endif
//提示:
//OVS的值是通过设想最坏情况下,在输出不超过此类型允许数值时,加乘运算输入端的最大幅值
//此值的大小是:此类型的最大正数/(1+sqrt(2))
struct Complex{ //构造复数结构
BITTYPE real;
BITTYPE imag;
};
Complex data[N];
Complex wn[N/2];
float sin_tab[N/4+1];
void tab_sin()
{
int i;
sin_tab[0]=0;
for(i=1;i<=(N/4);i&
FFT快速傅里叶代码
最新推荐文章于 2023-10-15 22:56:05 发布