Last active
August 29, 2015 14:01
-
-
Save amitjamadagni/ffa19aa6aae0ef988bfe to your computer and use it in GitHub Desktop.
Seifert Matrix
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
from sage.groups.free_group import FreeGroupElement | |
from sage.groups.braid import Braid | |
#from sage.matrix.matrix_integer_dense import Matrix_integer_dense, delete_rows | |
class Link: | |
def __init__(self, input = None, gauss_code = None, dt_code = None): | |
if type(input) == sage.groups.braid.Braid: | |
self._braid = input | |
self._gauss_code = None | |
self._dt_code = None | |
elif gauss_code != None: | |
self._braid = None | |
self._gauss_code = gauss_code | |
self._dt_code = None | |
elif dt_code != None: | |
self._braid = None | |
self._gauss_code = None | |
self._dt_code = dt_code | |
def braid(self): | |
if self._braid != None: | |
return self._braid | |
elif self._gauss_code != None: | |
return "Not implemented Error" | |
elif self._dt_code != None: | |
return "Not Implemented Error" | |
def gauss_code(self): | |
if self._gauss_code != None: | |
return self._gauss_code | |
elif self._braid != None: | |
return "Not Implemented Error" | |
elif self._dt_code != None: | |
return "Not Implemented Error" | |
def dt_code(self): | |
if self._dt_code != None: | |
return self._dt_code | |
elif self._braid != None: | |
return "Not Implemented Error" | |
elif self._gauss_code != None: | |
return "Not Implemented Error" | |
def braidcomponentsmatrix(self): | |
b = self.braid() | |
ml = list(b.Tietze()) | |
l = [abs(k) for k in ml] | |
sorting1 = list(set(range(l[0],max(l)+1)) - set(l)) | |
sorting = list(set(range(l[0],max(l)+1)) - set(sorting1)) | |
missing = [] | |
difference = [] | |
difference.append(sorting[0] -1) | |
for i in range(1, len(sorting)): | |
difference.append(sorting[i] - sorting[i-1]) | |
missing = list(set(range(sorting[0],sorting[-1]+1)) - set(sorting)) | |
if len(missing) == 0: | |
A = matrix(QQ,1,len(ml),ml) | |
return A | |
else: | |
A = matrix(QQ, len(missing) + 1, len(l)) | |
for i in range(len(missing) + 1): | |
k = 0 | |
for j in range(len(l)): | |
if i == 0: | |
if (abs(l[j]) < missing[i]): | |
A[0, k] = ml[j] | |
k = k + 1 | |
elif i>len(missing): | |
if missing[i] < abs(x[j]): | |
A[i, k] = ml[j] | |
k = k + 1 | |
else: | |
if(missing[i-1] < abs(l[j])): | |
A[i, k] = ml[j] | |
k = k + 1 | |
for i in range(len(missing) + 1): | |
l1 = list(A.row(i)) | |
M = min(l1) | |
if M == 0: | |
a = min(n for n in l1 if n!=M) | |
for j in range(len(l)): | |
if(A[i,j] != a): | |
A[i,j] = 0 | |
for i in range(len(missing) + 1): | |
for k in range(i+1, len(missing) + 1): | |
if(A[i,0] == A[k,0]): | |
A1 = A.delete_rows([k]) | |
return A1 #here the components should be returned in rows and columns | |
def braidwordcompenetsvector(self): | |
A = self.braidcomponentsmatrix() | |
if(A.nrows()>0): | |
x2 = [] | |
for i in range(A.nrows()): | |
for j in range(A.ncols()): | |
x2.append(A[i,j]) | |
x3 = [value for value in x2 if value != 0] | |
return x3 | |
else: | |
x3 = A.row(1) | |
return list(x3) | |
def homology_generators(self): | |
x4 = list(self.braid().Tietze()) | |
hom_gen = [] | |
for j in range(len(x4)-1): | |
a = abs(x4[j]) | |
for i in range(j+1, len(x4)): | |
if(a == abs(x4[i])): | |
hom_gen.append(i) | |
break | |
else: | |
hom_gen.append(0) | |
return hom_gen | |
def Seifert_Matrix(self): | |
x5 = self.braidwordcompenetsvector() | |
h = self.homology_generators() | |
hl = len(h) | |
A = matrix(QQ, hl, hl) | |
for i in range(hl): | |
if h[i] != 0: | |
for j in range(i,hl): | |
if i == j: | |
A[i,j] = -cmp((x5[i] + x5[h[i]]),0) | |
elif (h[i] > h[j]): | |
A[i,j] = 0 | |
A[j,i] = 0 | |
elif (h[i] < j): | |
A[i,j] = 0 | |
A[j,i] = 0 | |
elif (h[i] == j): | |
if(x5[j] > 0): | |
A[i,j] = 0 | |
A[j,i] = 1 | |
else: | |
A[i,j] = -1 | |
A[j,i] = 0 | |
elif abs(abs(x5[i]) - abs(x5[j])) > 1: | |
A[i,j] = 0 | |
elif (abs(x5[i]) - abs(x5[j]) == 1): | |
A[i,j] = 0 | |
A[j,i] = -1 | |
elif (abs(x5[j])- abs(x5[i]) == 1): | |
A[i,j] = 1 | |
A[j,i] = 0 | |
else: | |
A[i,j] = 2 | |
A[j,i] = 2 | |
else: | |
for k in range(hl): | |
A[k,i] = 0 | |
A[i,k] = 0 | |
#a check to see remove the zero rows | |
for i in range(hl): | |
if(list(A.row(i))) == [0 for i in range(hl)]: | |
print "a" | |
A.delete_rows([i]) | |
return A | |
B = BraidGroup(8) | |
L = Link(B([-1, 4, 1, 4, 1, 6])) | |
t1 = L.braidcomponentsmatrix() | |
print t1 | |
t2 = L.braidwordcompenetsvector() | |
print t2 | |
t3 = L.homology_generators() | |
print t3 | |
t4 = L.Seifert_Matrix() | |
print t4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment