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

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

Loading...
Searching...
No Matches
adaptive_algorithm_nlms.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_NLMS_H
12#define INCLUDED_DIGITAL_ADAPTIVE_ALGORITHM_NLMS_H
13
14#include <gnuradio/digital/adaptive_algorithm.h>
15#include <volk/volk.h>
16
17namespace gr {
18namespace digital {
19
20 class DIGITAL_API adaptive_algorithm_nlms : public adaptive_algorithm
21{
22public:
23 typedef std::shared_ptr<adaptive_algorithm_nlms> sptr;
24
25private:
26 const float d_step_size;
27
28protected:
29 adaptive_algorithm_nlms(constellation_sptr cons, float step_size)
30 : adaptive_algorithm(adaptive_algorithm_t::NLMS, cons), d_step_size(step_size)
31 {
32 }
33
34public:
35 static sptr make(constellation_sptr cons, float step_size)
36 {
37 return adaptive_algorithm_nlms::sptr(
38 new adaptive_algorithm_nlms(cons, step_size));
39 }
40
41 gr_complex update_tap(const gr_complex tap,
42 const gr_complex& in,
43 const gr_complex error,
44 const gr_complex decision) override
45 {
46 throw std::runtime_error(
47 "NLMS can only update all taps at once, single tap update is not valid");
48 }
49
50 void update_taps(gr_complex* taps,
51 const gr_complex* in,
52 const gr_complex error,
53 const gr_complex decision,
54 unsigned int num_taps) override
55 {
56 gr_complex dp;
57 volk_32fc_x2_conjugate_dot_prod_32fc(&dp, in, in, num_taps);
58 float magsq = real(dp);
59 float norm_step_size = d_step_size / magsq;
60
61 for (unsigned i = 0; i < num_taps; i++) {
62 taps[i] = conj(conj(taps[i]) + norm_step_size * in[i] * conj(error));
63 }
64 }
65
66 ~adaptive_algorithm_nlms() override {}
67
68 void initialize_taps(std::vector<gr_complex>& taps) override
69 {
70 std::fill(taps.begin(), taps.end(), gr_complex(0.0, 0.0));
71 }
72};
73
74} // namespace digital
75} // namespace gr
76
77#endif
adaptive_algorithm.h
gr::digital::adaptive_algorithm_nlms::~adaptive_algorithm_nlms
~adaptive_algorithm_nlms() override
Definition adaptive_algorithm_nlms.h:66
gr::digital::adaptive_algorithm_nlms::make
static sptr make(constellation_sptr cons, float step_size)
Definition adaptive_algorithm_nlms.h:35
gr::digital::adaptive_algorithm_nlms::adaptive_algorithm_nlms
adaptive_algorithm_nlms(constellation_sptr cons, float step_size)
Definition adaptive_algorithm_nlms.h:29
gr::digital::adaptive_algorithm_nlms::update_tap
gr_complex update_tap(const gr_complex tap, const gr_complex &in, const gr_complex error, const gr_complex decision) override
Definition adaptive_algorithm_nlms.h:41
gr::digital::adaptive_algorithm_nlms::initialize_taps
void initialize_taps(std::vector< gr_complex > &taps) override
Definition adaptive_algorithm_nlms.h:68
gr::digital::adaptive_algorithm_nlms::sptr
std::shared_ptr< adaptive_algorithm_nlms > sptr
Definition adaptive_algorithm_nlms.h:23
gr::digital::adaptive_algorithm_nlms::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_nlms.h:50
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::NLMS
@ NLMS
Definition adaptive_algorithm.h:23
gr
GNU Radio logging wrapper.
Definition basic_block.h:29