#18940: Simplify __getitem__ for polynomials and deprecate slicing
-------------------------------------+-------------------------------------
       Reporter:  pbruin             |        Owner:
           Type:  defect             |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.10
      Component:  algebra            |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Peter Bruin,       |    Reviewers:
  Jeroen Demeyer                     |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:                     |  1c56779b3140d12fbe5d0973cdcad0ac9dbb8054
  u/pbruin/18940-getitem_step        |     Stopgaps:
   Dependencies:  #19409             |
-------------------------------------+-------------------------------------
Changes (by {'newvalue': u'Peter Bruin, Jeroen Demeyer', 'oldvalue': u'Peter 
Bruin'}):

 * status:  needs_info => needs_work
 * author:  Peter Bruin => Peter Bruin, Jeroen Demeyer


Old description:

> Sage should support a `step` different from 1 in the `__getitem__()`
> method of polynomials:
> {{{
> sage: R.<x> = ZZ[]
> sage: f = sum(x^j for j in range(5))
> sage: f
> x^4 + x^3 + x^2 + x + 1
> sage: f[-2:4:2]
> x^3 + x^2 + x + 1  # should be x^2 + 1
> }}}
> We fix this for most classes by implementing a generic `__getitem__()`
> method, which depends on a new Cython method `get_unsafe()` to get single
> coefficients.  Overall, this greatly simplifies the code.  It is
> conceivable that there is a small performance loss (I have not tested
> this), but it is unlikely that there is any speed-critical code that
> heavily depends on `__getitem__()` with a slice argument.  For the
> remaining affected classes (Python classes, sparse polynomials), we fix
> `__getitem__()` in a similar way.
>
> This fix allows us to simplify the method
> `PowerSeries_poly.__getitem__()`.  Also, the patch corrects some
> (previously wrong) slice bounds in
> `LaurentPolynomial_univariate.__getitem__()`.

New description:

 For polynomials, we implementing a generic `__getitem__()` method, which
 depends on a new Cython method `get_unsafe()` to get single coefficients.
 Overall, this greatly simplifies the code.  Slicing for polynomials is
 deprecated, since there is no clear use case and it is not mathematically
 well-defined what the answer should be (see also comment [comment:39] and
 further below).

 This fix allows us to simplify the method
 `PowerSeries_poly.__getitem__()`.  Also, the patch corrects some
 (previously wrong) slice bounds in
 `LaurentPolynomial_univariate.__getitem__()`.

--

--
Ticket URL: <http://trac.sagemath.org/ticket/18940#comment:45>
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.

Reply via email to