<s> import numpy as np <EOL> def fdtd ( input_grid , steps ) : <EOL> grid = input_grid . copy ( ) <EOL> old_grid = np . zeros_like ( input_grid ) <EOL> previous_grid = np . zeros_like ( input_grid ) <EOL> l_x = grid . shape [ <NUM_LIT:0> ] <EOL> l_y = grid . shape [ <NUM_LIT:1> ] <EOL> for i in range ( steps ) : <EOL> previous_grid [ : , : ] = old_grid <EOL> old_grid [ : , : ] = grid <EOL> for x in range ( l_x ) : <EOL> for y in range ( l_y ) : <EOL> grid [ x , y ] = <NUM_LIT:0.0> <EOL> if x + <NUM_LIT:1> < l_x : <EOL> grid [ x , y ] += old_grid [ x + <NUM_LIT:1> , y ] <EOL> if <NUM_LIT:0> < x - <NUM_LIT:1> and x - <NUM_LIT:1> < l_x : <EOL> grid [ x , y ] += old_grid [ x - <NUM_LIT:1> , y ] <EOL> if y + <NUM_LIT:1> < l_y : <EOL> grid [ x , y ] += old_grid [ x , y + <NUM_LIT:1> ] <EOL> if <NUM_LIT:0> < y - <NUM_LIT:1> and y - <NUM_LIT:1> < l_y : <EOL> grid [ x , y ] += old_grid [ x , y - <NUM_LIT:1> ] <EOL> grid [ x , y ] /= <NUM_LIT> <EOL> grid [ x , y ] -= previous_grid [ x , y ] <EOL> return grid <EOL> N = <NUM_LIT:1000> <EOL> steps = <NUM_LIT:20> <EOL> input_grid = np . random . randn ( N , N ) . astype ( '<STR_LIT>' ) <EOL> import parakeet <EOL> parakeet . config . print_generated_code = True <EOL> from compare_perf import compare_perf <EOL> compare_perf ( fdtd , [ input_grid , steps ] , backends = ( '<STR_LIT:c>' , '<STR_LIT>' , '<STR_LIT>' ) ) </s>
