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

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

Loading...
Searching...
No Matches
adaptive_algorithm_cma.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_CMA_H
12#define INCLUDED_DIGITAL_ADAPTIVE_ALGORITHM_CMA_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 class DIGITAL_API adaptive_algorithm_cma : public adaptive_algorithm
21{
22public:
23 typedef std::shared_ptr<adaptive_algorithm_cma> sptr;
24
25private:
26 const float d_step_size;
27 const float d_modulus;
28
29protected:
30 adaptive_algorithm_cma(constellation_sptr cons, float step_size, float modulus)
31 : adaptive_algorithm(adaptive_algorithm_t::CMA, cons),
32 d_step_size(step_size),
33 d_modulus(modulus)
34 {
35 }
36
37public:
38 static sptr make(constellation_sptr cons, float step_size, float modulus)
39 {
40 return adaptive_algorithm_cma::sptr(
41 new adaptive_algorithm_cma(cons, step_size, modulus));
42 }
43
44 gr_complex error(const gr_complex& out) const
45 {
46 gr_complex error = out * (norm(out) - d_modulus);
47 float re = gr::clip(error.real(), 1.0);
48 float im = gr::clip(error.imag(), 1.0);
49 return gr_complex(re, im);
50 }
51
52 gr_complex error_dd(gr_complex& u_n, gr_complex& decision) const override
53 {
54 return error(u_n);
55 }
56
57 gr_complex error_tr(const gr_complex& u_n, const gr_complex& d_n) const override
58 {
59 return error(u_n);
60 }
61
62 void update_taps(gr_complex* taps,
63 const gr_complex* in,
64 const gr_complex error,
65 const gr_complex decision,
66 unsigned int num_taps) override
67 {
68 volk::vector<gr_complex> prod_vector(num_taps), conj_vector(num_taps);
69
70 gr_complex err_x_mu = -d_step_size * error;
71
72 volk_32fc_conjugate_32fc(conj_vector.data(), in, num_taps);
73#if VOLK_VERSION >= 030100
74 volk_32fc_s32fc_multiply2_32fc(
75 prod_vector.data(), conj_vector.data(), &err_x_mu, num_taps);
76#else
77 volk_32fc_s32fc_multiply_32fc(
78 prod_vector.data(), conj_vector.data(), err_x_mu, num_taps);
79#endif
80 volk_32fc_x2_add_32fc(taps, taps, prod_vector.data(), num_taps);
81 }
82
83 gr_complex update_tap(const gr_complex tap,
84 const gr_complex& u_n,
85 const gr_complex err,
86 const gr_complex decision) override
87 {
88 return conj(conj(tap) - d_step_size * u_n * conj(err));
89 }
90
91 ~adaptive_algorithm_cma() override {}
92};
93
94} // namespace digital
95} // namespace gr
96
97#endif
adaptive_algorithm.h
gr::digital::adaptive_algorithm_cma::adaptive_algorithm_cma
adaptive_algorithm_cma(constellation_sptr cons, float step_size, float modulus)
Definition adaptive_algorithm_cma.h:30
gr::digital::adaptive_algorithm_cma::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_cma.h:83
gr::digital::adaptive_algorithm_cma::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_cma.h:62
gr::digital::adaptive_algorithm_cma::sptr
std::shared_ptr< adaptive_algorithm_cma > sptr
Definition adaptive_algorithm_cma.h:23
gr::digital::adaptive_algorithm_cma::make
static sptr make(constellation_sptr cons, float step_size, float modulus)
Definition adaptive_algorithm_cma.h:38
gr::digital::adaptive_algorithm_cma::~adaptive_algorithm_cma
~adaptive_algorithm_cma() override
Definition adaptive_algorithm_cma.h:91
gr::digital::adaptive_algorithm_cma::error
gr_complex error(const gr_complex &out) const
Definition adaptive_algorithm_cma.h:44
gr::digital::adaptive_algorithm_cma::error_tr
gr_complex error_tr(const gr_complex &u_n, const gr_complex &d_n) const override
Definition adaptive_algorithm_cma.h:57
gr::digital::adaptive_algorithm_cma::error_dd
gr_complex error_dd(gr_complex &u_n, gr_complex &decision) const override
Definition adaptive_algorithm_cma.h:52
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::CMA
@ CMA
Definition adaptive_algorithm.h:23
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
gr::clip
static float clip(float x, float clip)
Definition math.h:82