Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "arm_math.h"
00025
00151 void arm_lms_norm_f32(
00152 arm_lms_norm_instance_f32 * S,
00153 float32_t * pSrc,
00154 float32_t * pRef,
00155 float32_t * pOut,
00156 float32_t * pErr,
00157 uint32_t blockSize)
00158 {
00159 float32_t *pState = S->pState;
00160 float32_t *pCoeffs = S->pCoeffs;
00161 float32_t *pStateCurnt;
00162 float32_t *px, *pb;
00163 float32_t mu = S->mu;
00164 uint32_t numTaps = S->numTaps;
00165 uint32_t tapCnt, blkCnt;
00166 float32_t energy;
00167 float32_t sum, e, d;
00168 float32_t w, x0, in;
00169 float32_t x1, x2;
00170 float32_t c0, c1;
00171
00172
00173 e = 0.0f;
00174 d = 0.0f;
00175 w = 0.0f;
00176
00177 energy = S->energy;
00178 x0 = S->x0;
00179
00180
00181
00182 pStateCurnt = &(S->pState[(numTaps - 1u)]);
00183
00184 blkCnt = blockSize;
00185
00186 while(blkCnt > 0u)
00187 {
00188
00189 *pStateCurnt++ = *pSrc;
00190
00191
00192 px = pState;
00193
00194
00195 pb = (pCoeffs);
00196
00197
00198 in = *pSrc++;
00199
00200
00201 energy -= x0 * x0;
00202 energy += in * in;
00203
00204
00205 sum = 0.0f;
00206
00207
00208 tapCnt = numTaps >> 2;
00209
00210 while(tapCnt > 0u)
00211 {
00212
00213
00214 x1 = *px;
00215 c0 = *pb++;
00216 x2 = *(px + 1u);
00217 c1 = *pb++;
00218
00219
00220 sum += x1 * c0;
00221 sum += x2 * c1;
00222
00223
00224 x1 = *(px + 2u);
00225 c0 = *pb++;
00226 x2 = *(px + 3u);
00227 c1 = *pb++;
00228
00229
00230 px += 4u;
00231
00232
00233 sum += x1 * c0;
00234 sum += x2 * c1;
00235
00236
00237 tapCnt--;
00238 }
00239
00240
00241 tapCnt = numTaps % 0x4u;
00242
00243 while(tapCnt > 0u)
00244 {
00245
00246 sum += (*px++) * (*pb++);
00247
00248
00249 tapCnt--;
00250 }
00251
00252
00253 *pOut++ = sum;
00254
00255
00256 d = (float32_t) (*pRef++);
00257 e = d - sum;
00258 *pErr++ = e;
00259
00260
00261
00262 w = (e * mu) / (energy + 0.000000119209289f);
00263
00264
00265 px = pState;
00266
00267
00268 pb = (pCoeffs);
00269
00270
00271 tapCnt = numTaps >> 2;
00272
00273
00274 while(tapCnt > 0u)
00275 {
00276
00277
00278
00279 x1 = *px;
00280 x2 = *(px + 1u);
00281 c0 = *pb;
00282 c1 = *(pb + 1u);
00283
00284
00285 c0 = c0 + x1 * w;
00286 c1 = c1 + x2 * w;
00287
00288
00289 *pb = c0;
00290 *(pb + 1u) = c1;
00291
00292
00293 x1 = *(px + 2u);
00294 x2 = *(px + 3u);
00295 c0 = *(pb + 2u);
00296 c1 = *(pb + 3u);
00297
00298
00299 c0 = c0 + x1 * w;
00300 c1 = c1 + x2 * w;
00301
00302
00303 *(pb + 2u) = c0;
00304 *(pb + 3u) = c1;
00305
00306
00307 px += 4u;
00308 pb += 4u;
00309
00310
00311 tapCnt--;
00312 }
00313
00314
00315 tapCnt = numTaps % 0x4u;
00316
00317 while(tapCnt > 0u)
00318 {
00319
00320 *pb += w * (*px++);
00321 pb++;
00322
00323
00324 tapCnt--;
00325 }
00326
00327 x0 = *pState;
00328
00329
00330 pState = pState + 1;
00331
00332
00333 blkCnt--;
00334 }
00335
00336 S->energy = energy;
00337 S->x0 = x0;
00338
00339
00340
00341
00342
00343
00344 pStateCurnt = S->pState;
00345
00346
00347 tapCnt = (numTaps - 1u) >> 2u;
00348
00349
00350 while(tapCnt > 0u)
00351 {
00352 *pStateCurnt++ = *pState++;
00353 *pStateCurnt++ = *pState++;
00354 *pStateCurnt++ = *pState++;
00355 *pStateCurnt++ = *pState++;
00356
00357
00358 tapCnt--;
00359 }
00360
00361
00362 tapCnt = (numTaps - 1u) % 0x4u;
00363
00364
00365 while(tapCnt > 0u)
00366 {
00367 *pStateCurnt++ = *pState++;
00368
00369
00370 tapCnt--;
00371 }
00372
00373
00374 }
00375