Capsim Block Documentation
This star implements a simple LMS adaptive filter.
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | x | |
| 1 | float | z |
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | y |
| Num | Description | Type | Name | Default Value | |
|---|---|---|---|---|---|
| 0 | Filter order | int | N | 10 | |
| 1 | LMS gain constant | float | mu | 0.1 | |
| 2 | Flag: 0=estimate, 1=error | int | outputFlag | 0 |
| Num | Type | Name | Initial Value | Description |
|---|---|---|---|---|
| 0 | float* | x_P | ||
| 1 | float* | w_P |
int i;
int j;
float tmp1,tmp2;
float dhat;
float temp;
float error;
|
|---|
/*
* Allocate memory and return pointers for tapped delay line x_P and
* array containing impulse response samples, h_P.
*
*/
if( (x_P = (float*)calloc(N,sizeof(float))) == NULL ||
(w_P = (float*)calloc(N,sizeof(float))) == NULL ) {
fprintf(stderr,"lms: can't allocate work space\n");
return(4);
}
/*
* initialize the tapped delay line and weights to zero.
*
*/
for (i=0; i |
|---|
for(j = MIN_AVAIL(); j>0; j--) {
/*
* Shift input sample into tapped delay line
*/
IT_IN(0);
tmp2=x(0);
for(i=0; i |
|---|
free(x_P); free(w_P); |
|---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
Copyright (C) 1989-2002 XCAD Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
http://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/* lms.s */
/***********************************************************************
lms()
************************************************************************
This star implements a simple LMS adaptive filter.
Param:
1 - (int) N filter order.
2 - (float) LMS gain constant.
3- (int) Flag to output either estimate or error
|
|---|