From cd7b2fc3a291555099f06191d8971c604dd02ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 30 Apr 2019 21:48:46 +0200 Subject: [PATCH] fix for ntl (simple minded but doing the job) --- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 103e5f4015f..79b19d0c8e6 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -1,4 +1,4 @@ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2005 William Stein # # Distributed under the terms of the GNU General Public License (GPL) @@ -10,9 +10,8 @@ # # The full text of the GPL is available at: # -# http://www.gnu.org/licenses/ -#***************************************************************************** - +# https://www.gnu.org/licenses/ +# **************************************************************************** from __future__ import absolute_import, division, print_function from cysignals.signals cimport sig_on, sig_off @@ -57,7 +56,7 @@ cdef make_ZZ_pX(ZZ_pX_c* x, ntl_ZZ_pContext_class ctx): cdef class ntl_ZZ_pX(object): r""" - The class \class{ZZ_pX} implements polynomial arithmetic modulo $p$. + The class \class{ZZ_pX} implements polynomial arithmetic modulo `p`. Polynomial arithmetic is implemented using the FFT, combined with the Chinese Remainder Theorem. A more detailed description of the @@ -94,16 +93,15 @@ cdef class ntl_ZZ_pX(object): if isinstance(v, ntl_ZZ_pX) and (v).c is self.c: self.x = (v).x - elif isinstance(v, list) or isinstance(v, tuple): - for i from 0 <= i < len(v): - x = v[i] + elif isinstance(v, (list, tuple, range)): + for i, x in enumerate(v): if not isinstance(x, ntl_ZZ_p): - cc = ntl_ZZ_p(x,self.c) + cc = ntl_ZZ_p(x, self.c) else: cc = x ZZ_pX_SetCoeff(self.x, i, cc.x) elif v is not None: - s = str(v).replace(',',' ').replace('L','') + s = str(v).replace(',', ' ').replace('L', '') ccreadstr(self.x, s) def __cinit__(self, v=None, modulus=None): @@ -489,7 +487,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: g = ntl.ZZ_pX([-1,0,1],c) sage: g**10 [1 0 10 0 5 0 0 0 10 0 8 0 10 0 0 0 5 0 10 0 1] @@ -509,7 +507,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([1,2,3],c) sage: g = ntl.ZZ_pX([1,2,3,0],c) sage: f == g @@ -539,7 +537,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([0,0,0,20],c) sage: f.is_zero() True @@ -558,7 +556,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([1,1],c) sage: f.is_one() False @@ -694,7 +692,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(17) + sage: c = ntl.ZZ_pContext(17) sage: f = ntl.ZZ_pX([1,2,3],c) * ntl.ZZ_pX([4,5],c)**2 sage: g = ntl.ZZ_pX([1,1,1],c)**3 * ntl.ZZ_pX([1,2,3],c) sage: f.gcd(g) @@ -813,7 +811,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([],c) sage: f.set_x() sage: f @@ -838,7 +836,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([],c) sage: f.set_x() sage: f.is_x() @@ -1004,7 +1002,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([1,2,3,4,5],c) sage: f.reverse() [5 4 3 2 1] @@ -1097,7 +1095,8 @@ cdef class ntl_ZZ_pX(object): def invert_and_truncate(self, long m): """ - Compute and return the inverse of self modulo $x^m$. + Compute and return the inverse of self modulo `x^m`. + The constant term of self must be a unit. EXAMPLES:: @@ -1201,7 +1200,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([1,2,0,3],c) sage: mod = ntl.ZZ_pX([5,3,-1,1,1],c) sage: f.trace_mod(mod) @@ -1217,20 +1216,21 @@ cdef class ntl_ZZ_pX(object): def trace_list(self): """ - Return the list of traces of the powers $x^i$ of the + Return the list of traces of the powers `x^i` of the monomial x modulo this polynomial for i = 0, ..., deg(f)-1. + This polynomial must be monic. EXAMPLES:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([1,2,0,3,0,1],c) sage: f.trace_list() [5, 0, 14, 0, 10] The input polynomial must be monic or a ValueError is raised:: - sage: c=ntl.ZZ_pContext(20) + sage: c = ntl.ZZ_pContext(20) sage: f = ntl.ZZ_pX([1,2,0,3,0,2],c) sage: f.trace_list() Traceback (most recent call last): @@ -1276,7 +1276,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(17) + sage: c = ntl.ZZ_pContext(17) sage: f = ntl.ZZ_pX([1,2,0,3],c) sage: mod = ntl.ZZ_pX([-5,2,0,0,1],c) sage: f.norm_mod(mod) @@ -1327,7 +1327,7 @@ cdef class ntl_ZZ_pX(object): EXAMPLES:: - sage: c=ntl.ZZ_pContext(17) + sage: c = ntl.ZZ_pContext(17) sage: f = ntl.ZZ_pX([1,2,0,3],c) sage: mod = ntl.ZZ_pX([-5,2,0,0,1],c) sage: f.charpoly_mod(mod)