GPLIB++
AMRLSCanceller.cpp
Go to the documentation of this file.
1 #include "AMRLSCanceller.h"
2 #include <algorithm>
3 
4 namespace ublas = boost::numeric::ublas;
5 
6 namespace gplib
7  {
8 
9  const double maxlambda = 1.0 - 1e-6;
10 
11  AMRLSCanceller::AMRLSCanceller(const int inputsize, const double MyDelta,
12  const double MyLambda, const double MyAlpha) :
13  RLSCanceller(inputsize, MyDelta, MyLambda), Lambdaplus(maxlambda),
14  Lambdaminus(MyLambda / 2.0), S(inputsize, inputsize), Psi(inputsize),
15  Alpha(MyAlpha), factor1(inputsize, inputsize), factor2(inputsize,
16  inputsize), I(inputsize)
17  {
18  std::fill_n(S.data().begin(), inputsize * inputsize, 0.0);
19  std::fill_n(Psi.begin(), inputsize, 0.0);
20  }
21 
23  {
24  }
25 
26  void AMRLSCanceller::AdaptFilter(const gplib::rvec &Input,
27  const gplib::rvec &Desired)
28  {
29  RLSCanceller::AdaptFilter(Input, Desired);
30  SetLambda(GetLambda() + Alpha * GetEpsilon()(0) * prec_inner_prod(Psi,
31  Input));
32  SetLambda(std::min(GetLambda(), Lambdaplus));
33  SetLambda(std::max(GetLambda(), Lambdaminus));
34 
35  factor1 = I - ublas::outer_prod(GetK(), Input);
36  factor2 = I - ublas::outer_prod(Input, GetK());
37  rmat temp1(ublas::prec_prod(factor1, S));
38  S = ublas::prec_prod(temp1, factor2);
39  S += ublas::outer_prod(GetK(), GetK());
40  S -= GetP();
41  S /= GetLambda();
42 
43  Psi = prec_prod(factor1, Psi) + prec_prod(S, Input) * GetEpsilon()(0);
44  }
45 
46  }
const gplib::rvec & GetEpsilon() const
Return the last estimation error.
const gplib::rvec & GetK()
Definition: RLSCanceller.h:33
AMRLSCanceller(const int inputsize, const double MyDelta, const double MyLambda, const double MyAlpha)
const double maxlambda
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)
Adapt the filter weights given the Input and Desired vectors.
void SetLambda(const double Mylambda)
Set the forgetting factor , usually .
Definition: RLSCanceller.h:39
Implements a recursive least-squares adaptive filter, as described in Haykin, p. 443.
Definition: RLSCanceller.h:16
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)
Adapt the filter weights given the Input and Desired vectors.
double GetLambda()
Get the current forgetting factor.
Definition: RLSCanceller.h:44
const gplib::rmat & GetP()
Definition: RLSCanceller.h:25