Comment #1 on issue 2434 by [email protected]: Polynomials are sorted
incorrectly w.r.t. the grevlex term order
http://code.google.com/p/sympy/issues/detail?id=2434
I believe I know why it doesn't work: Polynomials (at least sd polynomials)
are sorted via
def sdp_sort(f, O):
"""Sort terms in `f` using the given monomial order `O`. """
return sorted(f, key=lambda term: O(term[0]), reverse=True)
where O is either monomial_lex_key, monomial_grlex_key or
monomial_grevlex_key. The code for the last one is:
def monomial_grevlex_key(monom):
"""Key function for sorting monomials in reversed graded lexicographic
order. """
return (sum(monom), tuple(reversed(monom)))
Again, for (0, 0, 2) and (0, 1, 1) it will compare (2, (2, 0, 0)) and (2,
(1, 1, 0)). However this swaps the actual results, since for grevlex you
would have to switch the first and second monomial (i.e.
cmp(tuple(reversed(second)), tuple(reversed(first))) ) as in
monomial_grevlex_cmp.
I guess the easiest solution would be to have a special cmp function for
this purpose.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.