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>
37
38namespace itpp
39{
40
45// ----------------------------------------------------------------------
46// Modulator_ND
47// ----------------------------------------------------------------------
48
63class ITPP_EXPORT Modulator_ND
64{
65public:
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
122protected:
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
248class ITPP_EXPORT Modulator_NRD : public Modulator_ND
249{
250public:
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
388protected:
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
427ITPP_EXPORT std::ostream &operator<<(std::ostream &os, const Modulator_NRD &m);
428
429
430// ----------------------------------------------------------------------
431// Modulator_NCD
432// ----------------------------------------------------------------------
433
447class ITPP_EXPORT Modulator_NCD : public Modulator_ND
448{
449public:
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
589protected:
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
606ITPP_EXPORT std::ostream &operator<<(std::ostream &os, const Modulator_NCD &m);
607
608
609// ----------------------------------------------------------------------
610// ND_UPAM
611// ----------------------------------------------------------------------
612
654class ITPP_EXPORT ND_UPAM : public Modulator_NRD
655{
656public:
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
694private:
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
720class ITPP_EXPORT ND_UQAM : public Modulator_NCD
721{
722public:
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
753protected:
754 ivec L;
755};
756
757// ----------------------------------------------------------------------
758// ND_UPSK
759// ----------------------------------------------------------------------
760
768class ITPP_EXPORT ND_UPSK : public Modulator_NCD
769{
770public:
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
Definition of Array class (container)
Import/Export definitions for some templates defined in base folder.
General array class.
Definition: array.h:105
Log-likelihood algebra calculation unit.
Definition: llr.h:125
Base class for vector (MIMO) channel modulator/demodulators with complex valued components.
Definition: modulator_nd.h:448
Modulator_NCD()
Constructor.
Definition: modulator_nd.h:451
void demodulate_soft_bits(const cvec &y, const QLLRvec &LLR_apriori, QLLRvec &LLR_aposteriori, Soft_Demod_Method method=FULL_ENUM_LOGMAP)
Soft MAP demodulation for multidimensional channel, by "brute-force" enumeration of all constellation...
itpp::Array< itpp::Array< itpp::cvec > > hspacings
The spacing between different constellation points multiplied by the different H columns.
Definition: modulator_nd.h:595
itpp::Array< itpp::vec > yspacings
The spacing between different constellation points scaled by different y elements.
Definition: modulator_nd.h:597
itpp::cmat H
Complex-valued channel matrix.
Definition: modulator_nd.h:593
Array< cvec > symbols
Vectors of modulation symbols (along each dimension)
Definition: modulator_nd.h:591
virtual ~Modulator_NCD()
Destructor.
Definition: modulator_nd.h:453
Base class for an N-dimensional (ND) vector (MIMO) modulator.
Definition: modulator_nd.h:64
itpp::QLLRvec Qnorms
Norms part depending on both H and y.
Definition: modulator_nd.h:144
double gaussnorm
The normalization factor in the exponent (in front of the square norm) in the Gaussian distribution.
Definition: modulator_nd.h:140
Array< ivec > bits2symbols
Bit pattern in decimal form ordered and the corresponding symbols (one pattern per dimension)
Definition: modulator_nd.h:138
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
ivec bits_per_symbol() const
Get number of bits per modulation symbol per dimension.
Definition: modulator_nd.h:103
int get_dim() const
Get number of dimensions.
Definition: modulator_nd.h:93
itpp::vec hnorms
Norms part dependent on H.
Definition: modulator_nd.h:142
ivec M
Number of modulation symbols along each dimension.
Definition: modulator_nd.h:132
itpp::ivec bitcumsum
The cumulative sum of bits in the symbol vector.
Definition: modulator_nd.h:150
ivec k
Number of bits per modulation symbol.
Definition: modulator_nd.h:130
itpp::QLLRvec llrapr
A prioi information.
Definition: modulator_nd.h:146
LLR_calc_unit get_llrcalc() const
Get LLR calculation unit.
Definition: modulator_nd.h:88
Array< ivec > get_bits2symbols() const
Get bit pattern in decimal.
Definition: modulator_nd.h:113
Soft_Demod_Method
Soft demodulation method.
Definition: modulator_nd.h:67
@ FULL_ENUM_MAXLOG
Max-Log demodulation by "brute-force" enumeration of all points.
Definition: modulator_nd.h:71
@ FULL_ENUM_LOGMAP
Log-MAP demodulation by "brute-force" enumeration of all points.
Definition: modulator_nd.h:69
LLR_calc_unit llrcalc
LLR calculation unit.
Definition: modulator_nd.h:128
itpp::Array< itpp::Vec< unsigned > > gray2dec
The Gray to decimal mapping.
Definition: modulator_nd.h:152
int nb
Number of bits in the symbol vector.
Definition: modulator_nd.h:126
ivec get_M() const
Get number of modulation symbols per dimension.
Definition: modulator_nd.h:108
virtual ~Modulator_ND()
Destructor.
Definition: modulator_nd.h:80
Modulator_ND(LLR_calc_unit llrcalc_in=LLR_calc_unit())
Default constructor.
Definition: modulator_nd.h:77
Array< bmat > get_bitmap() const
Get Bit mapping table.
Definition: modulator_nd.h:118
Array< bmat > bitmap
Bit mapping table (one table per dimension)
Definition: modulator_nd.h:136
void set_llrcalc(LLR_calc_unit llrcalc_in)
Set LLR calculation unit.
Definition: modulator_nd.h:83
bool demod_initialized
Flag indicating whether the demodulator has been initialized.
Definition: modulator_nd.h:134
itpp::ivec bpos2cpos
The bit to column mapping.
Definition: modulator_nd.h:148
Base class for N-dimensional vector (MIMO) channel modulators/demodulators with real-valued component...
Definition: modulator_nd.h:249
virtual ~Modulator_NRD()
Destructor.
Definition: modulator_nd.h:254
void update_norm(double &norm, int k, int sold, int snew, const vec &ytH, const mat &HtH, const ivec &s)
Update residual norm (for internal use).
void demodulate_soft_bits(const vec &y, const QLLRvec &LLR_apriori, QLLRvec &LLR_aposteriori, Soft_Demod_Method method=FULL_ENUM_LOGMAP)
Soft MAP demodulation for multidimensional channel, by "brute-force" enumeration of all constellation...
itpp::Array< itpp::vec > yspacings
The spacing between different constellation points scaled by different y elements.
Definition: modulator_nd.h:420
itpp::mat H
Real channel matrix.
Definition: modulator_nd.h:416
Array< vec > symbols
Vectors of modulation symbols (along each dimension)
Definition: modulator_nd.h:390
Modulator_NRD()
Constructor.
Definition: modulator_nd.h:252
itpp::Array< itpp::Array< itpp::vec > > hspacings
The spacing between different constellation points multiplied by the different H columns.
Definition: modulator_nd.h:418
Real-valued MIMO channel with uniform PAM along each dimension.
Definition: modulator_nd.h:655
virtual ~ND_UPAM()
Destructor.
Definition: modulator_nd.h:660
virtual ~ND_UPSK()
Destructor.
Definition: modulator_nd.h:774
Complex MIMO channel with uniform QAM per dimension.
Definition: modulator_nd.h:721
ivec L
the square root of M
Definition: modulator_nd.h:754
virtual ~ND_UQAM()
Destructor.
Definition: modulator_nd.h:726
Class for numerically efficient log-likelihood algebra.
itpp namespace
Definition: itmex.h:37
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
Definition: binary.cpp:36
Templated Vector Class Definitions.
SourceForge Logo

Generated on Tue Jan 24 2023 00:00:00 for IT++ by Doxygen 1.9.6