itpp::Modulator< T > Class Template Reference
Communications Module » Digital Modulation

General modulator for 1D or 2D signal constellations. More...

`#include <itpp/comm/modulator.h>`

## Public Member Functions

| Modulator ()
| Default constructor.
| Modulator (const Vec< T > &symbols, const ivec &bits2symbols)
| Constructor.
virtual | ~Modulator ()
| Destructor.
virtual void | set (const Vec< T > &symbols, const ivec &bits2symbols)
| Set the constellation to use in the modulator.
virtual int | bits_per_symbol () const
| Returns number of bits per symbol.
virtual int | get_k () const
| Returns number of bits per symbol.
virtual int | get_M () const
| Returns number of modulation symbols.
virtual Vec< T > | get_symbols () const
| Get the symbol values used in the modulator.
virtual ivec | get_bits2symbols () const
| Get the bitmap, which maps input bits into symbols.
virtual void | modulate (const ivec &symbolnumbers, Vec< T > &output) const
| Modulation of symbols.
virtual Vec< T > | modulate (const ivec &symbolnumbers) const
| Modulation of symbols.
virtual void | demodulate (const Vec< T > &signal, ivec &output) const
| Demodulation of symbols.
virtual ivec | demodulate (const Vec< T > &signal) const
| Demodulation of symbols.
virtual void | modulate_bits (const bvec &bits, Vec< T > &output) const
| Modulation of bits.
virtual Vec< T > | modulate_bits (const bvec &bits) const
| Modulation of bits.
virtual void | demodulate_bits (const Vec< T > &signal, bvec &bits) const
| Hard demodulation of bits.
virtual bvec | demodulate_bits (const Vec< T > &signal) const
| Hard demodulation of bits.
virtual void | demodulate_soft_bits (const Vec< T > &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
| Soft demodulator for AWGN channels.
virtual vec | demodulate_soft_bits (const Vec< T > &rx_symbols, double N0, Soft_Method method=LOGMAP) const
| Soft demodulator for AWGN channels.
virtual void | demodulate_soft_bits (const Vec< T > &rx_symbols, const Vec< T > &channel, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
| Soft demodulator for fading channels.
virtual vec | demodulate_soft_bits (const Vec< T > &rx_symbols, const Vec< T > &channel, double N0, Soft_Method method=LOGMAP) const
| Soft demodulator for fading channels.

## Protected Member Functions

void | calculate_softbit_matrices ()
| This function calculates the soft bit mapping matrices S0 and S1.

## Protected Attributes

bool | setup_done
| Setup indicator.
int | k
| Number of bits per modulation symbol.
int | M
| Number of modulation symbols.
bmat | bitmap
| Bit to symbol mapping table (size: M x k)
ivec | bits2symbols
| Bit to symbol mapping in decimal form (size: M)
Vec< T > | symbols
| Corresponding modulation symbols (size: M)
imat | S0
| Matrix where row k contains the constellation points with '0' in bit position k.
imat | S1
| Matrix where row k contains the constellation points with '1' in bit position k.

## Related Symbols

(Note that these are not member symbols.)
typedef Modulator< double > | Modulator_1D
| Definition of 1D Modulator (with real symbols)
typedef Modulator< std::complex< double > > | Modulator_2D
| Definition of 2D Modulator (with complex symbols)

## Detailed Description

template<typename T>
class itpp::Modulator< T >

General modulator for 1D or 2D signal constellations.

The Modulator class is designed for modeling any kind of 1D (real) or 2D (complex) signal constellations. Therefore it is used as a base class for such modulations like PAM, PSK, QAM, etc.

The constellation of the modulator is described with two vectors. The first one contains the real or complex values representing the constellation points, whereas the other one includes the corresponding bit to symbol mapping (in the decimal from).

Beside hard demapping, this class can also perform soft demodulation. To use it properly the received symbols should be equal to:

where is the real or complex channel gain, is the transmitted constellation symbol, and is the AWGN of the channel (with variance ).

It is also assumed that the channel estimates are perfect when calculating the soft bits.

Definition at line 75 of file modulator.h.

## Constructor & Destructor Documentation

## Modulator() [1/2]

template<typename T >

itpp::Modulator< T >::Modulator | ( |  | ) |

Default constructor.

Definition at line 280 of file modulator.h.

## Modulator() [2/2]

template<typename T >

itpp::Modulator< T >::Modulator | ( | const Vec< T > & | symbols,
|  | const ivec & | bits2symbols
| ) |  |

Constructor.

Definition at line 285 of file modulator.h.

## ~Modulator()

template<typename T >

virtual itpp::Modulator< T >::~Modulator | ( |  | ) |

inlinevirtual

Destructor.

Definition at line 83 of file modulator.h.

## Member Function Documentation

## set()

template<typename T >

void itpp::Modulator< T >::set | ( | const Vec< T > & | symbols,
|  | const ivec & | bits2symbols
| ) |  |

virtual

Set the constellation to use in the modulator.

Definition at line 291 of file modulator.h.

References itpp::dec2bin(), itpp::is_even(), it_assert, itpp::levels2bits(), itpp::max(), itpp::min(), and itpp::Array< T >::size().

## bits_per_symbol()

template<typename T >

virtual int itpp::Modulator< T >::bits_per_symbol | ( |  | ) | const

inlinevirtual

Returns number of bits per symbol.

Definition at line 89 of file modulator.h.

References itpp::Modulator< T >::k.

## get_k()

template<typename T >

virtual int itpp::Modulator< T >::get_k | ( |  | ) | const

inlinevirtual

Returns number of bits per symbol.

Definition at line 92 of file modulator.h.

References itpp::Modulator< T >::k.

## get_M()

template<typename T >

virtual int itpp::Modulator< T >::get_M | ( |  | ) | const

inlinevirtual

Returns number of modulation symbols.

Definition at line 95 of file modulator.h.

References itpp::Modulator< T >::M.

## get_symbols()

template<typename T >

virtual Vec< T > itpp::Modulator< T >::get_symbols | ( |  | ) | const

inlinevirtual

Get the symbol values used in the modulator.

Definition at line 98 of file modulator.h.

References itpp::Modulator< T >::symbols.

## get_bits2symbols()

template<typename T >

virtual ivec itpp::Modulator< T >::get_bits2symbols | ( |  | ) | const

inlinevirtual

Get the bitmap, which maps input bits into symbols.

The mapping is done as follows. An input bit sequence in decimal notation is used for indexing the `bits2symbols` table. The indexing result denotes the symbol to be used from the `symbols` table, e.g.:

PSK mod(8); // assume 8-PSK modulator
cvec sym = mod.get_symbols();
ivec bits2sym = mod.get_bits2symbols();
bvec in_bits = "100" // input bits
int d = bin2dec(in_bits); // decimal representation of in_bits = 4
// mapping of d into PSK symbol using bits2sym and sym tables
std::complex<double> out_symbol = sym(bits2sym(d));
itpp::Array
General array class.
Definition array.h:105
itpp::PSK
M-ary PSK modulator.
Definition modulator.h:636
itpp::mod
int mod(int k, int n)
Calculates the modulus, i.e. the signed reminder after division.
Definition elem_math.h:166
itpp::bin2dec
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.

Definition at line 117 of file modulator.h.

References itpp::Modulator< T >::bits2symbols.

## modulate() [1/2]

template<typename T >

void itpp::Modulator< T >::modulate | ( | const ivec & | symbolnumbers,
|  | Vec< T > & | output
| ) |  | const

virtual

Modulation of symbols.

Definition at line 313 of file modulator.h.

References it_assert_debug, itpp::Array< T >::length(), and itpp::Array< T >::set_size().

## modulate() [2/2]

template<typename T >

Vec< T > itpp::Modulator< T >::modulate | ( | const ivec & | symbolnumbers | ) | const

virtual

Modulation of symbols.

Definition at line 322 of file modulator.h.

References itpp::Array< T >::length().

## demodulate() [1/2]

template<typename T >

void itpp::Modulator< T >::demodulate | ( | const Vec< T > & | signal,
|  | ivec & | output
| ) |  | const

virtual

Demodulation of symbols.

Definition at line 331 of file modulator.h.

References it_assert_debug, itpp::Array< T >::set_size(), and itpp::Array< T >::size().

## demodulate() [2/2]

template<typename T >

ivec itpp::Modulator< T >::demodulate | ( | const Vec< T > & | signal | ) | const

virtual

Demodulation of symbols.

Definition at line 353 of file modulator.h.

References itpp::Array< T >::length().

## modulate_bits() [1/2]

template<typename T >

void itpp::Modulator< T >::modulate_bits | ( | const bvec & | bits,
|  | Vec< T > & | output
| ) |  | const

virtual

Modulation of bits.

Definition at line 362 of file modulator.h.

References itpp::bin2dec(), it_assert_debug, it_warning, itpp::Array< T >::length(), itpp::Array< T >::mid(), and itpp::Array< T >::set_size().

## modulate_bits() [2/2]

template<typename T >

Vec< T > itpp::Modulator< T >::modulate_bits | ( | const bvec & | bits | ) | const

virtual

Modulation of bits.

Reimplemented in itpp::BPSK_c, and itpp::BPSK.

Definition at line 378 of file modulator.h.

## demodulate_bits() [1/2]

template<typename T >

void itpp::Modulator< T >::demodulate_bits | ( | const Vec< T > & | signal,
|  | bvec & | bits
| ) |  | const

virtual

Hard demodulation of bits.

Definition at line 386 of file modulator.h.

References it_assert_debug, itpp::Array< T >::set_size(), and itpp::Array< T >::size().

## demodulate_bits() [2/2]

template<typename T >

bvec itpp::Modulator< T >::demodulate_bits | ( | const Vec< T > & | signal | ) | const

virtual

Hard demodulation of bits.

Definition at line 408 of file modulator.h.

## demodulate_soft_bits() [1/4]

template<typename T >

void itpp::Modulator< T >::demodulate_soft_bits | ( | const Vec< T > & | rx_symbols,
|  | double | N0,
|  | vec & | soft_bits,
|  | Soft_Method | method = `LOGMAP`
| ) |  | const

virtual

Soft demodulator for AWGN channels.

This function calculates the log-likelihood ratio (LLR) of the received signal from AWGN channels. Depending on the soft demodulation method chosen, either full log-MAP calculation is performed (default method), according to the following equation:

or approximate, but faster calculation is performed.

The approximate method finds for each bit the closest constellation points that have zero and one in the corresponding position. Let denote the distance to the closest zero point and denote the distance to the closest one point for the corresponding bit respectively. The approximate algorithm then computes

This function can be used on channels where the channel gain .

When this function is to be used together with MAP-based turbo decoding algorithms then the channel reliability factor of the turbo decoder shall be set to 1. The output from this function can also be used by a Viterbi decoder using an AWGN based metric calculation function.

Parameters

  rx_symbols | The received noisy constellation symbols
  N0 | The spectral density of the AWGN noise
  soft_bits | The soft bits calculated using the expression above
  method | The method used for demodulation (LOGMAP or APPROX)

Note
  For soft demodulation it is suggested to use the N-dimensional modulator (`Modulator_ND`) instead, which is based on the QLLR (quantized) arithmetic and therefore is faster. Please note, however, that mixed use of `Modulator_1D/`Modulator_2D` and` `Modulator_ND` is not advised.

Definition at line 417 of file modulator.h.

References it_assert_debug, itpp::LOGMAP, itpp::Array< T >::set_size(), itpp::Array< T >::size(), itpp::sqr(), and itpp::trunc_log().

## demodulate_soft_bits() [2/4]

template<typename T >

vec itpp::Modulator< T >::demodulate_soft_bits | ( | const Vec< T > & | rx_symbols,
|  | double | N0,
|  | Soft_Method | method = `LOGMAP`
| ) |  | const

virtual

Soft demodulator for AWGN channels.

Definition at line 462 of file modulator.h.

## demodulate_soft_bits() [3/4]

template<typename T >

void itpp::Modulator< T >::demodulate_soft_bits | ( | const Vec< T > & | rx_symbols,
|  | const Vec< T > & | channel,
|  | double | N0,
|  | vec & | soft_bits,
|  | Soft_Method | method = `LOGMAP`
| ) |  | const

virtual

Soft demodulator for fading channels.

This function calculates the log-likelihood ratio (LLR) of the received signal from fading channels. Depending on the soft demodulation method chosen, either full log-MAP calculation is performed (default method), according to the following equation:

or approximate, but faster calculation is performed.

The approximate method finds for each bit the closest constellation points that have zero and one in the corresponding position. Let denote the distance to the closest zero point and denote the distance to the closest one point for the corresponding bit respectively. The approximate algorithm then computes

When this function is to be used together with MAP-based turbo decoding algorithms then the channel reliability factor of the turbo decoder shall be set to 1. The output from this function can also be used by a Viterbi decoder using an AWGN based metric calculation function.

Parameters

  rx_symbols | The received noisy constellation symbols
  channel | The channel values
  N0 | The spectral density of the AWGN noise
  soft_bits | The soft bits calculated using the expression above
  method | The method used for demodulation (LOGMAP or APPROX)

Note
  For soft demodulation it is suggested to use the N-dimensional modulator (Modulator_ND) instead, which is based on the QLLR (quantized) arithmetic and therefore is faster. Please note, however, that mixed use of `Modulator_1D/`Modulator_2D` and` `Modulator_ND` is not advised.

Definition at line 472 of file modulator.h.

References it_assert_debug, itpp::LOGMAP, itpp::Array< T >::set_size(), itpp::Array< T >::size(), itpp::sqr(), and itpp::trunc_log().

## demodulate_soft_bits() [4/4]

template<typename T >

vec itpp::Modulator< T >::demodulate_soft_bits | ( | const Vec< T > & | rx_symbols,
|  | const Vec< T > & | channel,
|  | double | N0,
|  | Soft_Method | method = `LOGMAP`
| ) |  | const

virtual

Soft demodulator for fading channels.

Definition at line 519 of file modulator.h.

## calculate_softbit_matrices()

template<typename T >

void itpp::Modulator< T >::calculate_softbit_matrices | ( |  | ) |

protected

This function calculates the soft bit mapping matrices S0 and S1.

Definition at line 530 of file modulator.h.

References itpp::Array< T >::set_size().

## Friends And Related Symbol Documentation

## Modulator_1D

template<typename T >

typedef Modulator<double> Modulator_1D

related

Definition of 1D Modulator (with real symbols)

Definition at line 266 of file modulator.h.

## Modulator_2D

template<typename T >

typedef Modulator<std::complex<double> > Modulator_2D

related

Definition of 2D Modulator (with complex symbols)

Definition at line 272 of file modulator.h.

## Member Data Documentation

## setup_done

template<typename T >

bool itpp::Modulator< T >::setup_done

protected

Setup indicator.

Definition at line 235 of file modulator.h.

## k

template<typename T >

int itpp::Modulator< T >::k

protected

Number of bits per modulation symbol.

Definition at line 237 of file modulator.h.

Referenced by itpp::Modulator< T >::bits_per_symbol(), and itpp::Modulator< T >::get_k().

## M

template<typename T >

int itpp::Modulator< T >::M

protected

Number of modulation symbols.

Definition at line 239 of file modulator.h.

Referenced by itpp::Modulator< T >::get_M().

## bitmap

template<typename T >

bmat itpp::Modulator< T >::bitmap

protected

Bit to symbol mapping table (size: M x k)

Definition at line 241 of file modulator.h.

## bits2symbols

template<typename T >

ivec itpp::Modulator< T >::bits2symbols

protected

Bit to symbol mapping in decimal form (size: M)

Definition at line 243 of file modulator.h.

Referenced by itpp::Modulator< T >::get_bits2symbols().

## symbols

template<typename T >

Vec<T> itpp::Modulator< T >::symbols

protected

Corresponding modulation symbols (size: M)

Definition at line 245 of file modulator.h.

Referenced by itpp::Modulator< T >::get_symbols().

## S0

template<typename T >

imat itpp::Modulator< T >::S0

protected

Matrix where row k contains the constellation points with '0' in bit position k.

Definition at line 248 of file modulator.h.

## S1

template<typename T >

imat itpp::Modulator< T >::S1

protected

Matrix where row k contains the constellation points with '1' in bit position k.

Definition at line 251 of file modulator.h.

The documentation for this class was generated from the following file:

- itpp/comm/modulator.h

Generated on Mon Jun 10 2024 11:49:37 for IT++ by Doxygen 1.9.8