FLINT fmpz_poly class wrapper#
AUTHORS:
Robert Bradshaw (2007-09-15) Initial version.
William Stein (2007-10-02) update for new flint; add arithmetic and creation of coefficients of arbitrary size.
- class sage.libs.flint.fmpz_poly_sage.Fmpz_poly[source]#
Bases:
SageObject
Construct a new fmpz_poly from a sequence, constant coefficient, or string (in the same format as it prints).
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: Fmpz_poly([1,2,3]) 3 1 2 3 sage: Fmpz_poly(5) 1 5 sage: Fmpz_poly(str(Fmpz_poly([3,5,7]))) 3 3 5 7
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> Fmpz_poly([Integer(1),Integer(2),Integer(3)]) 3 1 2 3 >>> Fmpz_poly(Integer(5)) 1 5 >>> Fmpz_poly(str(Fmpz_poly([Integer(3),Integer(5),Integer(7)]))) 3 3 5 7
- degree()[source]#
The degree of self.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2,3]); f 3 1 2 3 sage: f.degree() 2 sage: Fmpz_poly(range(1000)).degree() 999 sage: Fmpz_poly([2,0]).degree() 0
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(2),Integer(3)]); f 3 1 2 3 >>> f.degree() 2 >>> Fmpz_poly(range(Integer(1000))).degree() 999 >>> Fmpz_poly([Integer(2),Integer(0)]).degree() 0
- derivative()[source]#
Return the derivative of self.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2,6]) sage: f.derivative().list() == [2, 12] True
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(2),Integer(6)]) >>> f.derivative().list() == [Integer(2), Integer(12)] True
- div_rem(other)[source]#
Return self / other, self, % other.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,3,4,5]) sage: g = f^23 sage: g.div_rem(f)[1] 0 sage: g.div_rem(f)[0] - f^22 0 sage: f = Fmpz_poly([1..10]) sage: g = Fmpz_poly([1,3,5]) sage: q, r = f.div_rem(g) sage: q*f+r 17 1 2 3 4 4 4 10 11 17 18 22 26 30 23 26 18 20 sage: g 3 1 3 5 sage: q*g+r 10 1 2 3 4 5 6 7 8 9 10
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(3),Integer(4),Integer(5)]) >>> g = f**Integer(23) >>> g.div_rem(f)[Integer(1)] 0 >>> g.div_rem(f)[Integer(0)] - f**Integer(22) 0 >>> f = Fmpz_poly((ellipsis_range(Integer(1),Ellipsis,Integer(10)))) >>> g = Fmpz_poly([Integer(1),Integer(3),Integer(5)]) >>> q, r = f.div_rem(g) >>> q*f+r 17 1 2 3 4 4 4 10 11 17 18 22 26 30 23 26 18 20 >>> g 3 1 3 5 >>> q*g+r 10 1 2 3 4 5 6 7 8 9 10
- left_shift(n)[source]#
Left shift self by n.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2]) sage: f.left_shift(1).list() == [0,1,2] True
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(2)]) >>> f.left_shift(Integer(1)).list() == [Integer(0),Integer(1),Integer(2)] True
- list()[source]#
Return self as a list of coefficients, lowest terms first.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([2,1,0,-1]) sage: f.list() [2, 1, 0, -1]
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(2),Integer(1),Integer(0),-Integer(1)]) >>> f.list() [2, 1, 0, -1]
- pow_truncate(exp, n)[source]#
Return self raised to the power of exp mod x^n.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2]) sage: f.pow_truncate(10,3) 3 1 20 180 sage: f.pow_truncate(1000,3) 3 1 2000 1998000
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(2)]) >>> f.pow_truncate(Integer(10),Integer(3)) 3 1 20 180 >>> f.pow_truncate(Integer(1000),Integer(3)) 3 1 2000 1998000
- right_shift(n)[source]#
Right shift self by n.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,2]) sage: f.right_shift(1).list() == [2] True
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(2)]) >>> f.right_shift(Integer(1)).list() == [Integer(2)] True
- truncate(n)[source]#
Return the truncation of self at degree n.
EXAMPLES:
sage: from sage.libs.flint.fmpz_poly_sage import Fmpz_poly sage: f = Fmpz_poly([1,1]) sage: g = f**10; g 11 1 10 45 120 210 252 210 120 45 10 1 sage: g.truncate(5) 5 1 10 45 120 210
>>> from sage.all import * >>> from sage.libs.flint.fmpz_poly_sage import Fmpz_poly >>> f = Fmpz_poly([Integer(1),Integer(1)]) >>> g = f**Integer(10); g 11 1 10 45 120 210 252 210 120 45 10 1 >>> g.truncate(Integer(5)) 5 1 10 45 120 210