Mappers#

class SymbolMapper(alphabet: ndarray, is_mimo: bool = True, name: str = 'Symbol Mapper')#

Symbol Mapper for converting digital data to symbols based on a predefined alphabet.

This class maps an array of integers (representing digital data) to complex symbols according to a specified alphabet. It’s used in digital communication systems where digital bits need to be mapped to symbols for modulation.

Signal Model#

\[y[n] = f_{\mathcal{M}}(x[n])\]

where :

  • \(f_{\mathcal{M}}(.)\) is a mapper function that converts an integer \(\{0, \cdots, M-1\}\) into a symbol belonging to an alphabet \(\mathcal{M}\),

  • \(\mathcal{M}=\{s_0, \cdots, s_{M-1}\}\) corresponds to the alphabet.

Attributes#

alphabetnp.ndarray

An array of complex symbols representing the modulation alphabet.

namestr

Name of the symbol mapper instance. Default is “SymbolMapper”.

Examples#

>>> from comnumpy.core.generators import SymbolGenerator
>>> from comnumpy.core.mappers import SymbolMapper
>>> from comnumpy.core.utils import get_alphabet
>>> M = 4
>>> alphabet = get_alphabet("QAM", M)
>>> generator = SymbolGenerator(M=M, seed=42)
>>> mapper = SymbolMapper(alphabet)
>>> input = generator(5)
>>> print(input)
[0 3 2 1 1]
>>> symbols = mapper(input)
>>> print(symbols)
[-0.70710678+0.70710678j  0.70710678-0.70710678j  0.70710678+0.70710678j -0.70710678-0.70710678j -0.70710678-0.70710678j]
class SymbolDemapper(alphabet: ndarray, name: str = 'Symbol Demapper')#

Symbol Demapper for converting symbols to digital data based on a predefined alphabet.

This class demaps complex symbols to the nearest symbols in a specified alphabet, effectively performing the inverse operation of a symbol mapper.

Signal Model#

\[y[n] = \mathcal{P}_{\mathcal{M}}(x[n]) = \arg \min_{m \in \{0, \cdots, M-1\}} |x[n]-s_m|^2\]
  • \(\mathcal{P}_{\mathcal{M}}(.)\) corresponds to the orthogonal projector into the constellation \(\mathcal{M}\)

  • \(\mathcal{M}=\{s_0, \cdots, s_{M-1}\}\) corresponds to the alphabet.

Attributes#

alphabetnp.ndarray

An array of complex symbols representing the modulation alphabet.

namestr

Name of the symbol demapper instance. Default is “SymbolDemapper”.

Examples#

>>> import numpy as np
>>> from comnumpy.core.mappers import SymbolDemapper
>>> from comnumpy.core.utils import get_alphabet
>>> M = 4
>>> alphabet = get_alphabet("QAM", M)
>>> demapper = SymbolDemapper(alphabet)
>>> symbols = np.array([-0.70710678+0.70710678j, 0.70710678-0.70710678j, 0.70710678+0.70710678j, -0.70710678-0.70710678j, -0.70710678-0.70710678j])
>>> output = demapper(symbols)
>>> print(output)
[0 3 2 1 1]