Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdc-counting
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Radek Hušek
cdc-counting
Commits
6573707d
Commit
6573707d
authored
4 years ago
by
Radek Hušek
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
experiments/flower-snarks.py
+43
-0
43 additions, 0 deletions
experiments/flower-snarks.py
with
43 additions
and
0 deletions
experiments/flower-snarks.py
+
43
−
0
View file @
6573707d
...
...
@@ -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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment