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

📄 dvgen.c

📁 ofdm的完整系统模型,包含信道参数,多径模型,doppler频移等都可以自由修改!是您做仿真的有力帮助.c语言运行速度快!
💻 C
字号:
/*
 *	*************************************************************************
 *	*									*
 *	*	This confidential and proprietary software may be used only	*
 *	*  as authorized by a licensing agreement from the Alta Group of	*
 *	*  Cadence Design Systems, Inc.  In the event of publication, the	*
 *	*  following notice is applicable:					*
 *	*									*
 *	*    (c) COPYRIGHT 1995 ALTA GROUP OF CADENCE DESIGN SYSTEMS, INC.	*
 *	*			ALL RIGHTS RESERVED				*
 *	*									*
 *	*	The entire notice above must be reproduced on all authorized	*
 *	*  copies.								*
 *	*									*
 *	*************************************************************************
 *
 */
/*
 * FUNCTION:  DvGenerate(i_type, i_length, sp_props)
 * DESCRIPTION: Function to generate sine tables for FFT's and 
 *              window functions. 
 * RETURN VALUE: Ovector where computed table resides 
 * NOTES/WARNINGS: 
 * REVISION HISTORY:
 *	Release		Who	Date	Comments
 *      2.6    John Lundell 02/23/90  Changed Macro calls to register pointers.
 */

#include "cgs.h"

Objprops ObjPropDefault();

Ovector DvGenerate(i_type, i_length, sp_props)
int		i_type;
int		i_length;
Objprops	sp_props;
{
	register Ovector	ret;
	register int		i;
	register Complex	*cfrw,*cbac;
	register double		*frw, *bac;
	double			s1, s2;
	int			half = (i_length + 1) >> 1;

	frw = bac = (double *)NULL;
	cfrw = cbac = (Complex *)NULL;
	
/*
 *  Get the return vector which is complex for FFT sine table, double otherwise.
 */

	if ( i_type != OvFFT){
		ret = OvAlloc(i_length, sp_props);
		frw = (double *) OvToBegin(ret);
		bac = (double *) OvGetVirtEnd(ret);
		bac--;
	}
	else{
		ret = OvAlloc(i_length,ObjPropDefault(TYPE_VCD,0,0,0,0));
		cfrw = (Complex *) OvToBegin(ret);
		cbac = (Complex *) OvGetVirtEnd(ret);
		cbac--;
	}

 /*
 *  Loop over vector for the given table type.
 */
 
	switch(i_type) {
	      case OvFFT:  
#ifdef DSP32C
		s1 = PI2/2 ;
		for (i = 1; i < half; i++) { 
			cfrw->real = cos(s1/i);
			cfrw->imag = sin(s1/i);
			cbac->real =  cfrw->real;
			cbac->imag = -cfrw->imag;
			cbac -= 1;
			cfrw += 1;

 		}

#else 
		cfrw->real = 1.0;
		cfrw->imag = 0.0;
		cfrw += 1;
		s1 = PI2 / i_length;
		for (i = 1; i < half; i++) {
			cfrw->real = cos(s1 * i);
			cfrw->imag = sin(s1 * i);
			cbac->real =  cfrw->real;
			cbac->imag = -cfrw->imag;
			cbac -= 1;
			cfrw += 1;
 		}
		cfrw->real = -1.0;
		cfrw->imag = 0.0;
#endif	
	break; 

	      case OvBARTLETT_FFT:
		*frw++ = 0.0;
		s1 = 2.0 / (i_length);
       		for (i = 1; i < half; i++){
			*frw++ = *bac-- = s1 * i;
		}
		*frw = 1.0;
		break;
	      case OvBARTLETT:
		s1 = 2.0 / (i_length - 1.0);
       		for (i = 0; i < half; i++){
			*frw++ = *bac-- = s1 * i;
		}
		break;
	      case OvBLACKMAN_FFT:
		*frw++ = 0.0;
		s1 = PI2 / (i_length);
		s2 = 2.0 * PI2 / (i_length);
       		for (i = 1; i < half; i++){
			*frw++ = *bac-- = 0.42 - 0.5*cos(s1 * i) + 0.08*cos(s2 * i);
		}
		*frw = 0.42 - 0.5*cos(s1 * half) + 0.08*cos(s2 * half);
		break;
	      case OvBLACKMAN:
		s1 = PI2 / (i_length - 1.0);
		s2 = 2.0 * PI2 / (i_length - 1.0);
       		for (i = 0; i < half; i++){
			*frw++ = *bac-- = 0.42 - 0.5*cos(s1 * i) + 0.08*cos(s2 * i);
		}
		break;
	      case OvHAMMING_FFT:
		s1 = PI2 / (i_length);
		*frw++ = 0.08;
		for (i = 1; i < half; i++) {
			*frw++ = *bac-- = 0.54 - 0.46*cos(s1 * i);
		}
		*frw = 0.54 - 0.46*cos(s1 * half);
		break;
	      case OvHAMMING:
		s1 = PI2 / (i_length - 1.0);
		for (i = 0; i < half; i++) {
			*frw++ = *bac-- = 0.54 - 0.46*cos(s1 * i);
		}
		break;
	      case OvHANNING_FFT:
		s1 = PI2 / (i_length);
		*frw++ = 0.0;
       		for(i=1; i < half; i++){
			*frw++ = *bac-- = 0.5 - 0.5*cos(s1 * i);
	        }
		*frw = 0.5 - 0.5*cos(s1 * half);
		break;
	      case OvHANNING:
		s1 = PI2 / (i_length - 1.0);
       		for(i=0; i < half; i++){
			*frw++ = *bac-- = 0.5 - 0.5*cos(s1 * i);
	        }
		break;
	      default:
		printf("Invalid table type to OvGenerate.\n");

	}
	return ret;
}

⌨️ 快捷键说明

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