Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

IppsFIR and Initial Conditions

Jay_Schamus
Beginner
281 Views
I'm trying to use IppsFIR() to get the same results as the MatLab function filter(). For example, if I do the following call in ML:

y = filter( b, 1, x );

and then use the IPP functions():

IppsFIRState_64f *pState;
ippsFIRInitAlloc( &pState, *b, lenb, NULL );
ippsFIR( *x, *y, lenx, pState );

I get the same results in ML and IPP.

But if I do the following in MatLab:

y = filter( b, 1, x, zi );

and the following in IPP:

IppsFIRState_64f *pState;
ippsFIRInitAlloc( &pState, *b, lenb, *zi );
ippsFIR( *x, *y, lenx, pState );

The results are not at all the same. The ML results are ~ the same as point-by-point adding zi to the length zi number of points at the beginning of y. As for the IPP results, I don't have a clue as to what it's doing. The zi I'm using is symmetric, so it's not a matter of flipping it left-right, but obviously I'm missing something. The zi I'm using is symmetric, so it's not a matter of flipping it left-right, but obviously I'm missing something.

Any ideas on how to get IPP to work like MatLab without simpling adding the intitial conditions to the output?

0 Kudos
2 Replies
igorastakhov
New Contributor II
281 Views
Hi,

"filter" in Matlab corresponds to IIR filter - when you use "null" delay line and a[0]=1 - it works as FIR, but when you use initialized delay line - "filter" considers it as IIR direct form 2 delay line (see description for "filter" in the manual); IPP FIR considers delay line as simple tapsLen-1 delayed source. For full correspondence with "filter" you should use IPP IIR functionality and recalculate zi (delay line) to direct form 2 as it's described in Matlab documentation (ippsIIR also uses direct form 2 delay line). Or if you need only FIR - you should use your direct form1 delay line for IPP and for Matlab you should recalculate it to the direct form2:

for( i = 0; i < order; i++ ){
pDly = 0;
for( n = order - i; n > 0; n-- ){
pDly += pTaps[n+i] * pSrc[len-n]; /* b- corfficients */
}
}
for( i = 0; i < order; i++ ){
for( n = order - i; n > 0; n-- ){
pDly -= pTaps[order+n+i] * pDst[len-n]; /* a- coefficients */
}
}

Regards,
Igor

0 Kudos
Jay_Schamus
Beginner
281 Views
Doh!

Thanks, Igor. I didn't make the connection that of course ML is always using an IIR filter even when the denominator coefficients are just 1. Been too long since I took my filters classes.

Thanks again.


0 Kudos
Reply