GNU Radio Manual and C++ API Reference 3.10.5.1
The Free & Open Software Radio Ecosystem
constellation.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2010-2012 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_CONSTELLATION_H
12#define INCLUDED_DIGITAL_CONSTELLATION_H
13
16#include <gnuradio/gr_complex.h>
17#include <pmt/pmt.h>
18#include <boost/any.hpp>
19#include <vector>
20
21namespace gr {
22namespace digital {
23
24/************************************************************/
25/* constellation */
26/* */
27/* Base class defining interface. */
28/************************************************************/
29
30class constellation;
31typedef std::shared_ptr<constellation> constellation_sptr;
32
33/*!
34 * \brief An abstracted constellation object
35 * \ingroup symbol_coding_blk
36 *
37 * \details
38 * The constellation objects hold the necessary information to pass
39 * around constellation information for modulators and
40 * demodulators. These objects contain the mapping between the bits
41 * and the constellation points used to represent them as well as
42 * methods for slicing the symbol space. Various implementations are
43 * possible for efficiency and ease of use.
44 *
45 * Standard constellations (BPSK, QPSK, QAM, etc) can be inherited
46 * from this class and overloaded to perform optimized slicing and
47 * constellation mappings.
48 */
49class DIGITAL_API constellation : public std::enable_shared_from_this<constellation>
50{
51public:
56 };
57
58 constellation(std::vector<gr_complex> constell,
59 std::vector<int> pre_diff_code,
60 unsigned int rotational_symmetry,
61 unsigned int dimensionality,
62 normalization_t normalization = AMPLITUDE_NORMALIZATION);
64 virtual ~constellation();
65
66 //! Returns the constellation points for a symbol value
67 void map_to_points(unsigned int value, gr_complex* points);
68 std::vector<gr_complex> map_to_points_v(unsigned int value);
69
70 //! Returns the constellation point that matches best.
71 virtual unsigned int decision_maker(const gr_complex* sample) = 0;
72 //! Takes a vector rather than a pointer. Better for SWIG wrapping.
73 unsigned int decision_maker_v(std::vector<gr_complex> sample);
74 //! Also calculates the phase error.
75 unsigned int decision_maker_pe(const gr_complex* sample, float* phase_error);
76 //! Calculates distance.
77 // unsigned int decision_maker_e(const gr_complex *sample, float *error);
78
79 //! Calculates metrics for all points in the constellation.
80 //! For use with the viterbi algorithm.
81 virtual void calc_metric(const gr_complex* sample,
82 float* metric,
84 virtual void calc_euclidean_metric(const gr_complex* sample, float* metric);
85 virtual void calc_hard_symbol_metric(const gr_complex* sample, float* metric);
86
87 //! Returns the set of points in this constellation.
88 std::vector<gr_complex> points() { return d_constellation; }
89 //! Returns the vector of points in this constellation.
90 //! Raise error if dimensionality is not one.
91 std::vector<gr_complex> s_points();
92 //! Returns a vector of vectors of points.
93 std::vector<std::vector<gr_complex>> v_points();
94 //! Whether to apply an encoding before doing differential encoding. (e.g. gray
95 //! coding)
96 bool apply_pre_diff_code() { return d_apply_pre_diff_code; }
97 //! Whether to apply an encoding before doing differential encoding. (e.g. gray
98 //! coding)
99 void set_pre_diff_code(bool a) { d_apply_pre_diff_code = a; }
100 //! Returns the encoding to apply before differential encoding.
101 std::vector<int> pre_diff_code() { return d_pre_diff_code; }
102 //! Returns the order of rotational symmetry.
103 unsigned int rotational_symmetry() { return d_rotational_symmetry; }
104 //! Returns the number of complex numbers in a single symbol.
105 unsigned int dimensionality() { return d_dimensionality; }
106
107 unsigned int bits_per_symbol()
108 {
109 return floor(log(double(d_constellation.size())) / d_dimensionality / log(2.0));
110 }
111
112 unsigned int arity() { return d_arity; }
113
114 constellation_sptr base() { return shared_from_this(); }
115
116 pmt::pmt_t as_pmt() { return pmt::make_any(boost::any(base())); }
117
118 /*! \brief Generates the soft decision LUT based on
119 * constellation and symbol map.
120 *
121 * \details Generates the soft decision LUT based on
122 * constellation and symbol map. It can be given a estimate of
123 * the noise power in the channel as \p npwr.
124 *
125 * \param precision Number of bits of precision on each axis.
126 * \param npwr Estimate of the noise power (if known).
127 *
128 * This is expensive to compute.
129 */
130 void gen_soft_dec_lut(int precision, float npwr = 1.0);
131
132 /*! \brief Calculate soft decisions for the given \p sample.
133 *
134 * \details Calculate the soft decisions from the given \p sample
135 * at the given noise power \p npwr.
136 *
137 * This is a very costly algorithm (especially for higher order
138 * modulations) and should be used sparingly. It uses the
139 * #gen_soft_dec_lut function to generate the LUT, which
140 * should be done once or if a large change in the noise floor
141 * is detected.
142 *
143 * Instead of using this function, generate the LUT using the
144 * #gen_soft_dec_lut after creating the constellation object
145 * and then use the #soft_decision_maker function to return the
146 * answer from the LUT.
147 *
148 * \param sample The complex sample to get the soft decisions.
149 * \param npwr Estimate of the noise power (if known).
150 */
151 virtual std::vector<float> calc_soft_dec(gr_complex sample, float npwr = 1.0);
152
153 /*! \brief Define a soft decision look-up table.
154 *
155 * \details Define a soft decision look-up table (LUT). Because
156 * soft decisions can be calculated in various ways with various
157 * levels of accuracy and complexity, this function allows
158 * users to create a LUT in their own way.
159 *
160 * Setting the LUT here means that #has_soft_dec_lut will return
161 * true. Decision vectors returned by #soft_decision_maker will
162 * be calculated using this LUT.
163 *
164 * \param soft_dec_lut The soft decision LUT as a vector of
165 * tuples (vectors in C++) of soft decisions. Each
166 * element of the LUT is a vector of k-bit floats (where
167 * there are k bits/sample in the constellation).
168 * \param precision The number of bits of precision used when
169 * generating the LUT.
170 */
171 void set_soft_dec_lut(const std::vector<std::vector<float>>& soft_dec_lut,
172 int precision);
173
174 //! Returns True if the soft decision LUT has been defined, False otherwise.
176
177
178 std::vector<std::vector<float>> soft_dec_lut();
179
180
181 /*! \brief Returns the soft decisions for the given \p sample.
182 *
183 * \details Returns the soft decisions for the given \p
184 * sample. If a LUT is defined for the object, the decisions
185 * will be calculated from there. Otherwise, this function will
186 * call calc_soft_dec directly to calculate the soft decisions.
187 *
188 * \param sample The complex sample to get the soft decisions.
189 */
190 std::vector<float> soft_decision_maker(gr_complex sample);
191
192
193protected:
194 std::vector<gr_complex> d_constellation;
195 std::vector<int> d_pre_diff_code;
198 unsigned int d_dimensionality;
199 unsigned int d_arity;
200 //! The factor by which the user given constellation points were
201 //! scaled by to achieve an average amplitude of 1.
203 float d_re_min, d_re_max, d_im_min, d_im_max;
204
205 std::vector<std::vector<float>> d_soft_dec_lut;
208
209 float get_distance(unsigned int index, const gr_complex* sample);
210 unsigned int get_closest_point(const gr_complex* sample);
212
214};
215
216/************************************************************/
217/* constellation_calcdist */
218/* */
219/************************************************************/
220
221/*! \brief Calculate Euclidean distance for any constellation
222 * \ingroup digital
223 *
224 * \details
225 * Constellation which calculates the distance to each point in the
226 * constellation for decision making. Inefficient for large
227 * constellations.
228 */
230{
231public:
232 typedef std::shared_ptr<constellation_calcdist> sptr;
233
234 /*!
235 * Make a general constellation object that calculates the Euclidean distance for hard
236 * decisions.
237 *
238 * \param constell List of constellation points (order of list matches pre_diff_code)
239 * \param pre_diff_code List of alphabet symbols (before applying any differential
240 * coding) (order of list matches constell)
241 * \param rotational_symmetry Number of rotations around unit circle that have the
242 * same representation.
243 * \param dimensionality Number of dimensions to the constellation.
244 * \param normalization Use AMPLITUDE_NORMALIZATION to normalize points to
245 * mean(abs(points))=1 (default), POWER_NORMALIZATION to normalize points
246 * to mean(abs(points)^2)=1 or NO_NORMALIZATION to keep the original amplitude.
247 */
248 static sptr make(std::vector<gr_complex> constell,
249 std::vector<int> pre_diff_code,
250 unsigned int rotational_symmetry,
251 unsigned int dimensionality,
252 normalization_t normalization = AMPLITUDE_NORMALIZATION);
253
254 unsigned int decision_maker(const gr_complex* sample) override;
255 // void calc_metric(gr_complex *sample, float *metric, trellis_metric_type_t type);
256 // void calc_euclidean_metric(gr_complex *sample, float *metric);
257 // void calc_hard_symbol_metric(gr_complex *sample, float *metric);
258
259protected:
260 constellation_calcdist(std::vector<gr_complex> constell,
261 std::vector<int> pre_diff_code,
262 unsigned int rotational_symmetry,
263 unsigned int dimensionality,
264 normalization_t normalization = AMPLITUDE_NORMALIZATION);
265};
266
267
268/************************************************************/
269/*! constellation_sector */
270/************************************************************/
271
272/*!
273 * \brief Sectorized digital constellation
274 * \ingroup digital
275 *
276 * \details
277 * Constellation space is divided into sectors. Each sector is
278 * associated with the nearest constellation point.
279 */
281{
282public:
283 /*!
284 * Make a sectorized constellation object.
285 *
286 * \param constell List of constellation points (order of list matches pre_diff_code)
287 * \param pre_diff_code List of alphabet symbols (before applying any differential
288 * coding) (order of list matches constell)
289 * \param rotational_symmetry Number of rotations around unit circle that have the
290 * same representation. \param dimensionality Number of z-axis dimensions to the
291 * constellation \param n_sectors Number of sectors in the constellation.
292 * \param normalization Use AMPLITUDE_NORMALIZATION to normalize points to
293 * mean(abs(points))=1 (default), POWER_NORMALIZATION to normalize points
294 * to mean(abs(points)^2)=1 or NO_NORMALIZATION to keep the original amplitude.
295 */
296 constellation_sector(std::vector<gr_complex> constell,
297 std::vector<int> pre_diff_code,
298 unsigned int rotational_symmetry,
299 unsigned int dimensionality,
300 unsigned int n_sectors,
301 normalization_t normalization = AMPLITUDE_NORMALIZATION);
302
304
305 unsigned int decision_maker(const gr_complex* sample) override;
306
307protected:
308 virtual unsigned int get_sector(const gr_complex* sample) = 0;
309 virtual unsigned int calc_sector_value(unsigned int sector) = 0;
311
312 unsigned int n_sectors;
313
314private:
315 std::vector<int> sector_values;
316};
317
318/************************************************************/
319/* constellation_rect */
320/************************************************************/
321
322/*!
323 * \brief Rectangular digital constellation
324 * \ingroup digital
325 *
326 * Only implemented for 1-(complex)dimensional constellation.
327 *
328 * Constellation space is divided into rectangular sectors. Each
329 * sector is associated with the nearest constellation point.
330 *
331 * Works well for square QAM.
332 *
333 * Works for any generic constellation provided sectors are not
334 * too large.
335 */
337{
338public:
339 typedef std::shared_ptr<constellation_rect> sptr;
340
341 /*!
342 * Make a rectangular constellation object.
343 *
344 * \param constell List of constellation points (order of list matches pre_diff_code)
345 * \param pre_diff_code List of alphabet symbols (before applying any differential
346 * coding) (order of list matches constell)
347 * \param rotational_symmetry Number of rotations around unit circle that have the
348 * same representation. \param real_sectors Number of sectors the real axis is split
349 * in to. \param imag_sectors Number of sectors the imag axis is split in to. \param
350 * width_real_sectors width of each real sector to calculate decision boundaries.
351 * \param width_imag_sectors width of each imag sector to calculate decision
352 * boundaries. \param normalization Use AMPLITUDE_NORMALIZATION to normalize points
353 * to mean(abs(points))=1 (default), POWER_NORMALIZATION to normalize points to
354 * mean(abs(points)^2)=1 or NO_NORMALIZATION to keep the original amplitude.
355 */
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,
364 normalization_t normalization = AMPLITUDE_NORMALIZATION);
366
367protected:
368 constellation_rect(std::vector<gr_complex> constell,
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,
375 normalization_t normalization = AMPLITUDE_NORMALIZATION);
376
377 unsigned int get_sector(const gr_complex* sample) override;
378 gr_complex calc_sector_center(unsigned int sector);
379 unsigned int calc_sector_value(unsigned int sector) override;
380
381private:
382 unsigned int n_real_sectors;
383 unsigned int n_imag_sectors;
384 float d_width_real_sectors;
385 float d_width_imag_sectors;
386};
387
388
389/************************************************************/
390/* constellation_expl_rect */
391/************************************************************/
392
393/*!
394 * \brief Rectangular digital constellation.
395 * \ingroup digital
396 *
397 * \details
398 * Only implemented for 1-(complex)dimensional constellation.
399 *
400 * Constellation space is divided into rectangular sectors. Each
401 * sector is associated with the nearest constellation point.
402 *
403 * This class is different from constellation_rect in that the
404 * mapping from sector to constellation point is explicitly passed
405 * into the constructor as sector_values. Usually we do not need
406 * this, since we want each sector to be automatically mapped to
407 * the closest constellation point, however sometimes it's nice to
408 * have the flexibility.
409 */
411{
412public:
413 typedef std::shared_ptr<constellation_expl_rect> sptr;
414
415 static sptr make(std::vector<gr_complex> constellation,
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);
424
425protected:
426 constellation_expl_rect(std::vector<gr_complex> constellation,
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);
434
435 unsigned int calc_sector_value(unsigned int sector) override
436 {
437 return d_sector_values[sector];
438 }
439
440private:
441 std::vector<unsigned int> d_sector_values;
442};
443
444/************************************************************/
445/* constellation_psk */
446/************************************************************/
447
448/*!
449 * \brief constellation_psk
450 * \ingroup digital
451 *
452 * Constellation space is divided into pie slices sectors.
453 *
454 * Each slice is associated with the nearest constellation point.
455 *
456 * Works well for PSK but nothing else.
457 *
458 * Assumes that there is a constellation point at 1.x
459 */
461{
462public:
463 typedef std::shared_ptr<constellation_psk> sptr;
464
465 // public constructor
466 static sptr make(std::vector<gr_complex> constell,
467 std::vector<int> pre_diff_code,
468 unsigned int n_sectors);
469
471
472protected:
473 unsigned int get_sector(const gr_complex* sample) override;
474
475 unsigned int calc_sector_value(unsigned int sector) override;
476
477 constellation_psk(std::vector<gr_complex> constell,
478 std::vector<int> pre_diff_code,
479 unsigned int n_sectors);
480};
481
482
483/************************************************************/
484/* constellation_bpsk */
485/* */
486/* Only works for BPSK. */
487/* */
488/************************************************************/
489
490/*!
491 * \brief Digital constellation for BPSK .
492 * \ingroup digital
493 *
494 * \details
495 * \verbatim
496 0 | 1
497 \endverbatim
498 */
500{
501public:
502 typedef std::shared_ptr<constellation_bpsk> sptr;
503
504 // public constructor
505 static sptr make();
506
508
509 unsigned int decision_maker(const gr_complex* sample) override;
510
511protected:
513};
514
515
516/************************************************************/
517/* constellation_qpsk */
518/* */
519/* Only works for QPSK. */
520/* */
521/************************************************************/
522
523/*!
524 * \brief Digital constellation for QPSK
525 * \ingroup digital
526 *
527 * \details Constellation diagram assumes little endian format e.g. top, left means 2
528 not 1.
529 * \verbatim
530 01 | 11
531 -------
532 00 | 10
533 \endverbatim
534 */
536{
537public:
538 typedef std::shared_ptr<constellation_qpsk> sptr;
539
540 // public constructor
541 static sptr make();
542
544
545 unsigned int decision_maker(const gr_complex* sample) override;
546
547protected:
549};
550
551
552/************************************************************/
553/* constellation_dqpsk */
554/* */
555/* Works with differential encoding; slower decisions. */
556/* */
557/************************************************************/
558
559/*!
560 * \brief Digital constellation for DQPSK.
561 * \ingroup digital
562 *
563 * \details
564 * \verbatim
565 01 | 00
566 -------
567 11 | 10
568 \endverbatim
569 */
571{
572public:
573 typedef std::shared_ptr<constellation_dqpsk> sptr;
574
575 // public constructor
576 static sptr make();
577
579
580 unsigned int decision_maker(const gr_complex* sample) override;
581
582protected:
584};
585
586
587/************************************************************/
588/* constellation_8psk */
589/* */
590/* Only works for 8PSK. */
591/* */
592/************************************************************/
593
594/*!
595 * \brief Digital constellation for 8PSK.
596 * \ingroup digital
597 *
598 * \details
599 * \verbatim
600 101 | 100
601 001 | 000
602 -----------------
603 011 | 010
604 111 | 110
605 \endverbatim
606 */
608{
609public:
610 typedef std::shared_ptr<constellation_8psk> sptr;
611
612 // public constructor
613 static sptr make();
614
616
617 unsigned int decision_maker(const gr_complex* sample) override;
618
619protected:
621};
622
623/************************************************************/
624/* constellation_8psk_natural */
625/* */
626/* Only works for natural 8psk */
627/* */
628/************************************************************/
629
630/*!
631 * \brief Digital constellation for natually mapped 8PSK.
632 * \ingroup digital
633 *
634 * \details
635 * \verbatim
636 011 | 010
637 100 | 001
638 -----------------
639 101 | 000
640 110 | 111
641 \endverbatim
642 */
644{
645public:
646 typedef std::shared_ptr<constellation_8psk_natural> sptr;
647
648 // public constructor
649 static sptr make();
650
652
653 unsigned int decision_maker(const gr_complex* sample) override;
654
655protected:
657};
658
659/************************************************************/
660/* constellation_16qam */
661/* */
662/* the 16qam mapping used in set partition of tcm */
663/* */
664/************************************************************/
665
666/*!
667 * \brief Digital constellation for 16qam.
668 * \ingroup digital
669 *
670 * \details
671 * \verbatim
6721000 1101 | 1100 1001
673 |
6741111 1010 | 1011 1110
675 -----------------
6760100 0001 | 0000 0101
677 |
6780011 0110 | 0111 0010
679 \endverbatim
680 */
682{
683public:
684 typedef std::shared_ptr<constellation_16qam> sptr;
685
686 // public constructor
687 static sptr make();
688
690
691 unsigned int decision_maker(const gr_complex* sample) override;
692
693protected:
695};
696
697} /* namespace digital */
698} /* namespace gr */
699
700#endif /* INCLUDED_DIGITAL_CONSTELLATION_H */
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.
Digital constellation for natually mapped 8PSK.
Definition: constellation.h:644
std::shared_ptr< constellation_8psk_natural > sptr
Definition: constellation.h:646
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
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.
Digital constellation for BPSK .
Definition: constellation.h:500
unsigned int decision_maker(const gr_complex *sample) override
Returns the constellation point that matches best.
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
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(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
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
Rectangular digital constellation.
Definition: constellation.h:337
unsigned int get_sector(const gr_complex *sample) 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
unsigned int n_sectors
Definition: constellation.h:312
virtual unsigned int get_sector(const gr_complex *sample)=0
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