def main():
   """
   Generates a random matrix and
   applies the rules for Conway's game of life.
   """
   r = 0.2  # ratio of nonzeroes
   # n = 100  # dimension of the matrix
   n = input('give the dimension : ')
   A = np.random.rand(n,n)
   A = np.matrix(A < r,np.uint8)
   start_time = clock()
   for i in range(n): A = update(A)
   stop_time = clock()
   elapsed = stop_time - start_time
   print 'elapsed time', elapsed, 'seconds'
def main():
   """
   Generates a random matrix and
   applies the rules for Conway's
   game of life.
   """
   r = 0.2  # ratio of nonzeroes
   # n = 100  # dimension of the matrix
   n = input('give the dimension : ')
   A = np.random.rand(n,n)
   A = np.matrix(A < r,np.uint8)
   for i in xrange(10*n):
      S = sparse.coo_matrix(A)
      x = S.row; y = S.col
      plot(x,y,'r.',axis=[-1, n, -1, n], \
           title='stage %d' % i)
      A = update(A)