19 const gplib::rvec &Desired)
21 const int size = Input.size();
23 gplib::rvec wk1(size);
24 gplib::rvec wk2(size);
25 gplib::rvec wkm(filterlength);
26 double power = inner_prod(Input, Input);
28 std::fill_n(wkm.begin(), filterlength, 0.0);
31 wk2(size - 2) = Input(size - 1);
32 for (
int i = 1; i < size - 1; ++i)
35 wk2(i - 1) = Input(i);
37 for (
int j = 0; j < filterlength; ++j)
41 for (
int k = 0; k < (size - j - 1); ++k)
43 num += wk1(k) * wk2(k);
44 denom += wk1(k) * wk1(k) + wk2(k) * wk2(k);
48 for (
int k = 0; k < j; ++k)
52 if (j == filterlength - 1)
57 for (
int k = 0; k <= j; ++k)
59 for (
int k = 0; k < size - j - 2; ++k)
61 wk1(k) -= wkm(j) * wk2(k);
62 wk2(k) = wk2(k + 1) - wkm(j) * wk1(k + 1);
const gplib::rvec & GetWeights()
Return the current set of weights.
WienerInterpolator(const int filterlength)
The constructor needs to know the filterlength.
gplib::rvec & SetWeights()
Base class for least squares filter with a single output value.
virtual void AdaptFilter(const gplib::rvec &Input, const gplib::rvec &Desired)
Calculate the prediction coefficients, the contents of Desired are ignored, this function has to be i...
virtual ~WienerInterpolator()