fft.c

来自「本函数利用调用库函数的方法实现了实函数快速傅里叶变换」· C语言 代码 · 共 84 行

C
84
字号
#include "filter.h"
#include "stdio.h"
#include "math.h"
#include "complex.h"
#define N 512;

fract16 output[512];//库函数各参数的全局变量定义 
complex_fract16 t[512];
complex_fract16 out[512];
complex_fract16 w[512];

fract16 input_data[512]={ //初始化输入数据 
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497,3290,-462,5323,-5597,5323,-8595,3290,-18957,
0,18957,-3290,8595,-5323,5597,-5323,462,-3290,-15497,
0,15497};

void main() {
	int wst=1;
	int n=512;
	int block_exponent;
	int cale_method=2;//  dynamic
	twidfftrad2_fr16(w,n);
    rfft_fr16(input_data,t,out, w, wst, n, &block_exponent, cale_method);
    int i;
    for(i=0;i<512;i++)
    {
    	output[i]=cabs_fr16(out[i]);//求变换后的模 
    	printf("%d\t\t",(int)output[i]);
		if(i%8==7)
			printf("\n");
    }
}
//Program End.=======
//库函数的算法说明在“库函数.txt"文件中。

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?