[docs]classTransmitSymbolEncoder(TransmitEncoder["TransmitSymbolCoding"]):def__init__(self)->None:# Initialize base class, required for static type checkingTransmitEncoder.__init__(self)
[docs]@abstractmethoddefencode_symbols(self,symbols:StatedSymbols,num_output_streams:int)->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. num_output_streams (int): Number of required output streams after encoding. Returns: Encoded symbols. """...# pragma: no cover
@property@abstractmethoddefnum_transmit_input_symbols(self)->int:"""Required number of input streams during encoding."""...# pragma: no cover@property@abstractmethoddefnum_transmit_output_symbols(self)->int:"""Resulting number of output streams after encoding."""...# pragma: no cover@propertydefencode_rate(self)->Fraction:"""Rate between input symbol slots and output symbol slots."""returnFraction(self.num_transmit_input_symbols,self.num_transmit_output_symbols)
[docs]classReceiveSymbolDecoder(ReceiveDecoder["ReceiveSymbolCoding"]):def__init__(self)->None:# Initialize base class, required for static type checkingReceiveDecoder.__init__(self)
[docs]@abstractmethoddefdecode_symbols(self,symbols:StatedSymbols,num_output_streams:int)->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. num_output_streams (int): Number of required output streams after decoding. Returns: Decoded symbols. """...# pragma: no cover
@property@abstractmethoddefnum_receive_input_symbols(self)->int:"""Required number of input streams during decoding."""...# pragma: no cover@property@abstractmethoddefnum_receive_output_symbols(self)->int:"""Resulting number of output streams after decoding."""...# pragma: no cover@propertydefdecode_rate(self)->Fraction:"""Rate between input symbol slots and output symbol slots."""returnFraction(self.num_receive_output_symbols,self.num_receive_input_symbols)
classTransmitSymbolCoding(TransmitPrecoding[TransmitSymbolEncoder],Serializable):"""Channel precoding configuration for wireless transmission of modulated data symbols. Transmit symbol precoding occurs as an intermediate step between bit-mapping and base-band symbol modulation. """yaml_tag="TransmitSymbolCoding"defencode_symbols(self,symbols:StatedSymbols,num_output_streams:int)->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. num_output_streams (int): Number of required output streams after encoding. Returns: Encoded symbols. """num_encoder_io_streams=self._collect_encoder_num_io_streams(num_output_streams)# Iteratively apply each encoding stepencoded_symbols=symbols.copy()forprecoder,num_output_streamsinzip(self.__iter__(),num_encoder_io_streams[1:]):encoded_symbols=precoder.encode_symbols(encoded_symbols,num_output_streams)returnencoded_symbols@propertydefencode_rate(self)->Fraction:"""Rate between input symbol slots and output symbol slots."""r=Fraction(1,1)forsymbol_precoderinself:r*=symbol_precoder.encode_ratereturnrdefnum_encoded_blocks(self,num_input_blocks:int)->int:"""Number of resulting symbol 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.encode_ratereturnint(num_blocks)classReceiveSymbolCoding(ReceivePrecoding[ReceiveSymbolDecoder],Serializable):"""Channel precoding configuration for wireless reception of modulated data symbols. Receive symbol precoding occurs as an intermediate step between base-band demodulation and bit unmapping. """yaml_tag="ReceiveSymbolCoding"defdecode_symbols(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. """# Collect number of output streams for each decodernum_decoder_io_streams=self._collect_decoder_num_io_streams(symbols.num_streams)decoded_symbols=symbols.copy()fordecoder,num_output_streamsinzip(self,num_decoder_io_streams[1:]):decoded_symbols=decoder.decode_symbols(decoded_symbols,num_output_streams)returndecoded_symbols@propertydefdecode_rate(self)->Fraction:"""Rate between input symbol slots and output symbol slots."""r=Fraction(1,1)forsymbol_precoderinself:r*=symbol_precoder.decode_ratereturnrdefnum_decoded_blocks(self,num_input_blocks:int)->int:"""Number of resulting symbol blocks after decoding. Args: num_input_blocks (int): Number of blocks before decoding. Returns: Number of blocks after decoding. """num_blocks=Fraction(num_input_blocks,1)forprecoderinreversed(self):num_blocks/=precoder.decode_ratereturnint(num_blocks)