[docs]classSymbolPrecoder(Precoder,ABC):"""Abstract base class for signal processing algorithms operating on complex data symbols streams. A symbol precoder represents one coding step of a full symbol precoding configuration. It features the `encoding` and `decoding` routines, meant to encode and decode multidimensional symbol streams during transmission and reception, respectively. """
[docs]@abstractmethoddefencode(self,symbols:StatedSymbols)->StatedSymbols:"""Encode a data stream before transmission. This operation may modify the number of streams as well as the number of data symbols per stream. Args: symbols (StatedSymbols): Symbols to be encoded. Returns: Encoded symbols. Raises: NotImplementedError: If an encoding operation is not supported. """...# pragma no cover
[docs]@abstractmethoddefdecode(self,symbols:StatedSymbols)->StatedSymbols:"""Decode a data stream before reception. This operation may modify the number of streams as well as the number of data symbols per stream. Args: symbols (Symbols): Symbols to be decoded. Returns: Decoded symbols. Raises: NotImplementedError: If a decoding operation is not supported. """...# pragma no cover
[docs]classSymbolPrecoding(Precoding[SymbolPrecoder],Serializable):"""Channel SymbolPrecoding configuration for wireless transmission of modulated data symbols. Symbol precoding may occur as an intermediate step between bit-mapping and base-band symbol modulations. In order to account for the possibility of multiple antenna data-streams, waveform generators may access the `SymbolPrecoding` configuration to encode one-dimensional symbol streams into multi-dimensional symbol streams during transmission and subsequently decode during reception. """yaml_tag="SymbolCoding"def__init__(self,modem:BaseModem|None=None)->None:"""Symbol Precoding object initialization. Args: modem (BaseModem, optional): The modem this :class:`SymbolPrecoding` configuration is attached to. """Precoding.__init__(self,modem=modem)
[docs]defencode(self,symbols:StatedSymbols)->StatedSymbols:"""Encode a data stream before transmission. This operation may modify the number of streams as well as the number of data symbols per stream. Args: symbols (StatedSymbols): Symbols to be encoded. Returns: Encoded symbols. Raises: NotImplementedError: If an encoding operation is not supported. """# Iteratively apply each encoding stepencoded_symbols=symbols.copy()forprecoderinself:encoded_symbols=precoder.encode(encoded_symbols)returnencoded_symbols
[docs]defdecode(self,symbols:StatedSymbols)->StatedSymbols:"""Decode a data stream before reception. This operation may modify the number of streams as well as the number of data symbols per stream. Args: symbols (StatedSymbols): Symbols to be decoded. Returns: Decoded symbols. Raises: NotImplementedError: If an encoding operation is not supported. """decoded_symbols=symbols.copy()forprecoderinreversed(self):decoded_symbols=precoder.decode(decoded_symbols)returndecoded_symbols
[docs]defnum_encoded_blocks(self,num_input_blocks:int)->int:"""Number of blocks after encoding. Args: num_input_blocks (int): Number of blocks before encoding. Returns: Number of blocks after encoding. """num_blocks=Fraction(num_input_blocks,1)forprecoderinself:num_blocks/=precoder.ratereturnint(num_blocks)