[docs]classSingleCarrier(SymbolPrecoder,Serializable):"""Single Carrier data symbol precoding step. Takes a on-dimensional input stream and distributes the symbols to multiple output streams. """yaml_tag="SingleCarrier"def__init__(self)->None:"""Single Carrier object initialization."""SymbolPrecoder.__init__(self)
[docs]defencode(self,symbols:StatedSymbols)->StatedSymbols:ifsymbols.num_streams!=1:raiseRuntimeError("Single-Carrier spatial multiplexing only supports one-dimensional input streams during encoding")repeated_symbols=symbols.copy()repeated_symbols.raw=np.repeat(repeated_symbols.raw,self.num_output_streams,axis=0)repeated_symbols.states=np.repeat(repeated_symbols.states,self.num_output_streams,axis=0)returnrepeated_symbols
[docs]defdecode(self,symbols:StatedSymbols)->StatedSymbols:# Decode data using SC receive diversity with N_rx received antennas.## Received signal with equal noise power is assumed, the decoded signal has same noise# level as input. It is assumed that all data points equal noise levels.# Essentially, over all symbol streams for each symbol the one with the strongest response will be selectedsymbols=symbols.copy()dense_states=symbols.dense_states()squeezed_channel_state=dense_states.sum(axis=1,keepdims=False)# Select proper antenna for each symbol timestampantenna_selection=np.argmax(np.abs(squeezed_channel_state),axis=0)new_symbols=np.take_along_axis(symbols.raw,antenna_selection[np.newaxis,::],axis=0)# stream_noises = np.take_along_axis(symbols, antenna_selection.T, axis=0)channel_state_selection=antenna_selection[np.newaxis,np.newaxis,::].repeat(2,axis=1)new_states=np.take_along_axis(dense_states,channel_state_selection,axis=0)symbols.raw=new_symbolssymbols.states=new_statesreturnsymbols