Last active
July 20, 2019 13:58
-
-
Save littlebenlittle/0e240e3816466a713c03283194f0756e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%display latex | |
def get_vecs(n): | |
'''Get the orthonormal basis vectors of RR^n''' | |
vecs = [] | |
for i in range(n): | |
vecs.append([1 if x == i else 0 for x in range(n)]) | |
return vecs | |
def apply_permutation(lst, perm): | |
return [lst[i-1] for i in perm] | |
def get_matr(p): | |
return matrix( | |
apply_permutation( | |
get_vecs(len(p)), | |
p | |
), | |
sparse=True | |
) | |
def get_isomorphism_classes(n): | |
isomorphism_classes = dict() | |
for p in Permutations(n): | |
M1 = get_matr(p) | |
G1 = MatrixGroup([M1]) | |
is_new = True # is this a new isomorphism class? | |
for k in isomorphism_classes.keys(): | |
M2 = get_matr(isomorphism_classes[k][0]) | |
G2 = MatrixGroup([M2]) | |
if G1.is_isomorphic(G2): | |
is_new = False | |
isomorphism_classes[k].append(p) | |
continue | |
if is_new: | |
isomorphism_classes[str(p)] = [p] | |
return isomorphism_classes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment