-
-
Notifications
You must be signed in to change notification settings - Fork 684
Open
Description
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.
Component: algebra
Issue created by migration from https://trac.sagemath.org/ticket/18419