This repository was archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for ntl (simple minded but doing the job)
- Loading branch information
Showing
1 changed file
with
25 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
@@ -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 (<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): | ||
|
@@ -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) | ||
|