# Ticket #14136: trac_14136-p_partition_enumerator-review-ts.patch

File trac_14136-p_partition_enumerator-review-ts.patch, 3.4 KB (added by tscrim, 8 years ago)
• ## sage/combinat/posets/posets.py

# HG changeset patch
# User Travis Scrimshaw <tscrim@ucdavis.edu>
# Date 1368112575 25200
diff --git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
 a class FinitePoset(UniqueRepresentation, def p_partition_enumerator(self, tup, R, check=False): r""" return a P-partition enumerator of self This is a quasisymmetric function which depends on a total order on the vertices of the poset. Return a P-partition enumerator of self. Given a total order \prec on the vertices of a poset P, a P-parition enumerator is the quasisymmetric function \sum_f \prod_{p \in P} x_{f(p)}, where the first sum is taken over all P-partitions f. A P-partition is a function f : P \to \{1,2,3,...\} satisfying the following properties for any two elements i and j of P: - if i \prec j then f(i) \leq f(j), - if j \prec i then f(j) < f(i). INPUT: - tup -- tuple: the elements of P in some total order; this does not have to be a linear extension. - R -- commutative ring - tup -- A tuple of elements of P representing a total order (this does not have to be a linear extension) - R -- A commutative ring OUTPUT: the P-partition enumerator of self according to tup in the The P-partition enumerator of self according to tup in the algebra QSym over the base ring R. This is the quasisymmetric function \sum\limits_{f\text{ a }P\text{-partition}} \prod\limits_{p \in P} x_{f(p)}, where a P-partition is a function P \to \{1,2,3,...\} satisfying the following properties: For any two elements i and j of P, - if i < j then f(i) \leq f(j), - if i < j and i appears left of j in tup then f(i) < f(j). EXAMPLES:: sage: P = Poset([[1,2,3,4],[[1,4],[2,4],[4,3]]]) sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, check=True);FP sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, check=True); FP 2*M[1, 1, 1, 1] + 2*M[1, 2, 1] + M[2, 1, 1] + M[3, 1] sage: expansion = FP.expand(5) class FinitePoset(UniqueRepresentation, True sage: P = Poset([[],[]]) sage: FP = P.p_partition_enumerator((), QQ, check=True) ; FP sage: FP = P.p_partition_enumerator((), QQ, check=True); FP M[] """ if check: if sorted(self.list()) != sorted(tup): raise ValueError("the elements of tup are not those of P") from sage.combinat.composition import Composition from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions from sage.combinat.composition import Composition print('no error yet') QR = QuasiSymmetricFunctions(R) print('error is before this line') n = len(tup) res = QR.zero() tupdict = dict(zip(tup, range(n)))