00001 00030 #ifndef MODULATOR_ND_H 00031 #define MODULATOR_ND_H 00032 00033 #include <itpp/base/vec.h> 00034 #include <itpp/base/array.h> 00035 #include <itpp/comm/llr.h> 00036 00037 namespace itpp 00038 { 00039 00044 // ---------------------------------------------------------------------- 00045 // Modulator_ND 00046 // ---------------------------------------------------------------------- 00047 00062 class Modulator_ND 00063 { 00064 public: 00066 enum Soft_Demod_Method { 00068 FULL_ENUM_LOGMAP, 00070 ZF_LOGMAP 00071 }; 00072 00074 Modulator_ND(LLR_calc_unit llrcalc_in = LLR_calc_unit()): 00075 llrcalc(llrcalc_in) {} 00077 ~Modulator_ND() {} 00078 00080 void set_llrcalc(LLR_calc_unit llrcalc_in) { llrcalc = llrcalc_in; }; 00081 00083 LLR_calc_unit get_llrcalc() const { return llrcalc; } 00084 00086 int get_dim() const { return nt; } 00087 00089 ivec get_k() const { return k; } 00090 00092 ivec get_M() const { return M; } 00093 00094 protected: 00096 int nt; 00098 LLR_calc_unit llrcalc; 00100 ivec k; 00102 ivec M; 00104 Array<bmat> bitmap; 00106 Array<ivec> bits2symbols; 00107 00109 QLLRvec probabilities(QLLR l); // some abuse of what QLLR stands for... 00110 00112 Array<QLLRvec> probabilities(const QLLRvec &l); 00113 00132 void update_LLR(const Array<QLLRvec> &logP_apriori, const ivec &s, 00133 QLLR scaled_norm, QLLRvec &num, QLLRvec &denom); 00134 00154 void update_LLR(const Array<QLLRvec> &logP_apriori, int s, 00155 QLLR scaled_norm, int j, QLLRvec &num, QLLRvec &denom); 00156 }; 00157 00158 00159 // ---------------------------------------------------------------------- 00160 // Modulator_NRD 00161 // ---------------------------------------------------------------------- 00162 00190 class Modulator_NRD : public Modulator_ND 00191 { 00192 public: 00194 Modulator_NRD() {} 00196 ~Modulator_NRD() {} 00197 00199 Array<vec> get_symbols() const { return symbols; } 00200 00202 void modulate_bits(const bvec &bits, vec &symbols) const; 00203 00205 vec modulate_bits(const bvec &bits) const; 00206 00225 void demodulate_soft_bits(const vec &y, const mat &H, double sigma2, 00226 const QLLRvec &LLR_apriori, 00227 QLLRvec &LLR_aposteriori, 00228 Soft_Demod_Method method); 00229 00248 QLLRvec demodulate_soft_bits(const vec &y, const mat &H, double sigma2, 00249 const QLLRvec &LLR_apriori, 00250 Soft_Demod_Method method); 00251 00280 void demodulate_soft_bits(const vec &y, const mat &H, double sigma2, 00281 const QLLRvec &LLR_apriori, 00282 QLLRvec &LLR_aposteriori); 00283 00291 void demodulate_soft_bits(const vec &y, const vec &h, double sigma2, 00292 const QLLRvec &LLR_apriori, 00293 QLLRvec &LLR_aposteriori); 00294 00295 00297 friend std::ostream &operator<<(std::ostream &os, const Modulator_NRD &m); 00298 00299 protected: 00301 Array<vec> symbols; 00302 00317 void update_norm(double &norm, int k, int sold, int snew, const vec &ytH, 00318 const mat &HtH, const ivec &s); 00319 }; 00320 00325 std::ostream &operator<<(std::ostream &os, const Modulator_NRD &m); 00326 00327 00328 // ---------------------------------------------------------------------- 00329 // Modulator_NCD 00330 // ---------------------------------------------------------------------- 00331 00345 class Modulator_NCD : public Modulator_ND 00346 { 00347 public: 00349 Modulator_NCD() {} 00351 ~Modulator_NCD() {} 00352 00354 Array<cvec> get_symbols() const { return symbols; } 00355 00357 void modulate_bits(const bvec &bits, cvec &symbols) const; 00358 00360 cvec modulate_bits(const bvec &bits) const; 00361 00363 00382 void demodulate_soft_bits(const cvec &y, const cmat &H, double sigma2, 00383 const QLLRvec &LLR_apriori, 00384 QLLRvec &LLR_aposteriori, 00385 Soft_Demod_Method method); 00386 00406 QLLRvec demodulate_soft_bits(const cvec &y, const cmat &H, double sigma2, 00407 const QLLRvec &LLR_apriori, 00408 Soft_Demod_Method method); 00409 00438 void demodulate_soft_bits(const cvec &y, const cmat &H, double sigma2, 00439 const QLLRvec &LLR_apriori, 00440 QLLRvec &LLR_aposteriori); 00441 00449 void demodulate_soft_bits(const cvec &y, const cvec &H, double sigma2, 00450 const QLLRvec &LLR_apriori, 00451 QLLRvec &LLR_aposteriori); 00452 00454 friend std::ostream &operator<<(std::ostream &os, const Modulator_NCD &m); 00455 00456 protected: 00458 Array<cvec> symbols; 00459 00474 void update_norm(double &norm, int k, int sold, int snew, const cvec &ytH, 00475 const cmat &HtH, const ivec &s); 00476 }; 00477 00482 std::ostream &operator<<(std::ostream &os, const Modulator_NCD &m); 00483 00484 00485 // ---------------------------------------------------------------------- 00486 // ND_UPAM 00487 // ---------------------------------------------------------------------- 00488 00530 class ND_UPAM : public Modulator_NRD 00531 { 00532 public: 00534 ND_UPAM(int nt = 1, int Mary = 2); 00536 ~ND_UPAM() {} 00537 00539 void set_M(int nt = 1, int Mary = 2); 00540 00542 void set_M(int nt = 1, ivec Mary = "2"); 00543 00567 int sphere_decoding(const vec &y, const mat &H, double rmin, double rmax, 00568 double stepup, QLLRvec &detected_bits); 00569 00570 private: 00571 // Sphere decoding search with Schnorr Eucner strategy. 00572 int sphere_search_SE(const vec &y, const mat &H, const imat &zrange, 00573 double r, ivec &zhat); 00574 00575 vec spacing; // spacing between the constellation points 00576 00577 inline int sign_nozero_i(int a) { return (a > 0 ? 1 : -1); } 00578 inline int sign_nozero_i(double a) { return (a > 0.0 ? 1 : -1); } 00579 }; 00580 00581 // ---------------------------------------------------------------------- 00582 // ND_UQAM 00583 // ---------------------------------------------------------------------- 00584 00592 class ND_UQAM : public Modulator_NCD 00593 { 00594 public: 00596 ND_UQAM(int nt = 1, int Mary = 4); 00598 ~ND_UQAM() {} 00599 00601 void set_M(int nt = 1, int Mary = 4); 00602 00604 void set_M(int nt = 1, ivec Mary = "4"); 00605 00606 protected: 00607 ivec L; 00608 }; 00609 00610 // ---------------------------------------------------------------------- 00611 // ND_UPSK 00612 // ---------------------------------------------------------------------- 00613 00621 class ND_UPSK : public Modulator_NCD 00622 { 00623 public: 00625 ND_UPSK(int nt = 1, int Mary = 4); 00627 ~ND_UPSK() {} 00628 00630 void set_M(int nt = 1, int Mary = 4); 00631 00633 void set_M(int nt = 1, ivec Mary = "4"); 00634 }; 00635 00636 00637 } // namespace itpp 00638 00639 #endif // #ifndef MODULATOR_ND_H 00640
Generated on Wed Jan 20 23:03:05 2010 for IT++ by Doxygen 1.6.2