@@ -105,7 +105,7 @@ def __init__(self, memory, g_matrix, feedback = 0, code_type = 'default'):
105105 [self .k , self .n ] = g_matrix .shape
106106
107107 if code_type == 'rsc' :
108- for i in xrange (self .k ):
108+ for i in range (self .k ):
109109 g_matrix [i ][i ] = feedback
110110
111111 self .total_memory = memory .sum ()
@@ -117,19 +117,19 @@ def __init__(self, memory, g_matrix, feedback = 0, code_type = 'default'):
117117 self .number_inputs ], 'int' )
118118
119119 # Compute the entries in the next state table and the output table
120- for current_state in xrange (self .number_states ):
120+ for current_state in range (self .number_states ):
121121
122- for current_input in xrange (self .number_inputs ):
122+ for current_input in range (self .number_inputs ):
123123 outbits = np .zeros (self .n , 'int' )
124124
125125 # Compute the values in the output_table
126- for r in xrange (self .n ):
126+ for r in range (self .n ):
127127
128128 output_generator_array = np .zeros (self .k , 'int' )
129129 shift_register = dec2bitarray (current_state ,
130130 self .total_memory )
131131
132- for l in xrange (self .k ):
132+ for l in range (self .k ):
133133
134134 # Convert the number representing a polynomial into a
135135 # bit array
@@ -138,7 +138,7 @@ def __init__(self, memory, g_matrix, feedback = 0, code_type = 'default'):
138138
139139 # Loop over M delay elements of the shift register
140140 # to compute their contribution to the r-th output
141- for i in xrange (memory [l ]):
141+ for i in range (memory [l ]):
142142 outbits [r ] = (outbits [r ] + \
143143 (shift_register [i + l ]* generator_array [i + 1 ])) % 2
144144
@@ -184,7 +184,7 @@ def _generate_states(self, trellis_length, grid, state_order, state_radius, font
184184 """ Private method """
185185 state_patches = []
186186
187- for state_count in xrange (self .number_states * trellis_length ):
187+ for state_count in range (self .number_states * trellis_length ):
188188 state_patch = mpatches .Circle (grid [:,state_count ], state_radius ,
189189 color = "#003399" , ec = "#cccccc" )
190190 state_patches .append (state_patch )
@@ -198,11 +198,11 @@ def _generate_edges(self, trellis_length, grid, state_order, state_radius, edge_
198198 """ Private method """
199199 edge_patches = []
200200
201- for current_time_index in xrange (trellis_length - 1 ):
201+ for current_time_index in range (trellis_length - 1 ):
202202 grid_subset = grid [:,self .number_states * current_time_index :]
203- for state_count_1 in xrange (self .number_states ):
203+ for state_count_1 in range (self .number_states ):
204204 input_count = 0
205- for state_count_2 in xrange (self .number_states ):
205+ for state_count_2 in range (self .number_states ):
206206 dx = grid_subset [0 , state_count_2 + self .number_states ] - grid_subset [0 ,state_count_1 ] - 2 * state_radius
207207 dy = grid_subset [1 , state_count_2 + self .number_states ] - grid_subset [1 ,state_count_1 ]
208208 if np .count_nonzero (self .next_state_table [state_order [state_count_1 ],:] == state_order [state_count_2 ]):
@@ -219,8 +219,8 @@ def _generate_edges(self, trellis_length, grid, state_order, state_radius, edge_
219219 def _generate_labels (self , grid , state_order , state_radius , font ):
220220 """ Private method """
221221
222- for state_count in xrange (self .number_states ):
223- for input_count in xrange (self .number_inputs ):
222+ for state_count in range (self .number_states ):
223+ for input_count in range (self .number_inputs ):
224224 edge_label = str (input_count ) + "/" + str (
225225 self .output_table [state_order [state_count ], input_count ])
226226 plt .text (grid [0 , state_count ]- 1.5 * state_radius ,
@@ -333,16 +333,16 @@ def conv_encode(message_bits, trellis, code_type = 'default', puncture_matrix=No
333333 number_outbits = int ((number_inbits + total_memory )/ rate )
334334
335335 outbits = np .zeros (number_outbits , 'int' )
336- p_outbits = np .zeros (number_outbits *
337- puncture_matrix [0 :].sum ()/ np .size (puncture_matrix , 1 ), 'int' )
336+ p_outbits = np .zeros (int ( number_outbits *
337+ puncture_matrix [0 :].sum ()/ np .size (puncture_matrix , 1 )) , 'int' )
338338 next_state_table = trellis .next_state_table
339339 output_table = trellis .output_table
340340
341341 # Encoding process - Each iteration of the loop represents one clock cycle
342342 current_state = 0
343343 j = 0
344344
345- for i in xrange ( number_inbits / k ): # Loop through all input bits
345+ for i in range ( int ( number_inbits / k ) ): # Loop through all input bits
346346 current_input = bitarray2dec (inbits [i * k :(i + 1 )* k ])
347347 current_output = output_table [current_state ][current_input ]
348348 outbits [j * n :(j + 1 )* n ] = dec2bitarray (current_output , n )
@@ -353,15 +353,15 @@ def conv_encode(message_bits, trellis, code_type = 'default', puncture_matrix=No
353353
354354 term_bits = dec2bitarray (current_state , trellis .total_memory )
355355 term_bits = term_bits [::- 1 ]
356- for i in xrange (trellis .total_memory ):
356+ for i in range (trellis .total_memory ):
357357 current_input = bitarray2dec (term_bits [i * k :(i + 1 )* k ])
358358 current_output = output_table [current_state ][current_input ]
359359 outbits [j * n :(j + 1 )* n ] = dec2bitarray (current_output , n )
360360 current_state = next_state_table [current_state ][current_input ]
361361 j += 1
362362
363363 j = 0
364- for i in xrange (number_outbits ):
364+ for i in range (number_outbits ):
365365 if puncture_matrix [0 ][i % np .size (puncture_matrix , 1 )] == 1 :
366366 p_outbits [j ] = outbits [i ]
367367 j = j + 1
@@ -373,8 +373,8 @@ def _where_c(inarray, rows, cols, search_value, index_array):
373373
374374 #cdef int i, j,
375375 number_found = 0
376- for i in xrange (rows ):
377- for j in xrange (cols ):
376+ for i in range (rows ):
377+ for j in range (cols ):
378378 if inarray [i , j ] == search_value :
379379 index_array [number_found , 0 ] = i
380380 index_array [number_found , 1 ] = j
@@ -407,14 +407,14 @@ def _acs_traceback(r_codeword, trellis, decoding_type,
407407 decoded_bitarray = np .empty (k , 'int' )
408408
409409 # Loop over all the current states (Time instant: t)
410- for state_num in xrange (current_number_states ):
410+ for state_num in range (current_number_states ):
411411
412412 # Using the next state table find the previous states and inputs
413413 # leading into the current state (Trellis)
414414 number_found = _where_c (next_state_table , number_states , number_inputs , state_num , index_array )
415415
416416 # Loop over all the previous states (Time instant: t-1)
417- for i in xrange (number_found ):
417+ for i in range (number_found ):
418418
419419 previous_state = index_array [i , 0 ]
420420 previous_input = index_array [i , 1 ]
@@ -457,7 +457,7 @@ def _acs_traceback(r_codeword, trellis, decoding_type,
457457 current_state = path_metrics [:,1 ].argmin ()
458458
459459 # Traceback Loop
460- for j in reversed (xrange (1 , tb_depth )):
460+ for j in reversed (range (1 , tb_depth )):
461461
462462 dec_symbol = decoded_symbols [current_state , j ]
463463 previous_state = paths [current_state , j ]
@@ -538,7 +538,7 @@ def viterbi_decode(coded_bits, trellis, tb_depth=None, decoding_type='hard'):
538538 count = 0
539539 current_number_states = number_states
540540
541- for t in xrange (1 , ( L + total_memory + total_memory % k )/ k + 1 ):
541+ for t in range (1 , int (( L + total_memory + total_memory % k )/ k ) + 1 ):
542542 # Get the received codeword corresponding to t
543543 if t <= L :
544544 r_codeword = coded_bits [(t - 1 )* n :t * n ]
0 commit comments