diff --git a/lib/adaptive_dfe_impl.cc b/lib/adaptive_dfe_impl.cc index 5f9a2e9..73daeb0 100644 --- a/lib/adaptive_dfe_impl.cc +++ b/lib/adaptive_dfe_impl.cc @@ -232,10 +232,10 @@ bool adaptive_dfe_impl::start() GR_LOG_DEBUG(d_logger,str(boost::format("adaptive_dfe_impl::start() nB=%d nF=%d mu=%f alpha=%f") % _nB % _nF % _mu % _alpha)); _filter_update = lms::make(_mu); - // _filter_update = nlms::make(0.5); - // _filter_update = rls::make(0.001f, 0.999f); // not stable - // _filter_update = kalman_exp::make(1.0f, 0.999f); // too slow - // _filter_update = kalman_hsu::make(0.008f, 0.1f); // not stable + //_filter_update = nlms::make(0.5f, 1.0f); + //_filter_update = rls::make(0.001f, 0.9f); // not stable + //_filter_update = kalman_exp::make(1.0f, 0.9f); // too slow + // _filter_update = kalman_hsu::make(0.02f, 0.1f); // not stable return true; } bool adaptive_dfe_impl::stop() diff --git a/lib/kalman_exp.hpp b/lib/kalman_exp.hpp index e8f17d1..4628540 100644 --- a/lib/kalman_exp.hpp +++ b/lib/kalman_exp.hpp @@ -16,7 +16,6 @@ namespace digitalhf { class kalman_exp : public filter_update { public: - kalman_exp(float r, float lambda); virtual ~kalman_exp(); static sptr make(float r, float lambda); @@ -29,6 +28,8 @@ protected: void resize(size_t); private: + kalman_exp(float r, float lambda); + typedef std::vector > vec_type; float _lambda; float _r; diff --git a/lib/kalman_hsu.cc b/lib/kalman_hsu.cc index 2b21952..0d86186 100644 --- a/lib/kalman_hsu.cc +++ b/lib/kalman_hsu.cc @@ -3,7 +3,7 @@ #include #include "kalman_hsu.hpp" #include - +#include namespace gr { namespace digitalhf { @@ -92,8 +92,10 @@ gr_complex const* kalman_hsu::update(gr_complex const* beg, } } - for (unsigned i=0; i linear index } private: + kalman_hsu(float q, float e); + typedef std::vector > complex_vec_type; typedef std::vector > real_vec_type; float _q; diff --git a/lib/lms.hpp b/lib/lms.hpp index 6302408..57ff132 100644 --- a/lib/lms.hpp +++ b/lib/lms.hpp @@ -14,7 +14,6 @@ namespace digitalhf { class lms : public filter_update { public: - lms(float mu); virtual ~lms(); static sptr make(float mu); @@ -27,6 +26,8 @@ protected: void resize(size_t); private: + lms(float mu); + typedef std::vector > vec_type; float _mu; vec_type _gain; diff --git a/lib/nlms.cc b/lib/nlms.cc index a676009..bf3eee3 100644 --- a/lib/nlms.cc +++ b/lib/nlms.cc @@ -7,12 +7,13 @@ namespace gr { namespace digitalhf { -filter_update::sptr nlms::make(float mu) { - return filter_update::sptr(new nlms(mu)); +filter_update::sptr nlms::make(float mu, float delta) { + return filter_update::sptr(new nlms(mu, delta)); } -nlms::nlms(float mu) +nlms::nlms(float mu, float delta) : _mu(mu) + , _delta(delta) , _gain() , _tmp() , _t1() { @@ -35,21 +36,22 @@ void nlms::reset() { } gr_complex const* nlms::update(gr_complex const* beg, - gr_complex const* end) { + gr_complex const* end) { assert(end-beg > 0); size_t const n = end - beg; resize(n); volk_32fc_conjugate_32fc(&_tmp[0], beg, n); volk_32fc_magnitude_squared_32f(&_t1[0], beg, n); - float norm = 0.0f; + float norm = _delta; volk_32f_accumulator_s32f(&norm, &_t1[0], n); - volk_32f_s32f_multiply_32f((float*)&_gain[0], (float const*)&_tmp[0], _mu/norm, 2*n); + volk_32f_s32f_multiply_32f((float*)&_gain[0], (float const*)&_tmp[0], std::max(0.006f, _mu/norm), 2*n); return &_gain.front(); } void nlms::set_parameters(std::mapconst & p) { - _mu = p.at("mu"); + _mu = p.at("mu"); + _delta = p.at("delta"); } } // namespace digitalhf diff --git a/lib/nlms.hpp b/lib/nlms.hpp index 9e2a9ef..5b5e293 100644 --- a/lib/nlms.hpp +++ b/lib/nlms.hpp @@ -14,10 +14,9 @@ namespace digitalhf { class nlms : public filter_update { public: - nlms(float mu); virtual ~nlms(); - static sptr make(float mu); + static sptr make(float mu, float delta); virtual void reset(); virtual gr_complex const* update(gr_complex const*, gr_complex const*); @@ -27,9 +26,12 @@ protected: void resize(size_t); private: + nlms(float mu, float delta); + typedef std::vector > complex_vec_type; typedef std::vector > real_vec_type; float _mu; + float _delta; complex_vec_type _gain; complex_vec_type _tmp; real_vec_type _t1; diff --git a/lib/rls.cc b/lib/rls.cc index c5301d2..231f194 100644 --- a/lib/rls.cc +++ b/lib/rls.cc @@ -53,7 +53,7 @@ gr_complex const* rls::update(gr_complex const* beg, volk_32fc_x2_conjugate_dot_prod_32fc(&uPu, &_pu[0], beg, n); volk_32fc_conjugate_32fc(&_tmp[0], &_pu[0], n); - volk_32f_s32f_multiply_32f((float*)&_gain[0], (float const*)&_tmp[0], 1.0f/(_lambda + std::real(uPu)), 2*n); + volk_32f_s32f_multiply_32f((float*)&_gain[0], (float const*)&_tmp[0], 1.0f/(_lambda + std::real(uPu)/_lambda), 2*n); // volk_32fc_s32fc_multiply_32fc(&_gain[0], &_tmp[0], 1/(_lambda + uPu), n); for (unsigned i=0; i > vec_type; float _delta; float _lambda;