def identityDD(pmc, idem_size = None): """Returns the identity type DD structure for a given PMC.""" if idem_size is None: idem_size = pmc.genus n = pmc.n pmcopp = pmc.opp() alg1 = pmc.getAlgebra(idem_size = idem_size) alg2 = pmcopp.getAlgebra(idem_size = 2*pmc.genus - idem_size) ddstr = SimpleDDStructure(F2, alg1, alg2) idems = pmc.getIdempotents(idem_size) idem_pairs = [(idem, idem.opp().comp()) for idem in idems] chord_pairs = [(Strands(pmc, [(i, j)]), Strands(pmcopp, [(n-1-j, n-1-i)])) for i in range(n) for j in range(i+1, n)] ddstr = DDStrFromChords(alg1, alg2, idem_pairs, chord_pairs) # Any generator can serve as base_gen for gen in ddstr.getGenerators(): base_gen = gen break ddstr.registerHDiagram(getIdentityDiagram(pmc), base_gen) return ddstr
def identityDA(pmc): """Returns the identity type DA structure for a given PMC.""" alg = pmc.getAlgebra() dastr = SimpleDAStructure(F2, alg, alg) idems = pmc.getIdempotents() idem_to_gen_map = {} for i in range(len(idems)): cur_gen = SimpleDAGenerator(dastr, idems[i], idems[i], i) idem_to_gen_map[idems[i]] = cur_gen dastr.addGenerator(cur_gen) alg_gen = alg.getGenerators() for gen in alg_gen: if not gen.isIdempotent(): gen_from = idem_to_gen_map[gen.getLeftIdem()] gen_to = idem_to_gen_map[gen.getRightIdem()] dastr.addDelta(gen_from, gen_to, gen, (gen,), 1) # Now add grading. Any generator can serve as base_gen for gen in dastr.getGenerators(): base_gen = gen break dastr.registerHDiagram(getIdentityDiagram(pmc), base_gen) return dastr