#18585: Comparison of sparse polynomials
-------------------------------------+-------------------------------------
Reporter: bruno | Owner:
Type: defect | Status: needs_review
Priority: major | Milestone: sage-6.8
Component: commutative | Resolution:
algebra | Merged in:
Keywords: polynomials | Reviewers:
Authors: Bruno Grenet | Work issues:
Report Upstream: N/A | Commit:
Branch: | 1726058568171c77880ac9d00684ffc00c0b1492
u/bruno/compare_sparse_polynomials | Stopgaps:
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by bruno):
Replying to [comment:7 vdelecroix]:
> 1. You can replace
> {{{
> keys1 = list(reversed(sorted(d1.keys())))
> }}}
> with
> {{{
> keys1 = d1.keys()
> keys1.reverse()
> }}}
Done, with the added `keys1.sort()` before the `reverse()`.
> 2. Instead of looking at the length, you can do
> {{{
> if not keys1 and not keys2: return 0
> if not keys1: return -1
> if not keys2: return 1
> }}}
Also done.
> 3. Why the first key is treated differently?
This is to comply with the default `_cmp_` method for polynomials: for
instance `-2x^2 > x` but `x^3 - 2x^2 < x^3 + x`. A larger degree
polynomial is always greater than a lower degree polynomial, but then when
the coefficients are compared, `0` is greater than a negative coefficient.
--
Ticket URL: <http://trac.sagemath.org/ticket/18585#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.