Filters a vector through the FIR LMS filter.
IppStatus ippsFIRLMS_32f(const Ipp32f* pSrc, const Ipp32f* pRef, Ipp32f* pDst, int len, float mu, IppsFIRLMSState_32f* pState);
IppStatus ippsFIRLMS32f_16s(const Ipp16s* pSrc, const Ipp16s* pRef, Ipp16s* pDst, int len, float mu, IppsFIRLMSState32f_16s* pState);
pState |
Pointer to the FIR LMS filter state structure. |
pSrc |
Pointer to the source vector . |
pRef |
Pointer to the reference signal |
pDst |
Pointer to the output signal |
len |
Number of elements in the vector. |
mu |
Adaptation step. |
The function ippsFIRLMS is declared in the ipps.h file. This function filters a source vector pSrc using an adaptive FIR LMS filter.
Each of len iterations performed by the function consists of two main procedures. First, ippsLMS filters the current element of the source vector pSrc and stores the result in pDst. Next, the function updates the current taps using the reference signal pRef, the computed result signal pDst, and the adaptation step mu.
The filtering procedure can be described as a FIR filter operation:
Here the input sample to be filtered is denoted by x(n), the taps are denoted by h(i), and y(n) is the return value.
The function updates the filter coefficients that are stored in the filter state structure pState. Updated filter coefficients are defined as hn+1(i) = hn(i) + 2* mu* errVal * x(n-i),
where hn+1(i) denotes new taps, hn(i) denotes initial taps, mu and errVal are the adaptation step and adaptation error value, respectively. An adaptation error value errVal is computed inside the function as the difference between the output and reference signals.
Before using ippsFIRLMS, initialize the pState structure by calling the function ippsFIRLMSInitAlloc.
The code example below demonstrates how the use of the functions ippsFIRLMS_32f to filter a signal sample.
ippStsNoErr |
Indicates no error. |
ippStsNullPtrErr |
Indicates an error when one of the specified pointers is NULL. |
ippStsSizeErr |
Indicates an error when len is less or equal to 0. |
ippStsContextMatchErr |
Indicates an error when the state identifier is incorrect. |
IppStatus firlms(void) {
IppStatus st;
Ipp32f taps = 0, x[LEN], y[LEN], mu = 0.03f;
IppsFIRLMSState_32f* ctx;
int i;
/// no taps and no delay line from outside
ippsFIRLMSInitAlloc_32f( &ctx, 0, 1, 0, 0 );
/// make a const signal of amplitude 1 and noise it
for(i=0; i<LEN; ++i) x[i] = 0.4f * rand()/RAND_MAX + 0.8f;
st = ippsFIRLMS_32f( x, x+1, y, LEN-1, mu, ctx);
/// get FIR LMS tap, it must be near to 1
ippsFIRLMSGetTaps_32f(ctx, &taps);
ippsFIRLMSFree_32f(ctx);
printf_32f("FIR LMS tap fitted =", &taps, 1, st);
return st;
}
Output:
FIR LMS tap adapted = 0.986842
Copyright © 2000 - 2011, Intel Corporation. All rights reserved.