Skip to content
Snippets Groups Projects
Commit 6573707d authored by Radek Hušek's avatar Radek Hušek
Browse files

experiments/flower-snarks: prove that 16 is the largest eigenvalue

parent f6c5aeec
No related branches found
No related tags found
No related merge requests found
......@@ -15,12 +15,49 @@ sys.path.append(os.path.dirname(__file__) + "/..")
from graph_tools.all import *
from sage.all import identity_matrix, QQ, DiGraph, matrix
def deflate_eigenvector(M, u):
coord = min(( r for r in range(u.nrows()) if u[r, 0] > 0 ), key=lambda r: u[r, 0])
a = M[coord, :]
return M - u * a / u[coord, 0]
def bound_spectral_radius(M, bound):
def norm(A):
"""The matrix 1-norm. Max of the sum of columns.
We do not use the norms from Sage because they are slow
for sprase matrices.
"""
sums = [ 0 ] * A.ncols()
for (r, c), v in A.dict().items():
sums[c] += abs(v)
return max(sums)
X = M
p = 1
while True:
b = bound**p
n = norm(X)
print(" p=%i upper bound is %0.3lg" % (p, n**(1/p)))
if n <= b: break
X = X**2
p *= 2
print(" %i <= %i**%i" % (n, bound, p))
def test_eigenvalue(M, x):
H = M - x*identity_matrix(QQ, M.ncols(), sparse=True)
if H.is_singular():
print(" Value %i is an eigenvalue of M with geometric multiplicity %i" %
(x, H.ncols() - H.rank()))
def matrix_to_rev_graph(M):
assert M.ncols() == M.nrows()
return DiGraph([range(M.ncols()), M.dict().keys()],
......@@ -86,3 +123,9 @@ if __name__ == "__main__":
if vec_[i, 0] > 0 and fin[0, i] > 0:
print(" %s" % (S["variables"][i],))
print("Check that 16 is the largest eigenvalue")
print(" Calculating deflation of the matrix")
D = deflate_eigenvector(M, vec_)
print(" Bounding the spectral radius by 15")
bound_spectral_radius(D, 15)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment