def _test(n_max, v_max):
    for n in range(n_max + 1):
        for v in range(1, v_max + 1):
            for lam1 in Partition.all(n):
                for lam2 in Partition.all(n):
                    print()
                    print()
                    print('* v =', v, ', n =', n, ', mu =', lam1, ', nu =',
                          lam2)
                    print()

                    print('Computing LHS . . .')
                    print()

                    s = Polynomial()
                    for mu in Partition.all(n + max(sum(lam1), sum(lam2))):
                        a = SymmetricPolynomial.stable_grothendieck_doublebar(
                            v, mu, lam1).truncate(n).polynomial('x')
                        b = SymmetricPolynomial.dual_stable_grothendieck(
                            v, mu, lam2).truncate(n).polynomial('y')
                        s += (a * b).truncate(n)
                        print('  ', mu, ':', s, '|', a, '|', b)
                        print()
                    print('LHS =', s)
                    print()
                    print()

                    print('Computing RHS . . .')
                    print()

                    f = Polynomial.one()
                    x = Polynomial.x
                    y = Polynomial.y
                    for i in range(1, v + 1):
                        for j in range(1, v + 1):
                            a = x(i) * y(j)
                            term = Polynomial.one()
                            for e in range(1, n + 1):
                                term += a**e
                            f = (f * term).truncate(n)
                    print('  ', '   :', f)
                    print()

                    t = Polynomial()
                    for kappa in Partition.subpartitions(lam2):
                        a = SymmetricPolynomial.stable_grothendieck_doublebar(
                            v, lam2, kappa).truncate(n)
                        b = SymmetricPolynomial.dual_stable_grothendieck(
                            v, lam1, kappa).truncate(n)
                        t += (f * a.polynomial('x') *
                              b.polynomial('y')).truncate(n)
                        print('  ', kappa, ':', t)
                        print()

                    print('RHS =', t)
                    print()
                    print()
                    print('diff =', s - t)
                    print()
                    assert s == t
def test_symmetric_functions():
    nn = 6
    for mu in Partition.all(nn):
        for nu in Partition.all(nn, strict=True):
            for n in range(nn):
                print(n, mu, nu)
                print()

                f = SymmetricPolynomial.schur(n, mu, nu)
                g = SymmetricPolynomial.stable_grothendieck(n, mu, nu)
                h = SymmetricPolynomial.dual_stable_grothendieck(n, mu, nu)

                fs = SymmetricPolynomial._slow_schur(n, mu, nu)
                gs = SymmetricPolynomial._slow_stable_grothendieck(n, mu, nu)
                hs = SymmetricPolynomial._slow_dual_stable_grothendieck(
                    n, mu, nu)

                if f != fs:
                    print(f)
                    print(fs)
                    print()
                if g != gs:
                    print(g)
                    print(gs)
                    print()
                if h != hs:
                    print(h)
                    print(hs)
                    print()
                    print()

                assert f == fs
                assert g == gs
                assert h == hs

                hh = SymmetricPolynomial.schur_s(n, mu, nu)
                kk = SymmetricPolynomial.stable_grothendieck_s(n, mu, nu)

                if mu == nu:
                    assert f == 1
                    assert g == 1
                    assert h == 1
                    assert fs == 1
                    assert gs == 1
                    assert hs == 1
                    assert hh == 1
                    assert kk == 1

                if not Partition.contains(mu, nu):
                    assert f == 0
                    assert g == 0
                    assert h == 0
                    assert fs == 0
                    assert gs == 0
                    assert hs == 0
                    assert hh == 0
                    assert kk == 0

                print(f)
                print(g)
                print()
                print(hh)
                print(kk)
                print()
                assert g.lowest_degree_terms() == f
                assert kk.lowest_degree_terms() == hh
Exemplo n.º 3
0
def dual_grothendieck(num_variables, mu, nu=()):  # noqa
    return SymmetricPolynomial.dual_stable_grothendieck(num_variables, mu, nu)