from sage.all import *
import sys

N=2**14

def runit(n, c=3):
    l = []
    #print ' ',
    for i in xrange(c):
        A = random_matrix(GF(2),N,N,density=ZZ(n)/N)
        t = cputime()
        E = A.echelon_form('heuristic')
        l.append(cputime(t))
        #print "% 2.3f"%float(l[-1]),
        sys.stdout.flush()
    print "%2d %6.3f %6.3f %6.3f %6.3f"%(int(n),min(l), sum(l)/c, sorted(l)[c/2+1], max(l))
    return sorted(l)[c/2+1]

L = []
for i in range(1,31):
    L.append((i,runit(i)))
show(line(L),ymin=0)
save(L,"sparse-timings-10-4.sobj")
