Example #1
0
    def _shifted_rpp_horizontal_strips(cls, mu):  # noqa
        assert Partition.is_strict_partition(mu)
        if mu == ():
            return [(mu, set())]

        def remove_box(nu, i):
            if i < len(nu) and nu[i] > 0:
                nu = nu[:i] + (nu[i] - 1, ) + nu[i + 1:]
                while nu and nu[-1] == 0:
                    nu = nu[:-1]
                if all(nu[j] > nu[j + 1] for j in range(len(nu) - 1)):
                    yield nu

        def remove_all_boxes(nu, i):
            queue = [nu]
            while queue:
                nu, queue = queue[0], queue[1:]
                yield nu
                for x in remove_box(nu, i):
                    queue.append(x)

        ans = set()
        queue = [(mu, len(mu) - 1)]
        while queue:
            nu, i = queue[0]
            queue = queue[1:]
            if i >= 0:
                for nu in remove_all_boxes(nu, i):
                    ans.add(nu)
                    queue.append((nu, i - 1))

        return [(nu, Partition.skew(mu, nu, shifted=True)) for nu in ans]
Example #2
0
    def _shifted_rpp_vertical_strips(cls, mu):  # noqa
        assert Partition.is_strict_partition(mu)
        if mu == ():
            return [(mu, set())]

        def remove_box(nu, i):
            for j in range(len(nu) - 1, -1, -1):
                if j + nu[j] == i + 1:
                    nu = nu[:j] + (nu[j] - 1, ) + nu[j + 1:]
                    while nu and nu[-1] == 0:
                        nu = nu[:-1]
                    yield nu
                    return

        def remove_all_boxes(nu, i):
            queue = [nu]
            while queue:
                nu, queue = queue[0], queue[1:]
                yield nu
                for x in remove_box(nu, i):
                    queue.append(x)

        ans = set()
        queue = [(mu, (mu[0] if mu else 0) - 1)]
        while queue:
            nu, i = queue[0]
            queue = queue[1:]
            if i >= 0:
                for nu in remove_all_boxes(nu, i):
                    ans.add(nu)
                    queue.append((nu, i - 1))

        return [(nu, Partition.skew(mu, nu, shifted=True)) for nu in ans]
def is_reducible(nu, mu):
    if len(nu) == 0:
        return True
    if any(nu[i] == mu[i] for i in range(len(mu))):
        return True
    if sum(nu) - sum(mu) <= 3:
        return True


#    if any(nu[i] + 1 < mu[i - 1] for i in range(1, len(nu))):
#        return True
#    if nu == mu:
#        return True
# if Partition.get(nu, 1) <= Partition.get(mu, 1) + 1:
#    return True

    skew = Partition.skew(nu, mu, shifted=True)
    (i, j) = min(skew, key=lambda ij: (-ij[0], ij[1]))
    while True:
        if (i - 1, j) in skew:
            (i, j) = (i - 1, j)
        elif (i, j + 1) in skew:
            (i, j) = (i, j + 1)
        else:
            break
    if (i, j) != max(skew, key=lambda ij: (-ij[0], ij[1])):
        return True
Example #4
0
    def _rpp_horizontal_strips(cls, mu, lam):  # noqa
        if mu == lam:
            return [(mu, set())]

        if not Partition.contains(mu, lam):
            return []

        def remove_box(nu, i):
            if i < len(nu) and nu[i] > 0:
                nu = nu[:i] + (nu[i] - 1, ) + nu[i + 1:]
                while nu and nu[-1] == 0:
                    nu = nu[:-1]
                if all(nu[j] >= nu[j + 1] for j in range(len(nu) - 1)):
                    if Partition.contains(nu, lam):
                        yield nu

        def remove_all_boxes(nu, i):
            queue = [nu]
            while queue:
                nu, queue = queue[0], queue[1:]
                yield nu
                for x in remove_box(nu, i):
                    queue.append(x)

        ans = set()
        queue = [(mu, len(mu) - 1)]
        while queue:
            nu, i = queue[0]
            queue = queue[1:]
            if i >= 0:
                for nu in remove_all_boxes(nu, i):
                    ans.add(nu)
                    queue.append((nu, i - 1))

        return [(nu, Partition.skew(mu, nu)) for nu in ans]
Example #5
0
    def from_shifted_growth_diagram(cls, growth, edges, corners):
        def shdiff(nu, lam):
            return next(iter(Partition.skew(nu, lam, shifted=True)))

        p, q = Tableau(), Tableau()
        n, m = len(growth) - 1, len(growth[0]) - 1 if growth else 0

        for i in range(1, n + 1):
            mu, nu = growth[i][m], growth[i - 1][m]
            for a, b in Partition.skew(mu, nu, shifted=True):
                p = p.add(a, b, i)

        for i in range(1, m + 1):
            mu, nu = growth[n][i], growth[n][i - 1]
            v = -i if edges[n][i] else i
            j = corners[n][i]
            if mu != nu:
                a, b = shdiff(mu, nu)
                q = q.add(a, b, v)
            elif v < 0:
                x = q.last_box_in_column(j)
                q = q.add(x, j, v)
            else:
                x = q.last_box_in_row(j)
                q = q.add(j, x, v)

        return p, q
def split(nu, mu):
    if (nu, mu) not in SPLIT_CACHE:
        i, j = None, None
        for lam in lshapes(nu, mu):
            term = Partition.rim_terminal_part(left_rim(nu, mu, lam))
            i = max(([] if i is None else [i]) + [a for (a, _) in term])
            j = min(([] if j is None else [j]) + [b for (_, b) in term])
        for lam in rshapes(nu, mu):
            term = Partition.rim_terminal_part(right_rim(nu, mu, lam))
            i = max(([] if i is None else [i]) + [a for (a, _) in term])
            j = min(([] if j is None else [j]) + [b for (_, b) in term])
        skew = Partition.skew(nu, mu, shifted=True)
        # new_nu = Partition.trim(tuple(min(nu[t], j - t - 1) for t in range(i)) + nu[i:])
        # new_mu = Partition.trim(tuple(min(mu[t], j - t - 1) for t in range(i)) + mu[i:])
        while (i + 1, j) in skew:
            i += 1
        rest = {(a, b) for (a, b) in skew if (a <= i or b >= j)}
        split_nu, split_mu = Partition.from_skew(rest, shifted=False)
        diagonal = any(a == b for (a, b) in skew)
        SPLIT_CACHE[(nu, mu)] = (split_nu, split_mu, diagonal)
    return SPLIT_CACHE[(nu, mu)]
Example #7
0
 def shdiff(nu, lam):
     return next(iter(Partition.skew(nu, lam, shifted=True)))
Example #8
0
 def KLG_counts(cls, nu, mu, p):  # noqa
     rim = tuple(sorted(Partition.skew(nu, mu, shifted=True)))
     return cls._KLG_count_helper(p, rim)
def columns(lam, mu):
    return len({j for (i, j) in Partition.skew(lam, mu, True)})
def right_rim(nu, mu, lam):
    return Partition.skew(lam, mu, shifted=True)
def left_rim(nu, mu, lam):
    return Partition.skew(nu, lam, shifted=True)