-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcycles_ACGs_2_spread_gens.py
More file actions
67 lines (55 loc) · 1.67 KB
/
Copy pathcycles_ACGs_2_spread_gens.py
File metadata and controls
67 lines (55 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from graph import AbelianCayley, P, primes
import matplotlib.pyplot as plt
import numpy as np
from numpy import sqrt
from sympy.ntheory import factorint
# want to find graphs with large spectral gaps
# """
gaps = []
for n in range(3, 1259, 2): # primes[P-1], 2):
d = factorint(n)
ps = d.keys() # primes dividing n
gp = [] # characterization of the group
gens = [(1,)*len(ps), (-1,)*len(ps)] # generators of the group. already includes first generator (1)
new_gen1 = [] # corresp. to n//2. will be converted (cast) into tuple
new_gen2 = [] # corresp. to -n//2. will be converted (cast) into tuple
for p in ps:
gp.append((primes.index(p), d[p]))
pe = p**d[p]
new_gen1.append( (n//2) % pe )
new_gen2.append( (-(n//2)) % pe )
gens.append(tuple(new_gen1))
gens.append(tuple(new_gen2))
G = AbelianCayley(gp, gens)
G.find_spectrum()
gaps.append(G.gap)
gaps = np.array(gaps)
# plt.plot([n for n in range(3, 1259, 2)], gaps)
plt.plot([n for n in range(3, 1259, 2)], 1/sqrt(gaps))
plt.show()
plt.close()
"""
gaps = []
for n in primes[1:]: # primes[P-1], 2):
d = factorint(n)
ps = d.keys() # primes dividing n
gp = [] # characterization of the group
gens = [(1,)*len(ps)] # generators of the group. already includes first generator (1)
new_gen = [] # corresp. to n//2. will be converted (cast) into tuple
for p in ps:
gp.append((primes.index(p), d[p]))
pe = p**d[p]
new_gen.append( (n//2) % pe )
gens.append(tuple(new_gen))
# if n < 100: print(gp, gens)
G = AbelianCayley(gp, gens)
G.find_spectrum()
gaps.append(G.gap)
gaps = np.array(gaps)
print(gaps)
# """
# plt.plot([n for n in range(3, 1259, 2)], gaps)
plt.plot(primes[1:], 1/sqrt(gaps))
plt.show()
plt.close()
# """