<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , print_function <EOL> import time <EOL> import scipy . weave as weave <EOL> from numpy import * <EOL> def Ramp ( result , size , start , end ) : <EOL> step = ( end - start ) / ( size - <NUM_LIT:1> ) <EOL> for i in xrange ( size ) : <EOL> result [ i ] = start + step * i <EOL> def Ramp_numeric1 ( result , start , end ) : <EOL> code = """<STR_LIT>""" <EOL> weave . inline ( code , [ '<STR_LIT:result>' , '<STR_LIT:start>' , '<STR_LIT:end>' ] , compiler = '<STR_LIT>' ) <EOL> def Ramp_numeric2 ( result , start , end ) : <EOL> code = """<STR_LIT>""" <EOL> weave . inline ( code , [ '<STR_LIT:result>' , '<STR_LIT:start>' , '<STR_LIT:end>' ] , compiler = '<STR_LIT>' ) <EOL> def Ramp_list1 ( result , start , end ) : <EOL> code = """<STR_LIT>""" <EOL> weave . inline ( code , [ "<STR_LIT:result>" , "<STR_LIT:start>" , "<STR_LIT:end>" ] , verbose = <NUM_LIT:2> ) <EOL> def Ramp_list2 ( result , start , end ) : <EOL> code = """<STR_LIT>""" <EOL> weave . inline ( code , [ "<STR_LIT:result>" , "<STR_LIT:start>" , "<STR_LIT:end>" ] , verbose = <NUM_LIT:2> ) <EOL> def main ( ) : <EOL> N_array = <NUM_LIT> <EOL> N_py = <NUM_LIT:200> <EOL> N_c = <NUM_LIT> <EOL> ratio = float ( N_c ) / N_py <EOL> arr = [ <NUM_LIT:0> ] * N_array <EOL> t1 = time . time ( ) <EOL> for i in xrange ( N_py ) : <EOL> Ramp ( arr , N_array , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t2 = time . time ( ) <EOL> py_time = ( t2 - t1 ) * ratio <EOL> print ( '<STR_LIT>' , py_time ) <EOL> print ( '<STR_LIT>' , arr [ <NUM_LIT> ] ) <EOL> arr1 = array ( [ <NUM_LIT:0> ] * N_array , float ) <EOL> Ramp_numeric1 ( arr1 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t1 = time . time ( ) <EOL> for i in xrange ( N_c ) : <EOL> Ramp_numeric1 ( arr1 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t2 = time . time ( ) <EOL> c_time = ( t2 - t1 ) <EOL> print ( '<STR_LIT>' , c_time , py_time / c_time ) <EOL> print ( '<STR_LIT>' , arr1 [ <NUM_LIT> ] ) <EOL> arr2 = array ( [ <NUM_LIT:0> ] * N_array , float ) <EOL> Ramp_numeric2 ( arr2 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t1 = time . time ( ) <EOL> for i in xrange ( N_c ) : <EOL> Ramp_numeric2 ( arr2 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t2 = time . time ( ) <EOL> c_time = ( t2 - t1 ) <EOL> print ( '<STR_LIT>' , c_time , py_time / c_time ) <EOL> print ( '<STR_LIT>' , arr2 [ <NUM_LIT> ] ) <EOL> arr3 = [ <NUM_LIT:0> ] * N_array <EOL> Ramp_list1 ( arr3 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t1 = time . time ( ) <EOL> for i in xrange ( N_py ) : <EOL> Ramp_list1 ( arr3 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t2 = time . time ( ) <EOL> c_time = ( t2 - t1 ) * ratio <EOL> print ( '<STR_LIT>' , c_time , py_time / c_time ) <EOL> print ( '<STR_LIT>' , arr3 [ <NUM_LIT> ] ) <EOL> arr4 = [ <NUM_LIT:0> ] * N_array <EOL> Ramp_list2 ( arr4 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t1 = time . time ( ) <EOL> for i in xrange ( N_py ) : <EOL> Ramp_list2 ( arr4 , <NUM_LIT:0.0> , <NUM_LIT:1.0> ) <EOL> t2 = time . time ( ) <EOL> c_time = ( t2 - t1 ) * ratio <EOL> print ( '<STR_LIT>' , c_time , py_time / c_time ) <EOL> print ( '<STR_LIT>' , arr4 [ <NUM_LIT> ] ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
