diff --git a/islpy/__init__.py b/islpy/__init__.py index 1c64e1b20b9b60d555ad5dd816846d22cfbaa67c..2d05572602b40d1633986c68c262fe311a104796 100644 --- a/islpy/__init__.py +++ b/islpy/__init__.py @@ -129,30 +129,6 @@ EXPR_CLASSES = tuple(cls for cls in ALL_CLASSES if "Aff" in cls.__name__ or "Polynomial" in cls.__name__) -def _runs_in_integer_set(s, max_int=None): - if not s: - return - - if max_int is None: - max_int = max(s) - - i = 0 - while i < max_int: - if i in s: - start = i - - i += 1 - while i < max_int and i in s: - i += 1 - - end = i - - yield (start, end-start) - - else: - i += 1 - - def _add_functionality(): # {{{ Context @@ -1209,100 +1185,4 @@ def align_two(obj1, obj2, across_dim_types=False): return (obj1, obj2) -# {{{ performance tweak for dim_{min,max}: project first - -class TooManyInteractingDims(Exception): - pass - - -def _find_aff_dims(aff, dim_types_and_gen_dim_types): - result = [] - - for dt, gen_dt in dim_types_and_gen_dim_types: - for i in range(aff.dim(dt)): - if not aff.get_coefficient_val(dt, i).is_zero(): - result.append((gen_dt, i)) - - result = set(result) - - for i in range(aff.dim(dim_type.div)): - result.update(_find_aff_dims(aff.get_div(i))) - - return result - - -def _transitive_closure(graph_dict): - pass - - -def _find_noninteracting_dims(obj, dt, idx, other_dt, stop_at=6): - if isinstance(obj, BasicSet): - basics = [obj] - elif isinstance(obj, Set): - basics = obj.get_basic_sets() - else: - raise TypeError("unsupported arg type '%s'" % type(obj)) - - connections = [] - for bs in basics: - for c in bs.get_constraints(): - conn = _find_aff_dims( - c.get_aff(), - [(dim_type.param, dim_type.param), (dim_type.in_, dim_type.set)]) - if len(conn) > 1: - connections.append(conn) - - interacting = set([(dt, idx)]) - - while True: - changed_something = False - - # Compute the connected component near (dt, idx) by fixed point iteration - - for conn in connections: - prev_len = len(interacting) - - overlap = interacting & conn - if overlap: - interacting.update(conn) - - if len(interacting) != prev_len: - changed_something = True - - if len(interacting) >= stop_at: - raise TooManyInteractingDims() - - if not changed_something: - break - - return set(range(obj.dim(other_dt))) - set( - idx for dt, idx in interacting - if dt == other_dt) - - -def _eliminate_noninteracting(obj, dt, idx, other_dt): - try: - nonint = _find_noninteracting_dims(obj, dt, idx, other_dt) - - except TooManyInteractingDims: - return obj - - for first, n in _runs_in_integer_set(nonint): - obj = obj.eliminate(other_dt, first, n) - - return obj - - -def dim_min_with_elimination(obj, idx): - obj_elim = _eliminate_noninteracting(obj, dim_type.out, idx, dim_type.param) - return obj_elim.dim_min(idx) - - -def dim_max_with_elimination(obj, idx): - obj_elim = _eliminate_noninteracting(obj, dim_type.out, idx, dim_type.param) - return obj_elim.dim_max(idx) - -# }}} - - # vim: foldmethod=marker