예제 #1
0
def test_row_reading_word():
    t = Tableau()
    assert t.row_reading_word() == tuple()
    assert t == Tableau.from_row_reading_word(t.row_reading_word())

    t = Tableau({(1, 1): 1, (1, 2): 3, (1, 3): 4, (2, 1): 2})
    assert t.row_reading_word() == (2, 1, 3, 4)
    u = Tableau.from_row_reading_word(t.row_reading_word())
    assert t == u
def irsk(pi, n=None):
    if n is None:
        n = pi.rank
    cycles = sorted([(pi(i), i) for i in range(1, n + 1) if i <= pi(i)])
    tab = Tableau()
    for b, a in cycles:
        if a == b:
            tab = tab.add(1, tab.max_column() + 1, a)
        else:
            p, q = InsertionAlgorithm.hecke(tab.row_reading_word() + (a, ))
            i, j = q.find(len(q))[0]
            while j > 1 and (i + 1, j - 1) not in p:
                j = j - 1
            tab = p.add(i + 1, j, b)
    return tab