From 96d6da4e252b06dcfdc041e7df23e86161c33007 Mon Sep 17 00:00:00 2001 From: rihab kouki Date: Tue, 28 Jul 2020 11:24:49 +0100 Subject: Official ARM version: v5.6.0 --- docs/DSP/html/group__LMS.html | 177 +++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 95 deletions(-) (limited to 'docs/DSP/html/group__LMS.html') diff --git a/docs/DSP/html/group__LMS.html b/docs/DSP/html/group__LMS.html index 3e33b75..b2e329d 100644 --- a/docs/DSP/html/group__LMS.html +++ b/docs/DSP/html/group__LMS.html @@ -32,7 +32,7 @@ Logo
CMSIS-DSP -  Version 1.5.2 +  Version 1.7.0
CMSIS DSP Software Library
@@ -116,9 +116,9 @@ $(document).ready(function(){initNavTree('group__LMS.html','');}); - - - + + + @@ -128,12 +128,12 @@ Functions - - - - - - + + + + + +

Functions

void arm_lms_f32 (const arm_lms_instance_f32 *S, float32_t *pSrc, float32_t *pRef, float32_t *pOut, float32_t *pErr, uint32_t blockSize)
 Processing function for floating-point LMS filter. More...
 
void arm_lms_f32 (const arm_lms_instance_f32 *S, const float32_t *pSrc, float32_t *pRef, float32_t *pOut, float32_t *pErr, uint32_t blockSize)
 Processing function for floating-point LMS filter. More...
 
void arm_lms_init_f32 (arm_lms_instance_f32 *S, uint16_t numTaps, float32_t *pCoeffs, float32_t *pState, float32_t mu, uint32_t blockSize)
 Initialization function for floating-point LMS filter. More...
 
void arm_lms_init_q31 (arm_lms_instance_q31 *S, uint16_t numTaps, q31_t *pCoeffs, q31_t *pState, q31_t mu, uint32_t blockSize, uint32_t postShift)
 Initialization function for Q31 LMS filter. More...
 
void arm_lms_q15 (const arm_lms_instance_q15 *S, q15_t *pSrc, q15_t *pRef, q15_t *pOut, q15_t *pErr, uint32_t blockSize)
 Processing function for Q15 LMS filter. More...
 
void arm_lms_q31 (const arm_lms_instance_q31 *S, q31_t *pSrc, q31_t *pRef, q31_t *pOut, q31_t *pErr, uint32_t blockSize)
 Processing function for Q31 LMS filter. More...
 
void arm_lms_q15 (const arm_lms_instance_q15 *S, const q15_t *pSrc, q15_t *pRef, q15_t *pOut, q15_t *pErr, uint32_t blockSize)
 Processing function for Q15 LMS filter. More...
 
void arm_lms_q31 (const arm_lms_instance_q31 *S, const q31_t *pSrc, q31_t *pRef, q31_t *pOut, q31_t *pErr, uint32_t blockSize)
 Processing function for Q31 LMS filter. More...
 

Description

LMS filters are a class of adaptive filters that are able to "learn" an unknown transfer functions. LMS filters use a gradient descent method in which the filter coefficients are updated based on the instantaneous error signal. Adaptive filters are often used in communication systems, equalizers, and noise removal. The CMSIS DSP Library contains LMS filter functions that operate on Q15, Q31, and floating-point data types. The library also contains normalized LMS filters in which the filter coefficient adaptation is indepedent of the level of the input signal.

@@ -144,23 +144,23 @@ Functions Internal structure of the Least Mean Square filter

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.

-
Algorithm:
The output signal 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]
- 
+
Algorithm
The output signal 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]
+
The error signal equals the difference between the reference signal d[n] and the filter output:
-     e[n] = d[n] - y[n].
- 
+ e[n] = d[n] - y[n]. +
After each sample of the error signal is computed, the filter coefficients b[k] are updated on a sample-by-sample basis:
-     b[k] = b[k] + e[n] * mu * x[n-k],  for k=0, 1, ..., numTaps-1
- 
where mu is the step size and controls the rate of coefficient convergence.
+ b[k] = b[k] + e[n] * mu * x[n-k], for k=0, 1, ..., numTaps-1 + where mu is the step size and controls the rate of coefficient convergence.
In the APIs, 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]}
- 
+ {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]}
- 
+ {x[n-numTaps+1], x[n-numTaps], x[n-numTaps-1], x[n-numTaps-2]....x[0], x[1], ..., x[blockSize-1]} +
Note that the length of the state buffer exceeds the length of the coefficient array by 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.
Instance Structure
The coefficients and state variables for a filter are stored together in an instance data structure. A separate instance structure must be defined for each filter and coefficient and state arrays cannot be shared among instances. There are separate instance structure declarations for each of the 3 supported data types.
Initialization Functions
There is also an associated initialization function for each data type. The initialization function performs the following operations:
    @@ -169,19 +169,19 @@ Internal structure of the Least Mean Square filter
Use of the initialization function is optional. However, if the initialization function is used, then the instance structure cannot be placed into a const data section. To place an instance structure into a const data section, the instance structure must be manually initialized. Set the values in the state buffer to zeros before static initialization. The code below statically initializes each of the 3 different data type filter instance structures
-    arm_lms_instance_f32 S = {numTaps, pState, pCoeffs, mu};
-    arm_lms_instance_q31 S = {numTaps, pState, pCoeffs, mu, postShift};
-    arm_lms_instance_q15 S = {numTaps, pState, pCoeffs, mu, postShift};
- 
where numTaps is the number of filter coefficients in the filter; pState is the address of the state buffer; pCoeffs is the address of the coefficient buffer; mu is the step size parameter; and postShift is the shift applied to coefficients.
-
Fixed-Point Behavior:
Care must be taken when using the Q15 and Q31 versions of the LMS filter. The following issues must be considered:
    + arm_lms_instance_f32 S = {numTaps, pState, pCoeffs, mu}; + arm_lms_instance_q31 S = {numTaps, pState, pCoeffs, mu, postShift}; + arm_lms_instance_q15 S = {numTaps, pState, pCoeffs, mu, postShift}; + where numTaps is the number of filter coefficients in the filter; pState is the address of the state buffer; pCoeffs is the address of the coefficient buffer; mu is the step size parameter; and postShift is the shift applied to coefficients.
+
Fixed-Point Behavior
Care must be taken when using the Q15 and Q31 versions of the LMS filter. The following issues must be considered:
  • Scaling of coefficients
  • Overflow and saturation
