Skip to content

Commit f119d2c

Browse files
committed
fix the ordering and add doctests
1 parent a37eb29 commit f119d2c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/sage/rings/polynomial/multi_polynomial_ring_base.pyx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,9 +1380,15 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
13801380
sage: mons = R.monomials_of_degree(2)
13811381
sage: mons
13821382
[z^2, y*z, x*z, y^2, x*y, x^2]
1383-
sage: P = PolynomialRing(QQ, 3, 'x,y,z', order=TermOrder('wdeglex', [1,2,1]))
1383+
sage: P = PolynomialRing(QQ, 3, 'x, y, z', order=TermOrder('wdeglex', [1, 2, 1]))
13841384
sage: P.monomials_of_degree(2)
1385-
[y, z^2, x*z, x^2]
1385+
[z^2, y, x*z, x^2]
1386+
sage: P = PolynomialRing(QQ, 3, 'x, y, z', order='lex')
1387+
sage: P.monomials_of_degree(3)
1388+
[z^3, y*z^2, y^2*z, y^3, x*z^2, x*y*z, x*y^2, x^2*z, x^2*y, x^3]
1389+
sage: P = PolynomialRing(QQ, 3, 'x, y, z', order='invlex')
1390+
sage: P.monomials_of_degree(3)
1391+
[x^3, x^2*y, x*y^2, y^3, x^2*z, x*y*z, y^2*z, x*z^2, y*z^2, z^3]
13861392
13871393
The number of such monomials equals `\binom{n+k-1}{k}`
13881394
where `n` is the number of variables and `k` the degree::
@@ -1392,7 +1398,9 @@ cdef class MPolynomialRing_base(sage.rings.ring.CommutativeRing):
13921398
"""
13931399
deg_of_gens = [x.degree() for x in self.gens()]
13941400
from sage.combinat.integer_vector_weighted import WeightedIntegerVectors
1395-
return [self.monomial(*a) for a in WeightedIntegerVectors(degree, deg_of_gens)]
1401+
mons = [self.monomial(*a) for a in WeightedIntegerVectors(degree, deg_of_gens)]
1402+
mons.sort() # This could be implemented in WeightedIntegerVectors instead
1403+
return mons
13961404

13971405
def _macaulay_resultant_getS(self, mon_deg_tuple, dlist):
13981406
r"""

0 commit comments

Comments
 (0)