Loading...
Searching...
No Matches
adaptive_algorithm_cma.h
Go to the documentation of this file.
/* -*- c++ -*- */
/*
* Copyright 2020 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifndef INCLUDED_DIGITAL_ADAPTIVE_ALGORITHM_CMA_H
#define INCLUDED_DIGITAL_ADAPTIVE_ALGORITHM_CMA_H
#include <gnuradio/digital/adaptive_algorithm.h>
#include <volk/volk.h>
#include <volk/volk_alloc.hh>
namespace gr {
namespace digital {
class DIGITAL_API adaptive_algorithm_cma : public adaptive_algorithm
{
public:
typedef std::shared_ptr<adaptive_algorithm_cma> sptr;
private:
const float d_step_size;
const float d_modulus;
protected:
adaptive_algorithm_cma(constellation_sptr cons, float step_size, float modulus)
: adaptive_algorithm(adaptive_algorithm_t::CMA, cons),
d_step_size(step_size),
d_modulus(modulus)
{
}
public:
static sptr make(constellation_sptr cons, float step_size, float modulus)
{
return adaptive_algorithm_cma::sptr(
new adaptive_algorithm_cma(cons, step_size, modulus));
}
gr_complex error(const gr_complex& out) const
{
gr_complex error = out * (norm(out) - d_modulus);
float re = gr::clip(error.real(), 1.0);
float im = gr::clip(error.imag(), 1.0);
return gr_complex(re, im);
}
gr_complex error_dd(gr_complex& u_n, gr_complex& decision) const override
{
return error(u_n);
}
gr_complex error_tr(const gr_complex& u_n, const gr_complex& d_n) const override
{
return error(u_n);
}
void update_taps(gr_complex* taps,
const gr_complex* in,
const gr_complex error,
const gr_complex decision,
unsigned int num_taps) override
{
volk::vector<gr_complex> prod_vector(num_taps), conj_vector(num_taps);
gr_complex err_x_mu = -d_step_size * error;
volk_32fc_conjugate_32fc(conj_vector.data(), in, num_taps);
#if VOLK_VERSION >= 030100
volk_32fc_s32fc_multiply2_32fc(
prod_vector.data(), conj_vector.data(), &err_x_mu, num_taps);
#else
volk_32fc_s32fc_multiply_32fc(
prod_vector.data(), conj_vector.data(), err_x_mu, num_taps);
#endif
volk_32fc_x2_add_32fc(taps, taps, prod_vector.data(), num_taps);
}
gr_complex update_tap(const gr_complex tap,
const gr_complex& u_n,
const gr_complex err,
const gr_complex decision) override
{
return conj(conj(tap) - d_step_size * u_n * conj(err));
}
~adaptive_algorithm_cma() override {}
};
} // namespace digital
} // namespace gr
#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
taps
static constexpr float taps[NSTEPS+1][NTAPS]
Definition interpolator_taps.h:9
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