GNU Radio C++ API Reference: adaptive_algorithm_lms.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
adaptive_algorithm_lms.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2020 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_DIGITAL_ADAPTIVE_ALGORITHM_LMS_H
12#define INCLUDED_DIGITAL_ADAPTIVE_ALGORITHM_LMS_H
13
14#include <gnuradio/digital/adaptive_algorithm.h>
15#include <volk/volk.h>
16#include <volk/volk_alloc.hh>
17
18namespace gr {
19namespace digital {
20
21 class DIGITAL_API adaptive_algorithm_lms : public adaptive_algorithm
22{
23public:
24 typedef std::shared_ptr<adaptive_algorithm_lms> sptr;
25
26private:
27 const float d_step_size;
28
29protected:
30 adaptive_algorithm_lms(constellation_sptr cons, float step_size)
31 : adaptive_algorithm(adaptive_algorithm_t::LMS, cons), d_step_size(step_size)
32 {
33 }
34
35public:
36 static sptr make(constellation_sptr cons, float step_size)
37 {
38 return adaptive_algorithm_lms::sptr(new adaptive_algorithm_lms(cons, step_size));
39 }
40
41 ~adaptive_algorithm_lms() override {}
42
43 void update_taps(gr_complex* taps,
44 const gr_complex* in,
45 const gr_complex error,
46 const gr_complex decision,
47 unsigned int num_taps) override
48 {
49 volk::vector<gr_complex> prod_vector(num_taps), conj_vector(num_taps);
50
51 gr_complex err_x_mu = d_step_size * error;
52
53 volk_32fc_conjugate_32fc(conj_vector.data(), in, num_taps);
54#if VOLK_VERSION >= 030100
55 volk_32fc_s32fc_multiply2_32fc(
56 prod_vector.data(), conj_vector.data(), &err_x_mu, num_taps);
57#else
58 volk_32fc_s32fc_multiply_32fc(
59 prod_vector.data(), conj_vector.data(), err_x_mu, num_taps);
60#endif
61 volk_32fc_x2_add_32fc(taps, taps, prod_vector.data(), num_taps);
62 }
63
64 gr_complex update_tap(const gr_complex tap,
65 const gr_complex& u_n,
66 const gr_complex err,
67 const gr_complex decision) override
68 {
69 return conj(conj(tap) + d_step_size * u_n * conj(err));
70 }
71
72 void initialize_taps(std::vector<gr_complex>& taps) override
73 {
74 std::fill(taps.begin(), taps.end(), gr_complex(0.0, 0.0));
75 }
76};
77
78} // namespace digital
79} // namespace gr
80
81#endif
adaptive_algorithm.h
gr::digital::adaptive_algorithm_lms::sptr
std::shared_ptr< adaptive_algorithm_lms > sptr
Definition adaptive_algorithm_lms.h:24
gr::digital::adaptive_algorithm_lms::adaptive_algorithm_lms
adaptive_algorithm_lms(constellation_sptr cons, float step_size)
Definition adaptive_algorithm_lms.h:30
gr::digital::adaptive_algorithm_lms::update_tap
gr_complex update_tap(const gr_complex tap, const gr_complex &u_n, const gr_complex err, const gr_complex decision) override
Definition adaptive_algorithm_lms.h:64
gr::digital::adaptive_algorithm_lms::make
static sptr make(constellation_sptr cons, float step_size)
Definition adaptive_algorithm_lms.h:36
gr::digital::adaptive_algorithm_lms::~adaptive_algorithm_lms
~adaptive_algorithm_lms() override
Definition adaptive_algorithm_lms.h:41
gr::digital::adaptive_algorithm_lms::initialize_taps
void initialize_taps(std::vector< gr_complex > &taps) override
Definition adaptive_algorithm_lms.h:72
gr::digital::adaptive_algorithm_lms::update_taps
void update_taps(gr_complex *taps, const gr_complex *in, const gr_complex error, const gr_complex decision, unsigned int num_taps) override
Definition adaptive_algorithm_lms.h:43
gr::digital::adaptive_algorithm::adaptive_algorithm
adaptive_algorithm(adaptive_algorithm_t alg_type, constellation_sptr cons)
Definition adaptive_algorithm.h:38
DIGITAL_API
#define DIGITAL_API
Definition gr-digital/include/gnuradio/digital/api.h:18
gr_complex
std::complex< float > gr_complex
Definition gr_complex.h:15
gr::digital
Definition adaptive_algorithm.h:22
gr::digital::adaptive_algorithm_t
adaptive_algorithm_t
Definition adaptive_algorithm.h:23
gr::digital::adaptive_algorithm_t::LMS
@ LMS
Definition adaptive_algorithm.h:23
gr
GNU Radio logging wrapper.
Definition basic_block.h:29