GPLIB++
RLSCanceller.cpp
Go to the documentation of this file.
1 #include "RLSCanceller.h"
2 
3 namespace ublas = boost::numeric::ublas;
4 
5 #include <boost/numeric/ublas/operation.hpp>
6 //#include <boost/numeric/bindings/atlas/cblas3.hpp>
7 //#include <boost/numeric/bindings/atlas/cblas2.hpp>
8 #include <iostream>
9 
10 namespace gplib
11  {
12 
13  //namespace atlas = boost::numeric::bindings::atlas;
14  RLSCanceller::RLSCanceller(const int inputsize) :
15  LSSOFilter(inputsize), delta(0.9999999), lambda(1), P(inputsize,
16  inputsize), pi(inputsize), k(inputsize)
17  {
18  P = 1. / delta * ublas::identity_matrix<double>(inputsize);
19  }
20 
21  RLSCanceller::RLSCanceller(const int inputsize, const double MyDelta,
22  const double MyLambda) :
23  LSSOFilter(inputsize), delta(MyDelta), lambda(MyLambda), P(inputsize,
24  inputsize), pi(inputsize), k(inputsize)
25  {
26  P = 1. / delta * ublas::identity_matrix<double>(inputsize);
27  }
28 
30  {
31  }
32 
33  void RLSCanceller::AdaptFilter(const gplib::rvec &Input,
34  const gplib::rvec &Desired)
35  {
36  SetEpsilon(Desired - GetFilterOutput());
37  ublas::axpy_prod(P,Input,pi,true);
38  //atlas::gemv(P, Input, pi);
39  k = pi / (lambda + ublas::prec_inner_prod(Input, pi));
40  SetWeights() += k * GetEpsilon()(0);
41  gplib::rmat temp1(P);
42  ublas::noalias(temp1) -= ublas::prec_prod(ublas::outer_prod(k,Input),P);
43  //gplib::rmat temp1(P);
44  //atlas::ger(k,Input,kiouter); // ublas::outer_prod(k,Input); has replaced this line
45  //gplib::rmat temp2(ublas::outer_prod(k, Input));
46 
47  //atlas::gemm(-1.0 / lambda, temp2, temp1, 1.0 / lambda, P);
48  P = temp1 / lambda;
49  }
50 
51  }
const gplib::rvec & GetEpsilon() const
Return the last estimation error.
void SetEpsilon(const gplib::rvec &MyEps)
Possibility for derived classes to set estimation error.
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)
Adapt the filter weights given the Input and Desired vectors.
const gplib::rvec & GetFilterOutput() const
Access to the last calculated output (not sure if needed)
gplib::rvec & SetWeights()
Definition: LSSOFilter.h:26
RLSCanceller(const int inputsize)
Base class for least squares filter with a single output value.
Definition: LSSOFilter.h:20