#NEWLINE# def turbo_decode( sys_symbols , non_sys_symbols_1 , non_sys_symbols_2 , trellis , noise_variance , number_iterations , interleaver , L_int = None ) : #NEWLINE# #INDENT# ' Turbo Decoder.\n\n    Decodes a stream of convolutionally encoded\n    (rate 1/3) bits using the BCJR algorithm.\n\n    Parameters\n    ----------\n    sys_symbols : 1D ndarray\n        Received symbols corresponding to\n        the systematic (first output) bits in the codeword.\n\n    non_sys_symbols_1 : 1D ndarray\n        Received symbols corresponding to\n        the first parity bits in the codeword.\n\n    non_sys_symbols_2 : 1D ndarray\n        Received symbols corresponding to the\n        second parity bits in the codeword.\n\n    trellis : Trellis object\n        Trellis representation of the convolutional codes\n        used in the Turbo code.\n\n    noise_variance : float\n        Variance (power) of the AWGN channel.\n\n    number_iterations : int\n        Number of the iterations of the\n        BCJR algorithm used in turbo decoding.\n\n    interleaver : Interleaver object.\n        Interleaver used in the turbo code.\n\n    L_int : 1D ndarray\n        Array representing the initial intrinsic\n        information for all received\n        symbols.\n\n        Typically all zeros,\n        corresponding to equal prior\n        probabilities of bits 0 and 1.\n\n    Returns\n    -------\n    decoded_bits : 1D ndarray of ints containing {0, 1}\n        Decoded bit stream.\n\n    ' #NEWLINE# if ( L_int is None ) : #NEWLINE# #INDENT# L_int = zeros ( len ( sys_symbols ) ) #NEWLINE# #UNINDENT# L_int_1 = L_int #NEWLINE# sys_symbols_i = interleaver . interlv ( sys_symbols ) #NEWLINE# for iteration_count in xrange ( number_iterations ) : #NEWLINE# #INDENT# [ L_ext_1 , decoded_bits ] = map_decode ( sys_symbols , non_sys_symbols_1 , trellis , noise_variance , L_int_1 , 'compute' ) #NEWLINE# L_ext_1 = ( L_ext_1 - L_int_1 ) #NEWLINE# L_int_2 = interleaver . interlv ( L_ext_1 ) #NEWLINE# if ( iteration_count == ( number_iterations - 1 ) ) : #NEWLINE# #INDENT# mode = 'decode' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mode = 'compute' #NEWLINE# #UNINDENT# [ L_2 , decoded_bits ] = map_decode ( sys_symbols_i , non_sys_symbols_2 , trellis , noise_variance , L_int_2 , mode ) #NEWLINE# L_ext_2 = ( L_2 - L_int_2 ) #NEWLINE# L_int_1 = interleaver . deinterlv ( L_ext_2 ) #NEWLINE# #UNINDENT# decoded_bits = interleaver . deinterlv ( decoded_bits ) #NEWLINE# return decoded_bits