CMSIS-DSP
Verison 1.1.0
CMSIS DSP Software Library
|
Functions | |
void | arm_lms_norm_f32 (arm_lms_norm_instance_f32 *S, float32_t *pSrc, float32_t *pRef, float32_t *pOut, float32_t *pErr, uint32_t blockSize) |
Processing function for floating-point normalized LMS filter. | |
void | arm_lms_norm_init_f32 (arm_lms_norm_instance_f32 *S, uint16_t numTaps, float32_t *pCoeffs, float32_t *pState, float32_t mu, uint32_t blockSize) |
Initialization function for floating-point normalized LMS filter. | |
void | arm_lms_norm_init_q15 (arm_lms_norm_instance_q15 *S, uint16_t numTaps, q15_t *pCoeffs, q15_t *pState, q15_t mu, uint32_t blockSize, uint8_t postShift) |
Initialization function for Q15 normalized LMS filter. | |
void | arm_lms_norm_init_q31 (arm_lms_norm_instance_q31 *S, uint16_t numTaps, q31_t *pCoeffs, q31_t *pState, q31_t mu, uint32_t blockSize, uint8_t postShift) |
Initialization function for Q31 normalized LMS filter. | |
void | arm_lms_norm_q15 (arm_lms_norm_instance_q15 *S, q15_t *pSrc, q15_t *pRef, q15_t *pOut, q15_t *pErr, uint32_t blockSize) |
Processing function for Q15 normalized LMS filter. | |
void | arm_lms_norm_q31 (arm_lms_norm_instance_q31 *S, q31_t *pSrc, q31_t *pRef, q31_t *pOut, q31_t *pErr, uint32_t blockSize) |
Processing function for Q31 normalized LMS filter. |
This set of functions implements a commonly used adaptive filter. It is related to the Least Mean Square (LMS) adaptive filter and includes an additional normalization factor which increases the adaptation rate of the filter. The CMSIS DSP Library contains normalized LMS filter functions that operate on Q15, Q31, and floating-point data types.
A normalized least mean square (NLMS) filter consists of two components as shown below. The first component is a standard transversal or FIR filter. The second component is a coefficient update mechanism. The NLMS filter has two input signals. The "input" feeds the FIR filter while the "reference input" corresponds to the desired output of the FIR filter. That is, the FIR filter coefficients are updated so that the output of the FIR filter matches the reference input. The filter coefficient update mechanism is based on the difference between the FIR filter output and the reference input. This "error signal" tends towards zero as the filter adapts. The NLMS processing functions accept the input and reference input signals and generate the filter output and error signal.
The functions operate on blocks of data and each call to the function processes blockSize
samples through the filter. pSrc
points to input signal, pRef
points to reference signal, pOut
points to output signal and pErr
points to error signal. All arrays contain blockSize
values.
The functions operate on a block-by-block basis. Internally, the filter coefficients b[n]
are updated on a sample-by-sample basis. The convergence of the LMS filter is slower compared to the normalized LMS algorithm.
y[n]
is computed by a standard FIR filter: y[n] = b[0] * x[n] + b[1] * x[n-1] + b[2] * x[n-2] + ...+ b[numTaps-1] * x[n-numTaps+1]
d[n]
and the filter output: e[n] = d[n] - y[n].
E = x[n]^2 + x[n-1]^2 + ... + x[n-numTaps+1]^2.The filter coefficients
b[k]
are then updated on a sample-by-sample basis: b[k] = b[k] + e[n] * (mu/E) * x[n-k], for k=0, 1, ..., numTaps-1where
mu
is the step size and controls the rate of coefficient convergence. pCoeffs
points to a coefficient array of size numTaps
. Coefficients are stored in time reversed order. {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}
pState
points to a state array of size numTaps + blockSize - 1
. Samples in the state buffer are stored in the order: {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]}
blockSize-1
samples. The increased state buffer length allows circular addressing, which is traditionally used in FIR filters, to be avoided and yields a significant speed improvement. The state variables are updated after each block of data is processed. [-1 +1)
. The fixed-point functions have an additional scaling parameter postShift
. At the output of the filter's accumulator is a shift register which shifts the result by postShift
bits. This essentially scales the filter coefficients by 2^postShift
and allows the filter coefficients to exceed the range [+1 -1)
. The value of postShift
is set by the user based on the expected gain through the system being modeled.void arm_lms_norm_f32 | ( | arm_lms_norm_instance_f32 * | S, |
float32_t * | pSrc, | ||
float32_t * | pRef, | ||
float32_t * | pOut, | ||
float32_t * | pErr, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the floating-point normalized LMS filter structure. |
[in] | *pSrc | points to the block of input data. |
[in] | *pRef | points to the block of reference data. |
[out] | *pOut | points to the block of output data. |
[out] | *pErr | points to the block of error data. |
[in] | blockSize | number of samples to process. |
References blockSize, arm_lms_norm_instance_f32::energy, arm_lms_norm_instance_f32::mu, arm_lms_norm_instance_f32::numTaps, arm_lms_norm_instance_f32::pCoeffs, arm_lms_norm_instance_f32::pState, and arm_lms_norm_instance_f32::x0.
Referenced by main().
void arm_lms_norm_init_f32 | ( | arm_lms_norm_instance_f32 * | S, |
uint16_t | numTaps, | ||
float32_t * | pCoeffs, | ||
float32_t * | pState, | ||
float32_t | mu, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the floating-point LMS filter structure. |
[in] | numTaps | number of filter coefficients. |
[in] | *pCoeffs | points to coefficient buffer. |
[in] | *pState | points to state buffer. |
[in] | mu | step size that controls filter coefficient updates. |
[in] | blockSize | number of samples to process. |
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}The initial filter coefficients serve as a starting point for the adaptive filter.
pState
points to an array of length numTaps+blockSize-1
samples, where blockSize
is the number of input samples processed by each call to arm_lms_norm_f32()
. References arm_lms_norm_instance_f32::energy, arm_lms_norm_instance_f32::mu, arm_lms_norm_instance_f32::numTaps, arm_lms_norm_instance_f32::pCoeffs, arm_lms_norm_instance_f32::pState, and arm_lms_norm_instance_f32::x0.
Referenced by main().
void arm_lms_norm_init_q15 | ( | arm_lms_norm_instance_q15 * | S, |
uint16_t | numTaps, | ||
q15_t * | pCoeffs, | ||
q15_t * | pState, | ||
q15_t | mu, | ||
uint32_t | blockSize, | ||
uint8_t | postShift | ||
) |
[in] | *S | points to an instance of the Q15 normalized LMS filter structure. |
[in] | numTaps | number of filter coefficients. |
[in] | *pCoeffs | points to coefficient buffer. |
[in] | *pState | points to state buffer. |
[in] | mu | step size that controls filter coefficient updates. |
[in] | blockSize | number of samples to process. |
[in] | postShift | bit shift applied to coefficients. |
Description:
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}The initial filter coefficients serve as a starting point for the adaptive filter.
pState
points to the array of state variables and size of array is numTaps+blockSize-1
samples, where blockSize
is the number of input samples processed by each call to arm_lms_norm_q15()
. References armRecipTableQ15, arm_lms_norm_instance_q15::energy, arm_lms_norm_instance_q15::mu, arm_lms_norm_instance_q15::numTaps, arm_lms_norm_instance_q15::pCoeffs, arm_lms_norm_instance_q15::postShift, arm_lms_norm_instance_q15::pState, arm_lms_norm_instance_q15::recipTable, and arm_lms_norm_instance_q15::x0.
void arm_lms_norm_init_q31 | ( | arm_lms_norm_instance_q31 * | S, |
uint16_t | numTaps, | ||
q31_t * | pCoeffs, | ||
q31_t * | pState, | ||
q31_t | mu, | ||
uint32_t | blockSize, | ||
uint8_t | postShift | ||
) |
[in] | *S | points to an instance of the Q31 normalized LMS filter structure. |
[in] | numTaps | number of filter coefficients. |
[in] | *pCoeffs | points to coefficient buffer. |
[in] | *pState | points to state buffer. |
[in] | mu | step size that controls filter coefficient updates. |
[in] | blockSize | number of samples to process. |
[in] | postShift | bit shift applied to coefficients. |
Description:
pCoeffs
points to the array of filter coefficients stored in time reversed order: {b[numTaps-1], b[numTaps-2], b[N-2], ..., b[1], b[0]}The initial filter coefficients serve as a starting point for the adaptive filter.
pState
points to an array of length numTaps+blockSize-1
samples, where blockSize
is the number of input samples processed by each call to arm_lms_norm_q31()
. References armRecipTableQ31, arm_lms_norm_instance_q31::energy, arm_lms_norm_instance_q31::mu, arm_lms_norm_instance_q31::numTaps, arm_lms_norm_instance_q31::pCoeffs, arm_lms_norm_instance_q31::postShift, arm_lms_norm_instance_q31::pState, arm_lms_norm_instance_q31::recipTable, and arm_lms_norm_instance_q31::x0.
void arm_lms_norm_q15 | ( | arm_lms_norm_instance_q15 * | S, |
q15_t * | pSrc, | ||
q15_t * | pRef, | ||
q15_t * | pOut, | ||
q15_t * | pErr, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the Q15 normalized LMS filter structure. |
[in] | *pSrc | points to the block of input data. |
[in] | *pRef | points to the block of reference data. |
[out] | *pOut | points to the block of output data. |
[out] | *pErr | points to the block of error data. |
[in] | blockSize | number of samples to process. |
Scaling and Overflow Behavior:
References __SIMD32, arm_recip_q15(), blockSize, DELTA_Q15, arm_lms_norm_instance_q15::energy, arm_lms_norm_instance_q15::mu, arm_lms_norm_instance_q15::numTaps, arm_lms_norm_instance_q15::pCoeffs, arm_lms_norm_instance_q15::postShift, arm_lms_norm_instance_q15::pState, arm_lms_norm_instance_q15::recipTable, and arm_lms_norm_instance_q15::x0.
void arm_lms_norm_q31 | ( | arm_lms_norm_instance_q31 * | S, |
q31_t * | pSrc, | ||
q31_t * | pRef, | ||
q31_t * | pOut, | ||
q31_t * | pErr, | ||
uint32_t | blockSize | ||
) |
[in] | *S | points to an instance of the Q31 normalized LMS filter structure. |
[in] | *pSrc | points to the block of input data. |
[in] | *pRef | points to the block of reference data. |
[out] | *pOut | points to the block of output data. |
[out] | *pErr | points to the block of error data. |
[in] | blockSize | number of samples to process. |
Scaling and Overflow Behavior:
References arm_recip_q31(), blockSize, clip_q63_to_q31(), DELTA_Q31, arm_lms_norm_instance_q31::energy, arm_lms_norm_instance_q31::mu, arm_lms_norm_instance_q31::numTaps, arm_lms_norm_instance_q31::pCoeffs, arm_lms_norm_instance_q31::postShift, arm_lms_norm_instance_q31::pState, arm_lms_norm_instance_q31::recipTable, and arm_lms_norm_instance_q31::x0.