40template class ITPP_EXPORT Modulator<double>;
41template class ITPP_EXPORT Modulator<std::complex<double> >;
53 "QAM::set_M(): M = " <<
M <<
" is not an even power of 2");
54 L =
round_i(std::sqrt(
static_cast<double>(
M)));
65 for (
int i = 0;
i <
L;
i++) {
66 for (
int j = 0;
j <
L;
j++) {
88 for (
int i = 0;
i < signal.
size();
i++) {
128 double epsilon =
delta / 10000.0;
129 std::complex<double>
symb;
130 for (
int i = 0;
i <
M;
i++) {
131 symb = std::complex<double>(std::polar(1.0,
delta *
i));
132 if (std::fabs(std::real(
symb)) < epsilon) {
133 symbols(
i) = std::complex<double>(0.0, std::imag(
symb));
135 else if (std::fabs(std::imag(
symb)) < epsilon) {
136 symbols(
i) = std::complex<double>(std::real(
symb), 0.0);
159 for (
int i = 0;
i < signal.
size();
i++) {
160 ang = std::arg(signal(
i));
183 std::complex<double>
temp;
184 double factor = 2 * std::sqrt(2.0) / N0;
185 std::complex<double>
exp_pi4 = std::complex<double>(std::cos(
pi / 4),
208 std::complex<double>
temp;
209 double factor = 2 * std::sqrt(2.0) / N0;
210 std::complex<double>
exp_pi4 = std::complex<double>(std::cos(
pi / 4),
251 for (
int i = 0;
i < signal.
length();
i++) {
252 out(
i) = (std::real(signal(
i)) > 0) ?
bin(0) :
bin(1);
258 bvec
out(signal.size());
329 for (
int i = 0;
i < signal.
length();
i++) {
336 bvec
out(signal.size());
399 for (
int i = 0;
i <
M;
i++) {
416 for (
int i = 0;
i < signal.
size();
i++) {
429 bvec
temp(signal.size());
446 for (
int j = 0;
j <
M;
j++) {
450 for (
int i = 0;
i <
k;
i++) {
452 for (
int j = 0;
j < (
M >> 1);
j++) {
462 for (
int j = 0;
j <
M;
j++) {
465 for (
int i = 0;
i <
k;
i++) {
466 d0min =
d1min = std::numeric_limits<double>::max();
467 for (
int j = 0;
j < (
M >> 1);
j++) {
500 for (
int j = 0;
j <
M;
j++) {
504 for (
int i = 0;
i <
k;
i++) {
506 for (
int j = 0;
j < (
M >> 1);
j++) {
516 for (
int j = 0;
j <
M;
j++) {
519 for (
int i = 0;
i <
k;
i++) {
520 d0min =
d1min = std::numeric_limits<double>::max();
521 for (
int j = 0;
j < (
M >> 1);
j++) {
558 for (
int i = 0;
i <
M;
i++) {
575 for (
int i = 0;
i < signal.
size();
i++) {
587 bvec
temp(signal.size());
int size() const
Returns the number of data elements in the array object.
void set_size(int n, bool copy=false)
Resizing an Array<T>.
int length() const
Returns the number of data elements in the array object.
virtual void demodulate_soft_bits(const cvec &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
Soft demodulator for AWGN channel.
void modulate_bits(const bvec &bits, cvec &output) const
Modulate bits into BPSK symbols in complex domain.
void demodulate_bits(const cvec &signal, bvec &output) const
Demodulate noisy BPSK symbols in complex domain into bits.
void modulate_bits(const bvec &bits, vec &output) const
Modulate bits into BPSK symbols in complex domain.
virtual void demodulate_soft_bits(const vec &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
Soft demodulator for AWGN channel.
void demodulate_bits(const vec &signal, bvec &output) const
Demodulate noisy BPSK symbols in complex domain into bits.
bmat bitmap
Bit to symbol mapping table (size: M x k)
Vec< std::complex< double > > symbols
Corresponding modulation symbols (size: M)
int k
Number of bits per modulation symbol.
ivec bits2symbols
Bit to symbol mapping in decimal form (size: M)
bool setup_done
Setup indicator.
imat S1
Matrix where row k contains the constellation points with '1' in bit position k.
int M
Number of modulation symbols.
void calculate_softbit_matrices()
This function calculates the soft bit mapping matrices S0 and S1.
imat S0
Matrix where row k contains the constellation points with '0' in bit position k.
virtual void demodulate_soft_bits(const cvec &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
Soft demodulator for AWGN channels.
void set_M(int M)
Set the size of the signal constellation.
void demodulate_bits(const cvec &signal, bvec &output) const
Hard demodulation of PAM symbols in complex domain to bits.
double scaling_factor
Scaling factor used to normalize the average energy to 1.
void set_M(int M)
Set the size of the signal constellation.
double scaling_factor
Scaling factor used to normalize the average energy to 1.
void demodulate_bits(const vec &signal, bvec &output) const
Hard demodulation of PAM symbols in complex domain to bits.
void set_M(int M)
Change the size of the signal constellation.
void demodulate_bits(const cvec &signal, bvec &bits) const
Hard demodulation of bits.
double scaling_factor
Scaling factor of square QAM constellation (sqrt((M-1)*2/3))
void demodulate_bits(const cvec &signal, bvec &bits) const
Hard demodulation of bits.
int L
The square-root of M.
void set_M(int M)
Change the size of the signal constellation.
virtual void demodulate_soft_bits(const cvec &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
Soft demodulator for AWGN channel.
void set_size(int size, bool copy=false)
Set length of vector. if copy = true then keeping the old values.
Binary arithmetic (boolean) class.
Definitions of some specific functions useful in communications.
Elementary mathematical functions - header file.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
#define it_assert(t, s)
Abort if t is not true.
double trunc_log(double x)
Truncated natural logarithm function.
int pow2i(int x)
Calculate two to the power of x (2^x); x is integer.
int levels2bits(int n)
Calculate the number of bits needed to represent n different values (levels).
bmat graycode(int m)
Generate Gray code of blocklength m.
bool is_even(int x)
Return true if x is an even integer.
vec sqr(const cvec &data)
Absolute square of elements.
Soft_Method
Soft demodulation methods.
@ LOGMAP
Log-MAP full calculation.
Mat< bin > bmat
bin matrix
One- and two-dimensional modulators - header file.
ITPP_EXPORT int round_i(double x)
Round to nearest integer.
const double m_2pi
Constant 2*Pi.
ITPP_EXPORT int bin2dec(const bvec &inbvec, bool msb_first=true)
Convert a bvec to decimal int with the first bit as MSB if msb_first == true.
const Array< T > concat(const Array< T > &a, const T &e)
Append element e to the end of the Array a.
int gray_code(int x)
Convert to Gray Code.
const double pi
Constant Pi.
Definitions of special vectors and matrices.