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 
SourceForge Logo

Generated on Sat May 25 2013 16:32:21 for IT++ by Doxygen 1.8.2