IT++ Logo
modulator_nd.h
Go to the documentation of this file.
1 
29 #ifndef MODULATOR_ND_H
30 #define MODULATOR_ND_H
31 
32 #include <itpp/base/vec.h>
33 #include <itpp/base/array.h>
34 #include <itpp/comm/llr.h>
35 #include <itpp/itexports.h>
36 #include <itpp/base/base_exports.h>
37 
38 namespace itpp
39 {
40 
45 // ----------------------------------------------------------------------
46 // Modulator_ND
47 // ----------------------------------------------------------------------
48 
63 class ITPP_EXPORT Modulator_ND
64 {
65 public:
73  ZF_LOGMAP
74  };
75 
78  llrcalc(llrcalc_in), demod_initialized(false) {}
80  virtual ~Modulator_ND() {}
81 
83  void set_llrcalc(LLR_calc_unit llrcalc_in) {
84  llrcalc = llrcalc_in;
85  };
86 
89  return llrcalc;
90  }
91 
93  int get_dim() const {
94  return nt;
95  }
96 
98  ivec get_k() const {
99  return k;
100  }
101 
103  ivec bits_per_symbol() const {
104  return k;
105  }
106 
108  ivec get_M() const {
109  return M;
110  }
111 
114  return bits2symbols;
115  }
116 
119  return bitmap;
120  }
121 
122 protected:
124  int nt;
126  int nb;
130  ivec k;
132  ivec M;
140  double gaussnorm;
142  itpp::vec hnorms;
144  itpp::QLLRvec Qnorms;
146  itpp::QLLRvec llrapr;
148  itpp::ivec bpos2cpos;
150  itpp::ivec bitcumsum;
154  QLLRvec probabilities(QLLR l); // some abuse of what QLLR stands for...
156  Array<QLLRvec> probabilities(const QLLRvec &l);
158  void marginalize_bits(itpp::QLLRvec& llr, Soft_Demod_Method method) const;
160  void demodllrbit0(itpp::QLLR& llr) const;
162  void demodllrbit1(itpp::QLLR& llr) const;
164  void demodllrbit2(itpp::QLLR& llr) const;
166  void demodmaxbit0(itpp::QLLR& maxllr) const;
168  void demodmaxbit1(itpp::QLLR& maxllr) const;
170  void demodmaxbit2(itpp::QLLR& maxllr) const;
171 
190  void update_LLR(const Array<QLLRvec> &logP_apriori, const ivec &s,
191  QLLR scaled_norm, QLLRvec &num, QLLRvec &denom);
192 
212  void update_LLR(const Array<QLLRvec> &logP_apriori, int s,
213  QLLR scaled_norm, int j, QLLRvec &num, QLLRvec &denom);
214 };
215 
216 
217 // ----------------------------------------------------------------------
218 // Modulator_NRD
219 // ----------------------------------------------------------------------
220 
248 class ITPP_EXPORT Modulator_NRD : public Modulator_ND
249 {
250 public:
254  virtual ~Modulator_NRD() {}
255 
257  Array<vec> get_symbols() const;
258 
260  void modulate_bits(const bvec &bits, vec &symbols) const;
261 
263  vec modulate_bits(const bvec &bits) const;
264 
283  void init_soft_demodulator(const itpp::mat& H, const double& sigma2);
284 
285 
319  void demodulate_soft_bits(const vec &y,
320  const QLLRvec &LLR_apriori,
321  QLLRvec &LLR_aposteriori,
322  Soft_Demod_Method method = FULL_ENUM_LOGMAP);
323 
345  void demodulate_soft_bits(const vec &y, const mat &H, double sigma2,
346  const QLLRvec &LLR_apriori,
347  QLLRvec &LLR_aposteriori,
348  Soft_Demod_Method method = FULL_ENUM_LOGMAP);
349 
350 
369  QLLRvec demodulate_soft_bits(const vec &y, const mat &H, double sigma2,
370  const QLLRvec &LLR_apriori,
371  Soft_Demod_Method method = FULL_ENUM_LOGMAP);
372 
373 
381  void demodulate_soft_bits(const vec &y, const vec &h, double sigma2,
382  const QLLRvec &LLR_apriori,
383  QLLRvec &LLR_aposteriori);
384 
386  friend ITPP_EXPORT std::ostream &operator<<(std::ostream &os, const Modulator_NRD &m);
387 
388 protected:
391 
406  void update_norm(double &norm, int k, int sold, int snew, const vec &ytH,
407  const mat &HtH, const ivec &s);
408 
410  void hxnormupdate(itpp::vec& Hx, unsigned& bitstring, unsigned& ind, unsigned bit);
411 
413  void yxnormupdate(double& yx, itpp::QLLR& lapr, unsigned& bitstring, unsigned& ind, unsigned bit);
414 
416  itpp::mat H;
421 };
422 
427 ITPP_EXPORT std::ostream &operator<<(std::ostream &os, const Modulator_NRD &m);
428 
429 
430 // ----------------------------------------------------------------------
431 // Modulator_NCD
432 // ----------------------------------------------------------------------
433 
447 class ITPP_EXPORT Modulator_NCD : public Modulator_ND
448 {
449 public:
453  virtual ~Modulator_NCD() {}
454 
456  Array<cvec> get_symbols() const;
457 
459  void modulate_bits(const bvec &bits, cvec &symbols) const;
460 
462  cvec modulate_bits(const bvec &bits) const;
463 
482  void init_soft_demodulator(const itpp::cmat& H, const double& sigma2);
483 
515  void demodulate_soft_bits(const cvec &y,
516  const QLLRvec &LLR_apriori,
517  QLLRvec &LLR_aposteriori,
518  Soft_Demod_Method method = FULL_ENUM_LOGMAP);
519 
521 
543  void demodulate_soft_bits(const cvec &y, const cmat &H, double sigma2,
544  const QLLRvec &LLR_apriori,
545  QLLRvec &LLR_aposteriori,
546  Soft_Demod_Method method = FULL_ENUM_LOGMAP);
547 
570  QLLRvec demodulate_soft_bits(const cvec &y, const cmat &H, double sigma2,
571  const QLLRvec &LLR_apriori,
572  Soft_Demod_Method method = FULL_ENUM_LOGMAP);
573 
574 
582  void demodulate_soft_bits(const cvec &y, const cvec &h, double sigma2,
583  const QLLRvec &LLR_apriori,
584  QLLRvec &LLR_aposteriori);
585 
587  friend ITPP_EXPORT std::ostream &operator<<(std::ostream &os, const Modulator_NCD &m);
588 
589 protected:
593  itpp::cmat H;
598  void hxnormupdate(itpp::cvec& Hx, unsigned& bitstring, unsigned& ind, unsigned bit);
599  void yxnormupdate(double& yx, itpp::QLLR& lapr, unsigned& bitstring, unsigned& ind, unsigned bit);
600 };
601 
606 ITPP_EXPORT std::ostream &operator<<(std::ostream &os, const Modulator_NCD &m);
607 
608 
609 // ----------------------------------------------------------------------
610 // ND_UPAM
611 // ----------------------------------------------------------------------
612 
654 class ITPP_EXPORT ND_UPAM : public Modulator_NRD
655 {
656 public:
658  ND_UPAM(int nt = 1, int Mary = 2);
660  virtual ~ND_UPAM() {}
661 
663  void set_M(int nt = 1, int Mary = 2);
664 
666  void set_M(int nt = 1, ivec Mary = "2");
667 
691  int sphere_decoding(const vec &y, const mat &H, double rmin, double rmax,
692  double stepup, QLLRvec &detected_bits);
693 
694 private:
695  // Sphere decoding search with Schnorr Eucner strategy.
696  int sphere_search_SE(const vec &y, const mat &H, const imat &zrange,
697  double r, ivec &zhat);
698 
699  vec spacing; // spacing between the constellation points
700 
701  inline int sign_nozero_i(int a) {
702  return (a > 0 ? 1 : -1);
703  }
704  inline int sign_nozero_i(double a) {
705  return (a > 0.0 ? 1 : -1);
706  }
707 };
708 
709 // ----------------------------------------------------------------------
710 // ND_UQAM
711 // ----------------------------------------------------------------------
712 
720 class ITPP_EXPORT ND_UQAM : public Modulator_NCD
721 {
722 public:
724  ND_UQAM(int nt = 1, int Mary = 4);
726  virtual ~ND_UQAM() {}
727 
729  void set_M(int nt = 1, int Mary = 4);
730 
732  void set_M(int nt = 1, ivec Mary = "4");
733 
751  void set_constellation_points(const int nth, const cvec& inConstellation, const ivec& in_bit2symbols);
752 
753 protected:
754  ivec L;
755 };
756 
757 // ----------------------------------------------------------------------
758 // ND_UPSK
759 // ----------------------------------------------------------------------
760 
768 class ITPP_EXPORT ND_UPSK : public Modulator_NCD
769 {
770 public:
772  ND_UPSK(int nt = 1, int Mary = 4);
774  virtual ~ND_UPSK() {}
775 
777  void set_M(int nt = 1, int Mary = 4);
778 
780  void set_M(int nt = 1, ivec Mary = "4");
781 };
782 
783 
784 } // namespace itpp
785 
786 #endif // #ifndef MODULATOR_ND_H
787 
Array< cvec > symbols
Vectors of modulation symbols (along each dimension)
Definition: modulator_nd.h:591
virtual ~ND_UQAM()
Destructor.
Definition: modulator_nd.h:726
itpp::ivec bitcumsum
The cumulative sum of bits in the symbol vector.
Definition: modulator_nd.h:150
Array< ivec > get_bits2symbols() const
Get bit pattern in decimal.
Definition: modulator_nd.h:113
ivec get_k() const
Get number of bits per modulation symbol per dimension.
Definition: modulator_nd.h:98
int nt
Number of dimensions.
Definition: modulator_nd.h:124
itpp::Array< itpp::vec > yspacings
The spacing between different constellation points scaled by different y elements.
Definition: modulator_nd.h:420
Base class for N-dimensional vector (MIMO) channel modulators/demodulators with real-valued component...
Definition: modulator_nd.h:248
LLR_calc_unit llrcalc
LLR calculation unit.
Definition: modulator_nd.h:128
Array< ivec > bits2symbols
Bit pattern in decimal form ordered and the corresponding symbols (one pattern per dimension) ...
Definition: modulator_nd.h:138
Array< bmat > get_bitmap() const
Get Bit mapping table.
Definition: modulator_nd.h:118
bool demod_initialized
Flag indicating whether the demodulator has been initialized.
Definition: modulator_nd.h:134
double norm(const cvec &v)
Calculate the 2-norm: norm(v)=sqrt(sum(abs(v).^2))
Definition: misc_stat.cpp:77
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Definition: binary.cpp:36
Real-valued MIMO channel with uniform PAM along each dimension.
Definition: modulator_nd.h:654
Complex MIMO channel with uniform QAM per dimension.
Definition: modulator_nd.h:720
virtual ~Modulator_NCD()
Destructor.
Definition: modulator_nd.h:453
Array< vec > symbols
Vectors of modulation symbols (along each dimension)
Definition: modulator_nd.h:390
itpp::Array< itpp::vec > yspacings
The spacing between different constellation points scaled by different y elements.
Definition: modulator_nd.h:597
ivec M
Number of modulation symbols along each dimension.
Definition: modulator_nd.h:132
virtual ~Modulator_ND()
Destructor.
Definition: modulator_nd.h:80
void set_llrcalc(LLR_calc_unit llrcalc_in)
Set LLR calculation unit.
Definition: modulator_nd.h:83
itpp::Array< itpp::Array< itpp::cvec > > hspacings
The spacing between different constellation points multiplied by the different H columns.
Definition: modulator_nd.h:595
int nb
Number of bits in the symbol vector.
Definition: modulator_nd.h:126
Base class for an N-dimensional (ND) vector (MIMO) modulator.
Definition: modulator_nd.h:63
Definition of Array class (container)
Modulator_NRD()
Constructor.
Definition: modulator_nd.h:252
ivec get_M() const
Get number of modulation symbols per dimension.
Definition: modulator_nd.h:108
int get_dim() const
Get number of dimensions.
Definition: modulator_nd.h:93
virtual ~ND_UPAM()
Destructor.
Definition: modulator_nd.h:660
Import/Export definitions for some templates defined in base folder.
ivec k
Number of bits per modulation symbol.
Definition: modulator_nd.h:130
itpp::QLLRvec Qnorms
Norms part depending on both H and y.
Definition: modulator_nd.h:144
Class for numerically efficient log-likelihood algebra.
itpp::QLLRvec llrapr
A prioi information.
Definition: modulator_nd.h:146
itpp namespace
Definition: itmex.h:36
itpp::vec hnorms
Norms part dependent on H.
Definition: modulator_nd.h:142
virtual ~ND_UPSK()
Destructor.
Definition: modulator_nd.h:774
Base class for vector (MIMO) channel modulator/demodulators with complex valued components.
Definition: modulator_nd.h:447
ivec L
the square root of M
Definition: modulator_nd.h:754
Soft_Demod_Method
Soft demodulation method.
Definition: modulator_nd.h:67
Log-likelihood algebra calculation unit.
Definition: llr.h:124
ivec bits_per_symbol() const
Get number of bits per modulation symbol per dimension.
Definition: modulator_nd.h:103
Max-Log demodulation by "brute-force" enumeration of all points.
Definition: modulator_nd.h:71
itpp::Array< itpp::Vec< unsigned > > gray2dec
The Gray to decimal mapping.
Definition: modulator_nd.h:152
LLR_calc_unit get_llrcalc() const
Get LLR calculation unit.
Definition: modulator_nd.h:88
Modulator_ND(LLR_calc_unit llrcalc_in=LLR_calc_unit())
Default constructor.
Definition: modulator_nd.h:77
Array< bmat > bitmap
Bit mapping table (one table per dimension)
Definition: modulator_nd.h:136
itpp::ivec bpos2cpos
The bit to column mapping.
Definition: modulator_nd.h:148
double gaussnorm
The normalization factor in the exponent (in front of the square norm) in the Gaussian distribution...
Definition: modulator_nd.h:140
itpp::cmat H
Complex-valued channel matrix.
Definition: modulator_nd.h:593
itpp::mat H
Real channel matrix.
Definition: modulator_nd.h:416
itpp::Array< itpp::Array< itpp::vec > > hspacings
The spacing between different constellation points multiplied by the different H columns.
Definition: modulator_nd.h:418
Templated Vector Class Definitions.
Log-MAP demodulation by "brute-force" enumeration of all points.
Definition: modulator_nd.h:69
Modulator_NCD()
Constructor.
Definition: modulator_nd.h:451
virtual ~Modulator_NRD()
Destructor.
Definition: modulator_nd.h:254
SourceForge Logo

Generated on Sun Apr 10 2022 12:00:00 for IT++ by Doxygen 1.8.14