Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To slightly elaborate on John's comment, "CombinatorialFreeModule" allows you to specify an arbitrary comparison function on the elements. Here is a sample doctest from sage.categories.modules_with_basis :

            sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename("X"); x = X.basis()
            sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3)
            sage: x.leading_monomial()
            B[3]
            sage: def cmp(x,y): return y-x
            sage: x.leading_monomial(cmp=cmp)
            B[1]

To slightly elaborate on John's comment, "CombinatorialFreeModule" allows you to specify an arbitrary comparison function on the elements. Here is a sample doctest from sage.categories.modules_with_basis :

            sage: X = CombinatorialFreeModule(QQ, [1, 2, 3]); X.rename("X"); x = X.basis()
X.rename("X")
            sage: x = 3*X.monomial(1) + 2*X.monomial(2) + X.monomial(3)
            sage: x.leading_monomial()
            B[3]
            sage: def cmp(x,y): return y-x
            sage: x.leading_monomial(cmp=cmp)
            B[1]