#NEWLINE# def _acs_traceback( r_codeword , trellis , decoding_type , path_metrics , paths , decoded_symbols , decoded_bits , tb_count , t , count , tb_depth , current_number_states ) : #NEWLINE# #INDENT# k = trellis . k #NEWLINE# n = trellis . n #NEWLINE# number_states = trellis . number_states #NEWLINE# number_inputs = trellis . number_inputs #NEWLINE# branch_metric = 0.0 #NEWLINE# next_state_table = trellis . next_state_table #NEWLINE# output_table = trellis . output_table #NEWLINE# pmetrics = np . empty ( number_inputs ) #NEWLINE# i_codeword_array = np . empty ( n , 'int' ) #NEWLINE# index_array = np . empty ( [ number_states , 2 ] , 'int' ) #NEWLINE# decoded_bitarray = np . empty ( k , 'int' ) #NEWLINE# for state_num in xrange ( current_number_states ) : #NEWLINE# #INDENT# number_found = _where_c ( next_state_table , number_states , number_inputs , state_num , index_array ) #NEWLINE# for i in xrange ( number_found ) : #NEWLINE# #INDENT# previous_state = index_array [ ( i , 0 ) ] #NEWLINE# previous_input = index_array [ ( i , 1 ) ] #NEWLINE# i_codeword = output_table [ ( previous_state , previous_input ) ] #NEWLINE# i_codeword_array = dec2bitarray ( i_codeword , n ) #NEWLINE# if ( decoding_type == 'hard' ) : #NEWLINE# #INDENT# branch_metric = hamming_dist ( r_codeword . astype ( int ) , i_codeword_array . astype ( int ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( decoding_type == 'soft' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( decoding_type == 'unquantized' ) : #NEWLINE# #INDENT# i_codeword_array = ( ( 2 * i_codeword_array ) - 1 ) #NEWLINE# branch_metric = euclid_dist ( r_codeword , i_codeword_array ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# pmetrics [ i ] = ( path_metrics [ ( previous_state , 0 ) ] + branch_metric ) #NEWLINE# #UNINDENT# path_metrics [ ( state_num , 1 ) ] = pmetrics . min ( ) #NEWLINE# min_idx = pmetrics . argmin ( ) #NEWLINE# paths [ ( state_num , tb_count ) ] = index_array [ ( min_idx , 0 ) ] #NEWLINE# decoded_symbols [ ( state_num , tb_count ) ] = index_array [ ( min_idx , 1 ) ] #NEWLINE# #UNINDENT# if ( t >= ( tb_depth - 1 ) ) : #NEWLINE# #INDENT# current_state = path_metrics [ : , 1 ] . argmin ( ) #NEWLINE# for j in reversed ( xrange ( 1 , tb_depth ) ) : #NEWLINE# #INDENT# dec_symbol = decoded_symbols [ ( current_state , j ) ] #NEWLINE# previous_state = paths [ ( current_state , j ) ] #NEWLINE# decoded_bitarray = dec2bitarray ( dec_symbol , k ) #NEWLINE# decoded_bits [ ( ( ( ( t - tb_depth ) - 1 ) + ( ( j + 1 ) * k ) ) + count ) : ( ( ( ( t - tb_depth ) - 1 ) + ( ( j + 2 ) * k ) ) + count ) ] = decoded_bitarray #NEWLINE# current_state = previous_state #NEWLINE# #UNINDENT# paths [ : , 0 : ( tb_depth - 1 ) ] = paths [ : , 1 : ] #NEWLINE# decoded_symbols [ : , 0 : ( tb_depth - 1 ) ] = decoded_symbols [ : , 1 : ]