Initial import
git-svn-id: http://moon:8086/svn/software/trunk/libsrc/radio@1 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
// --------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "agc.h"
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// AGC
|
||||
// Scalar version
|
||||
// --------------------------------------------------------------
|
||||
void AGC_Init(agc_t *pObj, uint32_t windowLength, radio_float_t w_init)
|
||||
{
|
||||
pObj->w = w_init;
|
||||
SlidingMinMaxInit(&pObj->slMax, windowLength, (radio_float_t)1E12, 1);
|
||||
}
|
||||
|
||||
void AGC_Free(agc_t *pObj)
|
||||
{
|
||||
SlidingMinMaxFree(&pObj->slMax);
|
||||
}
|
||||
|
||||
void AGC_Process(agc_t *pObj, radio_float_t x, radio_float_t mu, radio_float_t target)
|
||||
{
|
||||
radio_float_t d2;
|
||||
radio_float_t e;
|
||||
|
||||
d2 = SlidingMinMaxProcess(&pObj->slMax, x);
|
||||
e = target - d2;
|
||||
pObj->w += mu*e*dabs(x);
|
||||
}
|
||||
|
||||
void AGC_Train(agc_t *pObj, radio_float_t e, radio_float_t mu)
|
||||
{
|
||||
pObj->w += mu*e;
|
||||
}
|
||||
|
||||
radio_float_t AGC_GetWeight(agc_t *pObj)
|
||||
{
|
||||
return pObj->w;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
Reference in New Issue
Block a user