diff --git a/graph_tools/misc.py b/graph_tools/misc.py index bc737e9ed45f91de72465cbb177a84a68aa67ea5..11c5fe4cbafb447deb75ef1d67ea7b81952f8f4d 100644 --- a/graph_tools/misc.py +++ b/graph_tools/misc.py @@ -176,10 +176,22 @@ def _init_(): return m - # FIXME k cemu je to dobry? - def edge_model_join_matrix(P, k): + def edge_model_join_matrix(P, k, threads=1): + from sage.all import matrix, QQ + from parmap import parmap + BG = [ FakeGadget(k, [ BoundaryValue(b, 1) ]) for b in P.enumerate_boundaries(k) ] - return parameter_matrix(P, BG) + inp = ( (r, c) for r in range(len(BG)) for c in range(len(BG)) ) + + def worker(x): + r, c = x + return (r, c, edge_model_join(BG[r], BG[c]).eval(P, no_cache=True)) + + m = matrix(QQ, len(BG), len(BG), sparse=True) + for r, c, v in parmap(worker, inp, nprocs=threads, in_order=False): + m[r, c] = v + + return m def enumerate_diamond_matchings(k):