def getKnotFloerHomology(rect): from genGen import gen import generators import homology import getOptiEllipses reload(homology) reload(generators) ellCandidate = getOptiEllipses.simple(rect, 1) print ellCandidate tmp = ellCandidate.pop() rect = tmp[3] print rect ell = (tmp[1], tmp[2]) print "ellipses:" print ell print "score:", tmp[0] print "new Diagram:" print rectDiagMisc.toStringNice(rect) (tmp, bound, pool, index) = generators.classifiedGen(rect, ell, 1) ##INDEX ## index-=1 print "index", index print "Scale:A and M: ", bound print "Generators, tabulated by Maslov and Alexander grading:" from homology import transpose transposed = transpose(tmp) def format(s, l): if len(s) < l: return " " * (l - len(s)) + s return s for i in transposed: s = "" for j in i: s += format(str(len(j)), 6) + " " print s ##the bdMap stuff HDEll = hdEllipsesGen(ell[0], ell[1]) (to0, toPlus, chEll) = hdCond(rect, HDEll) ## print "to0,toPlus,chell" ## print to0 ## print toPlus ## print chEll delta = hdCond2(rect, HDEll, to0, toPlus) path = preparePath(rect, ell) print "path", path ##the deepBd stuff init = deepBdMap2.initWith(rect, ell) ## print "deep2!" ## print "hdEllipses" ## print HDEll ## def eulerP(tab): ## k=[0]*(len(tab[0])) ## for i in range(len(tab[0])): ## tot=0 ## for j in range(len(tab)): ## tot=len(tab[j][i])-tot ## k[i]=tot ## return k ## print eulerP(tmp) cache = bdMapPsgenCache(rect, ell, pool) fillFValue( tmp, cache, ell, to0, toPlus, chEll, delta ) ##new####################################################################### ## cache2=bdMapGolay.bdMapPsgenCache(rect,ell,pool) ## a=raw_input("w") tmp2 = homology.chain2DToHomv3( tmp, lambda x, y: bdMap(rect, x, y, cache, ell, to0, toPlus, chEll, delta, path, init), len(rect) - 1, index ) return (bound, transpose(tmp2))
(gen1.yShift[a] + 1) / 2, b + (gen1.xShift[b] + 1) / 2, gen1.perm[b] + (gen1.yShift[b] + 1) / 2): return False return True elif l == 1: raise RuntimeError("1 of diff") raise RuntimeError("error in boundary") if __name__ == "__main__": rect0 = [[0, 2], [1, 3], [0, 2], [1, 3]] rect1 = [[0, 2], [1, 3], [0, 2], [1, 3]] rect2 = [[0, 1], [0, 1]] rect = [[1, 4], [0, 2], [1, 3], [2, 4], [0, 3]] tmp = classifiedGen(rect, 0)[0] print("second phase") tmp = chain2DToHomv2(tmp, lambda x, y: isBndryLargeEll(rect, x, y)) def format(s, l): if len(s) < l: return " " * (l - len(s)) + s return s for i in tmp: s = "" for j in i: s += format(str(j), 5) + " " print(s)
def getKnotFloerHomology(rect): """ INPUT: a grid diagram ? """ ellCandidate = getOptiEllipses.simple(rect, 1) print(ellCandidate) tmp = ellCandidate.pop() rect = tmp[3] print(rect) ell = (tmp[1], tmp[2]) print("ellipses:") print(ell) print("score:", tmp[0]) print("new Diagram:") print(rectDiagMisc.toStringNice(rect)) tmp, b, pool, index = generators.classifiedGen(rect, ell, 1) print("index", index) print("Scale:A and M: ", b) print("Generators, tabulated by Maslov and Alexander grading:") transposed = transpose(tmp) def format(s, l): if len(s) < l: return " " * (l - len(s)) + s return s for i in transposed: s = "" for j in i: s += format(str(len(j)), 6) + " " print(s) # the bdMap stuff HDEll = hdEllipsesGen(ell[0], ell[1]) to0, toPlus, chEll = hdCond(rect, HDEll) delta = hdCond2(rect, HDEll, to0, toPlus) path = preparePath(rect, ell) print("path", path) # the deepBd stuff init = deepBdMap2.initWith(rect, ell) # def eulerP(tab): # k=[0]*(len(tab[0])) # for i in range(len(tab[0])): # tot = 0 # for j in range(len(tab)): # tot = len(tab[j][i])-tot # k[i] = tot # return k # print(eulerP(tmp)) cache = bdMapPsgenCache(rect, ell, pool) fillFValue(tmp, cache, ell, to0, toPlus, chEll, delta) # new # cache2=bdMapGolay.bdMapPsgenCache(rect, ell, pool) # a=raw_input("w") def coeff(x, y): return bdMap(rect, x, y, cache, ell, to0, toPlus, chEll, delta, path, init) tmp2 = homology.chain2DToHomv3(tmp, coeff, len(rect) - 1, index) return transpose(tmp2)
if __name__ == "__main__": ##rect=[[0,2],[1,3],[0,2],[1,3]] ##rect=[[0,2],[1,3],[0,2],[1,3]] rect=[[0,1],[0,1]] rect=[[1,4],[0,2],[1,3],[2,4],[0,3]] ## rect=[[0,1],[0,2],[1,2]] ## a=gen([-1, 4, 3, 0, 2], [0, -1, -1, 1, -1], [0, 1, 1, 1, -1]) ## b=gen([-1, 4, 3, 0, 2], [0, -1, 1, 1, -1], [0, 1, 1, 1, -1]) ## print isBndryLargeEll(rect,a,b) tmp=classifiedGen(rect,0)[0] print "second phase" import profile profile.run("tmp=homology.chain2DToHomv2(tmp,lambda x,y:isBndryLargeEll(rect,x,y))") ## tmp=homology.chain2DToHomv2(tmp,lambda x,y:isBndryLargeEll(rect,x,y)) def format(s,l): if len(s)<l: return " "*(l-len(s))+s return s for i in tmp: s="" for j in i: s+=format(str(j),5)+" " print s