Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix for ntl (simple minded but doing the job)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed May 1, 2019
1 parent 5ba5a5a commit cd7b2fc
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/sage/libs/ntl/ntl_ZZ_pX.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2005 William Stein <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -94,16 +93,15 @@ cdef class ntl_ZZ_pX(object):

if isinstance(v, ntl_ZZ_pX) and (<ntl_ZZ_pX>v).c is self.c:
self.x = (<ntl_ZZ_pX>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):
Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cd7b2fc

Please sign in to comment.