Beispiel #1
0
 def _KOG_count_helper(cls, p, rim):  # noqa
     if len(rim) == 0:
         return 1 if p == 0 else 0
     if p <= 0:
         return 0
     term = Partition.rim_terminal_part(rim)
     if len(term) == 2 and p == 1:
         return 0
     elif len(term) == 2:
         left = tuple(a for a in rim if a not in term)
         x = cls._KOG_count_helper(p, left)
         y = cls._KOG_count_helper(p - 1, left)
         z = cls._KOG_count_helper(p - 2, left)
         c = 2 if p > 2 else 1
         return x + (1 + c) * y + c * z
     else:
         left = tuple(a for a in rim if a != term[-1])
         x = cls._KOG_count_helper(p, left)
         y = cls._KOG_count_helper(p - 1, left)
         c = 2 if p > 1 else 1
         if len(term) == 1:
             return c * (x + y)
         if len(term) == 3 and term[0][0] != term[-1][0] and term[0][
                 1] != term[-1][1]:
             return x + y
         if len(term) == 3:
             return y
def print_rshape(nu, mu, lam):
    lines = []
    for i in range(1, len(nu) + 1):
        line = (i - 1) * [' '] + Partition.get(mu, i) * ['.']
        line += (Partition.get(lam, i) - Partition.get(mu, i)) * ['R']
        line += (Partition.get(nu, i) - Partition.get(lam, i)) * ['*']
        lines += [' '.join(line)]
    print('\n'.join(reversed(lines)) + '\n')
    print('term:', Partition.rim_terminal_part(right_rim(nu, mu, lam)))
    print()
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)]
Beispiel #4
0
 def _KLG_count_helper(cls, p, rim):  # noqa
     if len(rim) == 0:
         return 1 if p == 0 else 0
     if p <= 0:
         return 0
     term = Partition.rim_terminal_part(rim)
     if len(term) == 2:
         left = tuple(a for a in rim if a not in term)
         x = cls._KLG_count_helper(p, left)
         y = cls._KLG_count_helper(p - 1, left)
         z = cls._KLG_count_helper(p - 2, left)
         if p > 2:
             return x + 3 * y + 2 * z
         elif p == 2 and term[0][0] == term[0][1]:
             return 1
         elif p == 2:
             return x + 3 * y + 2 * z
         elif p == 1:
             if term[0][0] == term[0][1] == term[1][0]:
                 return 0
             elif term[0][0] == term[0][1] == term[1][1]:
                 return 1
             else:
                 return x + y
     else:
         left = tuple(a for a in rim if a != term[-1])
         x = cls._KLG_count_helper(p, left)
         y = cls._KLG_count_helper(p - 1, left)
         if len(term) == 1:
             if p == 1 and term[0][0] == term[0][1]:
                 return 1
             else:
                 return 2 * x + 2 * y
         if len(term) == 3 and term[0][0] != term[-1][0] and term[0][
                 1] != term[-1][1]:
             return x + y
         if len(term) == 3:
             return y