def compute_boundary_operators(self): #: Matrix form of boundary operators; the `i`-th differential #: `D[i]` is `dim C[i-1]` rows (range) by `dim C[i]` columns #: (domain). m = self.module # micro-optimization D = DifferentialComplex() D.append(NullMatrix, 0, len(m[0])) for i in xrange(1, len(self)): timing.start("D[%d]" % i) p = len(m[i - 1]) # == dim C[i-1] q = len(m[i]) # == dim C[i] try: checkpoint = os.path.join(runtime.options.checkpoint_dir, ('M%d,%d-D%d.sms' % (runtime.g, runtime.n, i))) except AttributeError: checkpoint = None # maybe load `D[i]` from persistent storage if checkpoint and p > 0 and q > 0 and runtime.options.restart: d = SimpleMatrix(p, q) if d.load(checkpoint): D.append(d, p, q) logging.info(" Loaded %dx%d matrix D[%d] from file '%s'", p, q, i, checkpoint) continue # with next `i` # compute `D[i]` d = SimpleMatrix(p, q) j0 = 0 for pool1 in m[i].iterblocks(): k0 = 0 for pool2 in m[i - 1].iterblocks(): for edgeno in xrange(pool1.graph.num_edges): if pool1.graph.is_loop(edgeno): continue # with next `edgeno` for (j, k, s) in NumberedFatgraphPool.facets( pool1, edgeno, pool2): assert k < len(pool2) assert j < len(pool1) assert k + k0 < p assert j + j0 < q d.addToEntry(k + k0, j + j0, s) k0 += len(pool2) # # `pool2` will never be used again, so clear it from the cache. # # XXX: using implementation detail! # pool2.graph._cache_isomorphisms.clear() j0 += len(pool1) # `pool1` will never be used again, so clear it from the cache. # XXX: using implementation detail! pool1.graph._cache_isomorphisms.clear() timing.stop("D[%d]" % i) if checkpoint: d.save(checkpoint) D.append(d, p, q) logging.info(" Computed %dx%d matrix D[%d] (elapsed: %.3fs)", p, q, i, timing.get("D[%d]" % i)) return D
def compute_boundary_operators(self): #: Matrix form of boundary operators; the `i`-th differential #: `D[i]` is `dim C[i-1]` rows (range) by `dim C[i]` columns #: (domain). m = self.module # micro-optimization D = DifferentialComplex() D.append(NullMatrix, 0, len(m[0])) for i in xrange(1, len(self)): timing.start("D[%d]" % i) p = len(m[i-1]) # == dim C[i-1] q = len(m[i]) # == dim C[i] try: checkpoint = os.path.join(runtime.options.checkpoint_dir, ('M%d,%d-D%d.sms' % (runtime.g, runtime.n, i))) except AttributeError: checkpoint = None # maybe load `D[i]` from persistent storage if checkpoint and p>0 and q>0 and runtime.options.restart: d = SimpleMatrix(p, q) if d.load(checkpoint): D.append(d, p, q) logging.info(" Loaded %dx%d matrix D[%d] from file '%s'", p, q, i, checkpoint) continue # with next `i` # compute `D[i]` d = SimpleMatrix(p, q) j0 = 0 for pool1 in m[i].iterblocks(): k0 = 0 for pool2 in m[i-1].iterblocks(): for edgeno in xrange(pool1.graph.num_edges): if pool1.graph.is_loop(edgeno): continue # with next `edgeno` for (j, k, s) in NumberedFatgraphPool.facets(pool1, edgeno, pool2): assert k < len(pool2) assert j < len(pool1) assert k+k0 < p assert j+j0 < q d.addToEntry(k+k0, j+j0, s) k0 += len(pool2) # # `pool2` will never be used again, so clear it from the cache. # # XXX: using implementation detail! # pool2.graph._cache_isomorphisms.clear() j0 += len(pool1) # `pool1` will never be used again, so clear it from the cache. # XXX: using implementation detail! pool1.graph._cache_isomorphisms.clear() timing.stop("D[%d]" % i) if checkpoint: d.save(checkpoint) D.append(d, p, q) logging.info(" Computed %dx%d matrix D[%d] (elapsed: %.3fs)", p, q, i, timing.get("D[%d]" % i)) return D
i0 = 0 while thresholds[i0] < i: i0 += 1 i0 -= 1 return (i0, i-i0) def labelfn(D, i): i0, i1 = matrix_index_to_G(i) return ("G_{%d,%d}^{(%d)}" % (num_edges-1, i0, i)) p = len(all_graphs[num_edges-1]) if (num_edges-1 in all_graphs) else 0 q = len(all_graphs[num_edges]) if (num_edges in all_graphs) else 0 r = num_edges - min_num_edges + 1 matrix_file = os.path.join(dir, ("M%d,%d-D%d.sms" % (g,n,r))) if os.path.exists(matrix_file): d = SimpleMatrix(p, q) d.load(matrix_file) k0 = 0 for j, G in enumerate(graphs): pool = pools[j] name = ("G_{%d,%d}" % (num_edges, j)) orientable = G.is_oriented() outfile.start_graph(name, G, pool) # print automorphisms Aut = list(G.automorphisms()) if len(Aut) > 1: outfile.add_automorphisms(Aut) if pool[0].is_oriented(): # print markings if n > 1: outfile.add_markings(name, pool)