def test_GQ_to_GP_expansion(): # noqa for mu in Partition.all(25, strict=True): print('mu =', mu) print() print(Partition.printable(mu, shifted=True)) print() n = len(mu) q = GQ(n, mu) expansion = SymmetricPolynomial.GP_expansion(q) normalized = Vector({ tuple(nu[i] - mu[i] for i in range(len(mu))): c * sgn(mu, nu) * BETA**(sum(nu) - sum(mu)) / 2**(len(mu) - sum(nu) + sum(mu)) for nu, c in expansion.items() }) unsigned = all(c > 0 for c in normalized.values()) print(' mu =', mu, 'n =', n) print(' expansion =', expansion) print(' normalized expansion =', normalized) assert all(len(nu) == 0 or max(nu) <= 1 for nu in normalized) assert all(len(nu) == len(mu) for nu in expansion) assert all(Partition.contains(nu, mu) for nu in expansion) assert all(c % 2**(len(mu) - sum(nu) + sum(mu)) == 0 for nu, c in expansion.items()) assert unsigned expected = { tuple(mu[i] + a[i] for i in range(len(a))) for a in zero_one_tuples(len(mu)) if all( mu[i - 1] + a[i - 1] > mu[i] + a[i] for i in range(1, len(a))) } print(' expected =', expected) assert set(expansion) == expected print() print()
def test_gq_to_gp_expansion(): # noqa for mu in Partition.all(15, strict=True): print('mu =', mu) print() print(Partition.printable(mu, shifted=True)) print() n = len(mu) q = gq(n, mu) expansion = SymmetricPolynomial.gp_expansion(q) print(' mu =', mu, 'n =', n) print(' expansion =', expansion) assert all(len(nu) == len(mu) for nu in expansion) assert all(Partition.contains(mu, nu) for nu in expansion) # assert all(c % 2**(len(mu) - sum(nu) + sum(mu)) == 0 for nu, c in expansion.items()) expected = {} for a in zero_one_tuples(len(mu)): if not all(mu[i - 1] - a[i - 1] > mu[i] - a[i] for i in range(1, len(a))): continue if not all(mu[i] - a[i] > 0 for i in range(len(a))): continue nu = Partition.trim(tuple(mu[i] - a[i] for i in range(len(a)))) coeff = 2**(len(nu) - sum(a)) * sgn(nu, mu) * BETA**sum(a) assert coeff != 0 expected[nu] = coeff print(' expected =', expected) assert expansion == Vector(expected) print() print()
def stable_grothendieck_doublebar(cls, num_variables, mu, nu=(), degree_bound=None): # noqa ans = SymmetricPolynomial() if Partition.contains(mu, nu): for x in Partition.remove_inner_corners(nu): ans += BETA**(sum(nu) - sum(x)) * cls._stable_grothendieck( num_variables, mu, x, degree_bound) return ans
def test_contains(): mu = (1, ) nu = () assert Partition.contains(mu, mu) assert Partition.contains(mu, nu) assert not Partition.contains(nu, mu) mu = (3, 2, 1) nu = (3, 2) assert Partition.contains(mu, mu) assert Partition.contains(mu, nu) assert not Partition.contains(nu, mu) mu = (3, 2, 1) nu = (1, 1, 1) assert Partition.contains(mu, nu) assert not Partition.contains(nu, mu) mu = (1, 1, 1, 1) nu = (1, 1, 1) assert Partition.contains(mu, nu) assert not Partition.contains(nu, mu)
def test_skew_GP_positivity(): # noqa k = 10 for mu in Partition.all(k, strict=True): for nu in Partition.all(k, strict=True): if not Partition.contains(mu, nu): continue n = len(mu) f = GP(n, mu, nu) expansion = SymmetricPolynomial.GP_expansion(f) normalized = Vector({ lam: c * BETA**(sum(lam) - sum(mu) + sum(nu)) for lam, c in expansion.items() }) print('GP_{%s/%s}(x_%s) =' % (mu, nu, n), normalized) print() assert all(c > 0 for c in normalized.values())
def test_staircase_grothendieck_GP_positivity(): # noqa r = 6 for k in range(r): delta = tuple(k - i for i in range(k)) for nu in Partition.all(sum(delta)): if not Partition.contains(delta, nu): continue n = len(delta) f = G(n, delta, nu) expansion = SymmetricPolynomial.GP_expansion(f) normalized = Vector({ lam: c * BETA**(sum(lam) - sum(delta) + sum(nu)) for lam, c in expansion.items() }) print('G_{%s/%s}(x_%s) =' % (delta, nu, n), normalized) print() assert all(c > 0 for c in normalized.values())
def test_strict_symmetric_functions(): nn = 5 for mu in Partition.all(nn, strict=True): for nu in Partition.all(nn, strict=True): for n in range(nn): print(n, mu, nu) print() # Schur-P and GP f = SymmetricPolynomial.schur_p(n, mu, nu) g = SymmetricPolynomial.stable_grothendieck_p(n, mu, nu) h = SymmetricPolynomial.dual_stable_grothendieck_p(n, mu, nu) fs = SymmetricPolynomial._slow_schur_p(n, mu, nu) gs = SymmetricPolynomial._slow_stable_grothendieck_p(n, mu, nu) hs = SymmetricPolynomial._slow_dual_stable_grothendieck_p( 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() print() assert f == fs assert g == gs assert h == hs if mu == nu: assert f == 1 assert g == 1 assert h == 1 assert fs == 1 assert gs == 1 assert hs == 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 # Schur-Q and GQ f = SymmetricPolynomial.schur_q(n, mu, nu) g = SymmetricPolynomial.stable_grothendieck_q(n, mu, nu) h = SymmetricPolynomial.dual_stable_grothendieck_q(n, mu, nu) fs = SymmetricPolynomial._slow_schur_q(n, mu, nu) gs = SymmetricPolynomial._slow_stable_grothendieck_q(n, mu, nu) hs = SymmetricPolynomial._slow_dual_stable_grothendieck_q( 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() print() assert f == fs assert g == gs assert h == hs if mu == nu: assert f == 1 assert g == 1 assert h == 1 assert fs == 1 assert gs == 1 assert hs == 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
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