📄 dvfir.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. *
* * *
* *************************************************************************
*
*/
/*
* FILE: dvfir.c
* DATE: Nov 1, 1989
* RELATED FILES:
* AUTHOR: Mark Schrank
* DESCRIPTION: "c" Dvfir function
* NOTES/WARNINGS:
* REVISION HISTORY:
* Release Who Date Comments
* 2.6 John Lundell 02/23/90 Changed Macro calls to register pointers.
*/
#include "cgs.h"
/*
*---------------------------------------------------------------
* FUNCTION: Dvfir(d_input,sp_state,sp_coef)
* DESCRIPTION:
* double Dvfir(double input, Ovector *state, Ovector *coef);
*
* Performs a single FIR filter output using passed filter
* input, state, and coefficients
*
* RETURN VALUE: The filter output
* NOTES/WARNINGS:
* This function uses the state vector as a circular buffer.
* The dot product is therefore split into two parts. The
* first part performs the dot product from the current location
* to the end of the state vector. The second part is the dot
* product from the state vector start to the until the end of
* filter.
*
* This function only uses the points in the state vector in the
* set [state->virtstart, state->virtend). The number of points
* in this set must be >= the length of the coef vector. This
* function ignores the step size of the state vector and assumes
* that the curr_loc is not changed from call to call.
*
* REVISION HISTORY:
* Release Who Date Comments
* 2.6 John Lundell 02/23/90 Changed Macro calls to register pointers.
*/
double Dvfir(d_input, sp_state, sp_coef)
double d_input;
Ovector sp_state;
Ovector sp_coef;
{
register long n = sp_coef->length;
register double *sp = (double *) sp_state->curr_loc;
register double *se = (double *) sp_state->virtend;
register char *cp = sp_coef->virtstart;
register long stpc = sp_coef->stepsize;
register double result = 0.0;
/*
* Update the circular buffer pointer.
*/
if (sp-- <= (double *) sp_state->virtstart) {
sp = se - 1;
}
*sp = d_input;
sp_state->curr_loc = (char *) sp;
/*
* Get the output
*/
while (n-- > 0) {
result += *sp++ * *(double *) cp;
cp += stpc;
if (sp >= se) sp = (double *) sp_state->virtstart;
}
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -