latc_filter.cpp

来自「c语言版各种fir滤波器的实现」· C++ 代码 · 共 37 行

CPP
37
字号
/**********************************************
* Filename : Latc_filter.CPP                  *
* Function : realization of FIR filter with   *
             Lattice structure                *
*Parameter : (k) the coefficients of Lattice  *
                 filter                       *
			 (q) the inner state variables    *
			 (x) the input data               *
			 (y) the output data              *
			 (n) the number of k[]            *
			 (m) the number of input data     *
**********************************************/

#include <stdlib.h>

void latc_filter(float k[],float q[],float x[],float y[],int n,int m)
{
	int i,j;
	float *p;
	p=(float *)calloc(n,sizeof(float));
	for(i=0;i<m;i++)
	{
		*p=x[i]*k[0];
		for(j=1;j<n;j++)
		{
			*(p+j)=*(p+j-1)+q[j-1]*k[j];
		}
		for(j=n-1;j>0;j--)
		{
			q[j]=*(p+j-1)*k[j]+q[j-1];
		}
		q[0]=x[i]*k[0];
		y[i]=*(p+n-1);
	}
	free(p);

}

⌨️ 快捷键说明

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