⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_fix_fft.c

📁 很不错的FFT算法
💻 C
字号:
/*  Short test program to accompany fix_fft.c*/#define DEBUG 0#include <stdio.h>#include <stdlib.h>#include <math.h>#include "fix_fft.c"#define N 128#define log2N 7#define AMPLITUDE 12288#define MAX(a,b) (((a)>(b))?(a):(b))int main(){	int i, scale;	unsigned diff;	short x[N], fx[N], fy[N];	for (i=0; i<N; i++) {		fx[i] = fy[i] = x[i] = AMPLITUDE*cos(i*2*3.1415926535/N);#if DEBUG			printf("%d %d\n", i, x[i]);#endif	}	fix_fftr(fy, log2N, 0);	scale = fix_fftr(fy, log2N, 1);#if DEBUG	puts("");	fprintf(stderr, "scale = %d\n", scale);#endif	for (i=0,diff=0; i<N; i++) {#if DEBUG		int sample;		sample = fy[i] << scale;		printf("%d %d\n", i, sample);#endif		diff = MAX(abs(fx[i]-(fy[i] << scale)), diff);	}	fprintf(stderr, "max amplitude error = %g %%\n",			diff *100./AMPLITUDE);	return 0;}

⌨️ 快捷键说明

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