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

📄 tcr2fftn.c

📁 快速FFT,汇编原程序
💻 C
字号:
#include <stdio.h>
#include "tcr2fftn.h"

#define FFTSIZE 32	
#define PRINT_ON_ERROR
extern complex_fract16 in[];
extern complex_fract16 out[];
extern complex_fract16 w[];

void main(void)
{
short error1, error2;
int i, n, wst;
double PI = 3.14159265358979;


Init(w);

printf("\nTesting Property 1.......\n");

n = 0;
wst =0;

for(i=0; i<FFTSIZE; i++)
{
	in[i].re = 700*i;
	in[i].im = -850*i;
	out[i].re =0, out[i].im = 0;
}

_cfftN(in,out, w, wst, n);

for (i = 0; i < FFTSIZE; i++)
	{
	if ((out[i].re != 0) || (out[i].im != 0))
		{	 
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000,0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[i].re, out[i].im);
#endif 
		}
	}


printf("Testing Property 2.......\n");

n = FFTSIZE;
wst = (int)(512/n);

for(i=0; i<n; i++)
{
	in[i].re = 0;
	in[i].im = 0;
	out[i].re =0, out[i].im = 0;
}

_cfftN(in,out, w, wst, n);

for (i = 0; i < n; i++)
	{
	if ((out[i].re != 0) || (out[i].im != 0))
		{	 
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000,0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[i].re, out[i].im);
#endif   
		}
	}


printf("Testing property 3.......\n");

n =FFTSIZE;
wst = (int)(512/n);

for(i=0; i<n; i++)
{
	in[i].re = 0x3fff;
	in[i].im = 0x3fff;
	out[i].re =0, out[i].im = 0;
}

_cfftN(in,out, w, wst, n);

error1 = out[0].re - 0x3fff;
error2 = out[0].im - 0x3fff;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",in[0].re, in[0].im);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[0].re, out[0].im);
#endif   
}

for (i = 1; i < n; i++)
	{
	if ((out[i].re != 0) || (out[i].im != 0))
		{	 
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000,0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[i].re, out[i].im);
#endif   
		}
	}

printf("Testing property 4.......\n");
n =FFTSIZE;
wst = (int)(512/n);

in[0].re = 0x3fff;
in[0].im = 0x3fff;

for(i=1; i<n; i++)
{
	in[i].re = 0;
	in[i].im = 0;
}
_cfftN(in,out, w, wst, n);

for (i = 0; i < n; i++)
	{
	error1 = 512 - out[i].re;
	error2 = 512 - out[i].im;

	if (abs(error1) >1 || abs(error2) > 1)
		{	 
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000,0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[i].re, out[i].im);
#endif  
		}
	}


printf("Testing property 5.......\n");
n =FFTSIZE;
wst = (int)(512/n);

for(i=0; i<n; i++)
{
	in[i].re = multi_in[i].re;
	in[i].im = multi_in[i].im;
}

_cfftN(in,out, w, wst, n);

error1 = out[0].re - 0;
error2 = out[0].im - 0;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000, 0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[0].re, out[0].im);
#endif  
}

error1 = out[1].re - 0;
error2 = out[1].im - 0xF000;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000, 0xF000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[1].re, out[1].im);
#endif  
}

error1 = out[2].re - 0x1000;
error2 = out[2].im - 0;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x1000, 0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[2].re, out[2].im);
#endif  
}

for(i=3; i< 30; i++)
{
error1 = out[i].re - 0;
error2 = out[i].im - 0;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000, 0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[i].re, out[i].im);
#endif  
}
}

error1 = out[30].re - 0x1000;
error2 = out[30].im - 0;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x1000, 0x0000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[30].re, out[30].im);
#endif  
}


error1 = out[31].re - 0;
error2 = out[31].im - 0x1000;

if(abs(error1) >1 || abs (error2) > 1)
{
			printf("Failed\n\n");
#ifdef PRINT_ON_ERROR
	 printf("Expected Result : Real = 0x%x Imaginary = 0x%x\n",0x0000, 0x1000);
	 printf("Calculated Result : Real = 0x%x Imaginary = 0x%x\n", out[31].re, out[31].im);
#endif  
}

}

⌨️ 快捷键说明

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