applications.runtime_oriented_matroids

Runtime of Oriented Matroids

Runtime of Oriented Matroids

We demonstrate how to test the runtime of the package sign_vectors:

sage: from sign_vectors import *

Integers

We generate a random integer matrix and time the computation of its circuits:

sage: P = random_matrix(ZZ, 5, 10)
sage: om = OrientedMatroid(P)
sage: om.circuits() # random
{(00--0---+0),
 (0--++0+00-),
...
 (-+0+0+0++0)}

An oriented matroid remembers the signs of the maximal minors it has computed, so repeated calls of om.circuits() are faster than the first one. Therefore, we time the computation for a new oriented matroid:

sage: timeit("OrientedMatroid(P).circuits()") # long time, random
125 loops, best of 3: 4.09 ms per loop

Real Algebraic Numbers

Next, we consider a matrix over the real algebraic numbers:

sage: P = random_matrix(AA, 3, 6)
sage: om = OrientedMatroid(P)
sage: om.circuits() # random
{(-00++-),
 (-++00-),
...
 (00--++)}
sage: timeit("OrientedMatroid(P).circuits()") # long time, random
125 loops, best of 3: 3.01 ms per loop