#18419: Extend truncation of polynomials and harmonize with __getitem__
---------------------------+----------------------------
Reporter: vdelecroix | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.7
Component: algebra | Keywords:
Merged in: | Authors:
Reviewers: | Report Upstream: N/A
Work issues: | Branch:
Commit: | Dependencies:
Stopgaps: |
---------------------------+----------------------------
The current `truncate` methods of polynomials is
{{{
cpdef truncate(self, n):
r"""
return self modulo X^n
"""
}}}
In many algorithms it is desirable to have a more general truncation
{{{
cpdef truncate(self, l, h):
r"""
Given a polynomial p = a_0 + a_1 X + ... + a_d X^d return the
polynomial
a_l + a_{l+1} X + ... + a_{h-1] X^h
"""
}}}
It would be the very same semantic than for the `__getitem__`.
{{{
sage: R.<x> = QQ[]
sage: p = 0 + 1*x + 2*x^2 + 3*x^3 + 4*x^4
sage: p[1:3]
2*x^2 + x
sage: p[2:]
4*x^4 + 3*x^3 + 2*x^2
}}}
Currently the `__getitem__` method is a generic one. But for slices of the
form `(a,b,1)` we should rely on `truncate` that can be optimized in
derived classes.
--
Ticket URL: <http://trac.sagemath.org/ticket/18419>
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.