11#ifndef INCLUDED_DIGITAL_CONSTELLATION_H
12#define INCLUDED_DIGITAL_CONSTELLATION_H
18#include <boost/any.hpp>
31typedef std::shared_ptr<constellation> constellation_sptr;
59 std::vector<int> pre_diff_code,
60 unsigned int rotational_symmetry,
61 unsigned int dimensionality,
88 std::vector<gr_complex>
points() {
return d_constellation; }
93 std::vector<std::vector<gr_complex>>
v_points();
109 return floor(log(
double(d_constellation.size())) / d_dimensionality / log(2.0));
112 unsigned int arity() {
return d_arity; }
114 constellation_sptr
base() {
return shared_from_this(); }
232 typedef std::shared_ptr<constellation_calcdist>
sptr;
249 std::vector<int> pre_diff_code,
250 unsigned int rotational_symmetry,
251 unsigned int dimensionality,
261 std::vector<int> pre_diff_code,
262 unsigned int rotational_symmetry,
263 unsigned int dimensionality,
297 std::vector<int> pre_diff_code,
298 unsigned int rotational_symmetry,
299 unsigned int dimensionality,
300 unsigned int n_sectors,
315 std::vector<int> sector_values;
339 typedef std::shared_ptr<constellation_rect>
sptr;
357 make(std::vector<gr_complex> constell,
358 std::vector<int> pre_diff_code,
359 unsigned int rotational_symmetry,
360 unsigned int real_sectors,
361 unsigned int imag_sectors,
362 float width_real_sectors,
363 float width_imag_sectors,
369 std::vector<int> pre_diff_code,
370 unsigned int rotational_symmetry,
371 unsigned int real_sectors,
372 unsigned int imag_sectors,
373 float width_real_sectors,
374 float width_imag_sectors,
382 unsigned int n_real_sectors;
383 unsigned int n_imag_sectors;
384 float d_width_real_sectors;
385 float d_width_imag_sectors;
413 typedef std::shared_ptr<constellation_expl_rect>
sptr;
416 std::vector<int> pre_diff_code,
417 unsigned int rotational_symmetry,
418 unsigned int real_sectors,
419 unsigned int imag_sectors,
420 float width_real_sectors,
421 float width_imag_sectors,
422 std::vector<unsigned int> sector_values);
427 std::vector<int> pre_diff_code,
428 unsigned int rotational_symmetry,
429 unsigned int real_sectors,
430 unsigned int imag_sectors,
431 float width_real_sectors,
432 float width_imag_sectors,
433 std::vector<unsigned int> sector_values);
437 return d_sector_values[sector];
441 std::vector<unsigned int> d_sector_values;
463 typedef std::shared_ptr<constellation_psk>
sptr;
467 std::vector<int> pre_diff_code,
468 unsigned int n_sectors);
478 std::vector<int> pre_diff_code,
479 unsigned int n_sectors);
502 typedef std::shared_ptr<constellation_bpsk>
sptr;
538 typedef std::shared_ptr<constellation_qpsk>
sptr;
573 typedef std::shared_ptr<constellation_dqpsk>
sptr;
610 typedef std::shared_ptr<constellation_8psk>
sptr;
646 typedef std::shared_ptr<constellation_8psk_natural>
sptr;
684 typedef std::shared_ptr<constellation_16qam>
sptr;
Digital constellation for 16qam.
Definition: constellation.h:682
std::shared_ptr< constellation_16qam > sptr
Definition: constellation.h:684
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
~constellation_16qam() override
Digital constellation for natually mapped 8PSK.
Definition: constellation.h:644
std::shared_ptr< constellation_8psk_natural > sptr
Definition: constellation.h:646
~constellation_8psk_natural() override
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
constellation_8psk_natural()
Digital constellation for 8PSK.
Definition: constellation.h:608
std::shared_ptr< constellation_8psk > sptr
Definition: constellation.h:610
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
~constellation_8psk() override
Digital constellation for BPSK .
Definition: constellation.h:500
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
~constellation_bpsk() override
std::shared_ptr< constellation_bpsk > sptr
Definition: constellation.h:502
Calculate Euclidean distance for any constellation.
Definition: constellation.h:230
std::shared_ptr< constellation_calcdist > sptr
Definition: constellation.h:232
constellation_calcdist(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int dimensionality, normalization_t normalization=AMPLITUDE_NORMALIZATION)
static sptr make(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int dimensionality, normalization_t normalization=AMPLITUDE_NORMALIZATION)
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
Digital constellation for DQPSK.
Definition: constellation.h:571
~constellation_dqpsk() override
std::shared_ptr< constellation_dqpsk > sptr
Definition: constellation.h:573
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
Rectangular digital constellation.
Definition: constellation.h:411
unsigned int calc_sector_value(unsigned int sector) override
Definition: constellation.h:435
static sptr make(std::vector< gr_complex > constellation, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors, std::vector< unsigned int > sector_values)
~constellation_expl_rect() override
constellation_expl_rect(std::vector< gr_complex > constellation, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors, std::vector< unsigned int > sector_values)
std::shared_ptr< constellation_expl_rect > sptr
Definition: constellation.h:413
constellation_psk
Definition: constellation.h:461
unsigned int get_sector(const gr_complex *sample) override
std::shared_ptr< constellation_psk > sptr
Definition: constellation.h:463
constellation_psk(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int n_sectors)
unsigned int calc_sector_value(unsigned int sector) override
~constellation_psk() override
static sptr make(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int n_sectors)
Digital constellation for QPSK.
Definition: constellation.h:536
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
std::shared_ptr< constellation_qpsk > sptr
Definition: constellation.h:538
~constellation_qpsk() override
Rectangular digital constellation.
Definition: constellation.h:337
unsigned int get_sector(const gr_complex *sample) override
~constellation_rect() override
std::shared_ptr< constellation_rect > sptr
Definition: constellation.h:339
unsigned int calc_sector_value(unsigned int sector) override
constellation_rect(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors, normalization_t normalization=AMPLITUDE_NORMALIZATION)
gr_complex calc_sector_center(unsigned int sector)
static constellation_rect::sptr make(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int real_sectors, unsigned int imag_sectors, float width_real_sectors, float width_imag_sectors, normalization_t normalization=AMPLITUDE_NORMALIZATION)
Sectorized digital constellation.
Definition: constellation.h:281
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
virtual unsigned int calc_sector_value(unsigned int sector)=0
~constellation_sector() override
unsigned int n_sectors
Definition: constellation.h:312
virtual unsigned int get_sector(const gr_complex *sample)=0
void find_sector_values()
constellation_sector(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int dimensionality, unsigned int n_sectors, normalization_t normalization=AMPLITUDE_NORMALIZATION)
An abstracted constellation object.
Definition: constellation.h:50
constellation_sptr base()
Definition: constellation.h:114
bool d_apply_pre_diff_code
Definition: constellation.h:196
virtual void calc_hard_symbol_metric(const gr_complex *sample, float *metric)
std::vector< gr_complex > d_constellation
Definition: constellation.h:194
bool has_soft_dec_lut()
Returns True if the soft decision LUT has been defined, False otherwise.
std::vector< int > d_pre_diff_code
Definition: constellation.h:195
virtual void calc_metric(const gr_complex *sample, float *metric, gr::digital::trellis_metric_type_t type)
Calculates distance.
pmt::pmt_t as_pmt()
Definition: constellation.h:116
unsigned int arity()
Definition: constellation.h:112
int d_lut_precision
Definition: constellation.h:206
std::vector< gr_complex > points()
Returns the set of points in this constellation.
Definition: constellation.h:88
float get_distance(unsigned int index, const gr_complex *sample)
void gen_soft_dec_lut(int precision, float npwr=1.0)
Generates the soft decision LUT based on constellation and symbol map.
float d_im_max
Definition: constellation.h:203
virtual std::vector< float > calc_soft_dec(gr_complex sample, float npwr=1.0)
Calculate soft decisions for the given sample.
virtual void calc_euclidean_metric(const gr_complex *sample, float *metric)
unsigned int rotational_symmetry()
Returns the order of rotational symmetry.
Definition: constellation.h:103
unsigned int decision_maker_v(std::vector< gr_complex > sample)
Takes a vector rather than a pointer. Better for SWIG wrapping.
constellation(std::vector< gr_complex > constell, std::vector< int > pre_diff_code, unsigned int rotational_symmetry, unsigned int dimensionality, normalization_t normalization=AMPLITUDE_NORMALIZATION)
normalization_t
Definition: constellation.h:52
@ POWER_NORMALIZATION
Definition: constellation.h:54
@ NO_NORMALIZATION
Definition: constellation.h:53
@ AMPLITUDE_NORMALIZATION
Definition: constellation.h:55
unsigned int d_rotational_symmetry
Definition: constellation.h:197
std::vector< std::vector< gr_complex > > v_points()
Returns a vector of vectors of points.
void set_soft_dec_lut(const std::vector< std::vector< float > > &soft_dec_lut, int precision)
Define a soft decision look-up table.
void set_pre_diff_code(bool a)
Whether to apply an encoding before doing differential encoding. (e.g. gray coding)
Definition: constellation.h:99
void map_to_points(unsigned int value, gr_complex *points)
Returns the constellation points for a symbol value.
std::vector< std::vector< float > > d_soft_dec_lut
Definition: constellation.h:205
unsigned int d_dimensionality
Definition: constellation.h:198
bool apply_pre_diff_code()
Whether to apply an encoding before doing differential encoding. (e.g. gray coding)
Definition: constellation.h:96
std::vector< gr_complex > s_points()
Returns the vector of points in this constellation. Raise error if dimensionality is not one.
unsigned int decision_maker_pe(const gr_complex *sample, float *phase_error)
Also calculates the phase error.
std::vector< float > soft_decision_maker(gr_complex sample)
Returns the soft decisions for the given sample.
unsigned int d_arity
Definition: constellation.h:199
unsigned int dimensionality()
Returns the number of complex numbers in a single symbol.
Definition: constellation.h:105
float d_lut_scale
Definition: constellation.h:207
float d_scalefactor
The factor by which the user given constellation points were scaled by to achieve an average amplitud...
Definition: constellation.h:202
unsigned int bits_per_symbol()
Definition: constellation.h:107
std::vector< std::vector< float > > soft_dec_lut()
virtual unsigned int decision_maker(const gr_complex *sample)=0
Returns the constellation point that matches best.
std::vector< int > pre_diff_code()
Returns the encoding to apply before differential encoding.
Definition: constellation.h:101
std::vector< gr_complex > map_to_points_v(unsigned int value)
unsigned int get_closest_point(const gr_complex *sample)
#define DIGITAL_API
Definition: gr-digital/include/gnuradio/digital/api.h:18
std::complex< float > gr_complex
Definition: gr_complex.h:15
trellis_metric_type_t
Definition: metric_type.h:17
GNU Radio logging wrapper.
Definition: basic_block.h:29
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83
PMT_API pmt_t make_any(const boost::any &any)
make an any