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