-
Scaling of Coefficients:
Filter coefficients are represented as fractional values and coefficients are restricted to lie in the range [-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.
-
Overflow and Saturation:
Overflow and saturation behavior of the fixed-point Q15 and Q31 versions are described separately as part of the function specific documentation below.
+
Scaling of Coefficients
Filter coefficients are represented as fractional values and coefficients are restricted to lie in the range [-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.
+
Overflow and Saturation
Overflow and saturation behavior of the fixed-point Q15 and Q31 versions are described separately as part of the function specific documentation below.

Function Documentation

- +
@@ -194,7 +194,7 @@ Internal structure of the Least Mean Square filter - + @@ -228,21 +228,18 @@ Internal structure of the Least Mean Square filter
float32_tconst float32_t pSrc,
-

This function operates on floating-point data types.

Parameters
- - - - - - + + + + + +
[in]*Spoints to an instance of the floating-point LMS filter structure.
[in]*pSrcpoints to the block of input data.
[in]*pRefpoints to the block of reference data.
[out]*pOutpoints to the block of output data.
[out]*pErrpoints to the block of error data.
[in]blockSizenumber of samples to process.
[in]Spoints to an instance of the floating-point LMS filter structure
[in]pSrcpoints to the block of input data
[in]pRefpoints to the block of reference data
[out]pOutpoints to the block of output data
[out]pErrpoints to the block of error data
[in]blockSizenumber of samples to process
-
Returns
none.
- -

References blockSize, arm_lms_instance_f32::mu, arm_lms_instance_f32::numTaps, arm_lms_instance_f32::pCoeffs, and arm_lms_instance_f32::pState.

+
Returns
none
@@ -295,21 +292,19 @@ Internal structure of the Least Mean Square filter
Parameters
- - - - - - + + + + + +
[in]*Spoints to an instance of the floating-point LMS filter structure.
[in]numTapsnumber of filter coefficients.
[in]*pCoeffspoints to the coefficient buffer.
[in]*pStatepoints to state buffer.
[in]mustep size that controls filter coefficient updates.
[in]blockSizenumber of samples to process.
[in]Spoints to an instance of the floating-point LMS filter structure
[in]numTapsnumber of filter coefficients
[in]pCoeffspoints to coefficient buffer
[in]pStatepoints to state buffer
[in]mustep size that controls filter coefficient updates
[in]blockSizenumber of samples to process
-
Returns
none.
-
Description:
pCoeffs points to the array of filter coefficients stored in time reversed order:
+
Returns
none
+
Details
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_f32().
- -

References arm_lms_instance_f32::mu, arm_lms_instance_f32::numTaps, arm_lms_instance_f32::pCoeffs, and arm_lms_instance_f32::pState.

+
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_f32().
@@ -368,22 +363,20 @@ Internal structure of the Least Mean Square filter
Parameters
- + - - + +
[in]*Spoints to an instance of the Q15 LMS filter structure.
[in]Spoints to an instance of the Q15 LMS filter structure.
[in]numTapsnumber of filter coefficients.
[in]*pCoeffspoints to the coefficient buffer.
[in]*pStatepoints to the state buffer.
[in]pCoeffspoints to coefficient buffer.
[in]pStatepoints to state buffer.
[in]mustep size that controls filter coefficient updates.
[in]blockSizenumber of samples to process.
[in]postShiftbit shift applied to coefficients.
-
Returns
none.
-
Description:
pCoeffs points to the array of filter coefficients stored in time reversed order:
+
Returns
none
+
Details
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_q15().
- -

References arm_lms_instance_q15::mu, arm_lms_instance_q15::numTaps, arm_lms_instance_q15::pCoeffs, arm_lms_instance_q15::postShift, and arm_lms_instance_q15::pState.

+
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_q15().
@@ -442,26 +435,24 @@ Internal structure of the Least Mean Square filter
Parameters
- - - - - - - + + + + + + +
[in]*Spoints to an instance of the Q31 LMS filter structure.
[in]numTapsnumber of filter coefficients.
[in]*pCoeffspoints to coefficient buffer.
[in]*pStatepoints to state buffer.
[in]mustep size that controls filter coefficient updates.
[in]blockSizenumber of samples to process.
[in]postShiftbit shift applied to coefficients.
[in]Spoints to an instance of the Q31 LMS filter structure
[in]numTapsnumber of filter coefficients
[in]pCoeffspoints to coefficient buffer
[in]pStatepoints to state buffer
[in]mustep size that controls filter coefficient updates
[in]blockSizenumber of samples to process
[in]postShiftbit shift applied to coefficients
-
Returns
none.
-
Description:
pCoeffs points to the array of filter coefficients stored in time reversed order:
+
Returns
none
+
Details
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_q31().
- -

References arm_lms_instance_q31::mu, arm_lms_instance_q31::numTaps, arm_lms_instance_q31::pCoeffs, arm_lms_instance_q31::postShift, and arm_lms_instance_q31::pState.

+
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_q31().
- +
@@ -474,7 +465,7 @@ Internal structure of the Least Mean Square filter - + @@ -510,24 +501,22 @@ Internal structure of the Least Mean Square filter
Parameters
q15_tconst q15_t pSrc,
- - - - - - + + + + + +
[in]*Spoints to an instance of the Q15 LMS filter structure.
[in]*pSrcpoints to the block of input data.
[in]*pRefpoints to the block of reference data.
[out]*pOutpoints to the block of output data.
[out]*pErrpoints to the block of error data.
[in]blockSizenumber of samples to process.
[in]Spoints to an instance of the Q15 LMS filter structure
[in]pSrcpoints to the block of input data
[in]pRefpoints to the block of reference data
[out]pOutpoints to the block of output data
[out]pErrpoints to the block of error data
[in]blockSizenumber of samples to process
-
Returns
none.
-
Scaling and Overflow Behavior:
The function is implemented using a 64-bit internal accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format.
+
Returns
none
+
Scaling and Overflow Behavior
The function is implemented using an internal 64-bit accumulator. Both coefficients and state variables are represented in 1.15 format and multiplications yield a 2.30 result. The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. Lastly, the accumulator is saturated to yield a result in 1.15 format.
In this filter, filter coefficients are updated for each sample and the updation of filter cofficients are saturted.
-

References __SIMD32, __SMLALD(), blockSize, arm_lms_instance_q15::mu, arm_lms_instance_q15::numTaps, arm_lms_instance_q15::pCoeffs, arm_lms_instance_q15::postShift, and arm_lms_instance_q15::pState.

-
- +
@@ -540,7 +529,7 @@ Internal structure of the Least Mean Square filter - + @@ -576,21 +565,19 @@ Internal structure of the Least Mean Square filter
Parameters
q31_tconst q31_t pSrc,
- - - - - + + + + +
[in]*Spoints to an instance of the Q15 LMS filter structure.
[in]*pSrcpoints to the block of input data.
[in]*pRefpoints to the block of reference data.
[out]*pOutpoints to the block of output data.
[out]*pErrpoints to the block of error data.
[in]Spoints to an instance of the Q31 LMS filter structure.
[in]pSrcpoints to the block of input data.
[in]pRefpoints to the block of reference data.
[out]pOutpoints to the block of output data.
[out]pErrpoints to the block of error data.
[in]blockSizenumber of samples to process.
-
Returns
none.
-
Scaling and Overflow Behavior:
The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clips. In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. The reference signal should not be scaled down. After all multiply-accumulates are performed, the 2.62 accumulator is shifted and saturated to 1.31 format to yield the final result. The output signal and error signal are in 1.31 format.
+
Returns
none
+
Scaling and Overflow Behavior
The function is implemented using an internal 64-bit accumulator. The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. Thus, if the accumulator result overflows it wraps around rather than clips. In order to avoid overflows completely the input signal must be scaled down by log2(numTaps) bits. The reference signal should not be scaled down. After all multiply-accumulates are performed, the 2.62 accumulator is shifted and saturated to 1.31 format to yield the final result. The output signal and error signal are in 1.31 format.
In this filter, filter coefficients are updated for each sample and the updation of filter cofficients are saturted.
-

References blockSize, clip_q63_to_q31(), arm_lms_instance_q31::mu, arm_lms_instance_q31::numTaps, arm_lms_instance_q31::pCoeffs, arm_lms_instance_q31::postShift, and arm_lms_instance_q31::pState.

-
@@ -598,7 +585,7 @@ Internal structure of the Least Mean Square filter