Skip to content

Commit 8edced7

Browse files
committed
Revert changes from file and only modify the functions I have included
1 parent 59aafbd commit 8edced7

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

src/sage/rings/polynomial/polynomial_zz_pex.pyx

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ AUTHOR:
1616
from cysignals.signals cimport sig_on, sig_off
1717

1818
from sage.libs.ntl.ntl_ZZ_pEContext cimport ntl_ZZ_pEContext_class
19-
from sage.libs.ntl.ntl_ZZ_pE cimport ntl_ZZ_pE
2019
from sage.libs.ntl.ZZ_pE cimport ZZ_pE_to_ZZ_pX
2120
from sage.libs.ntl.ZZ_pX cimport ZZ_pX_deg, ZZ_pX_coeff
2221
from sage.libs.ntl.ZZ_p cimport ZZ_p_rep
@@ -26,22 +25,23 @@ from sage.libs.ntl.convert cimport ZZ_to_mpz
2625
# to make sure the function get_cparent is found since it is used in
2726
# 'polynomial_template.pxi'.
2827

29-
cdef cparent get_cparent(parent) except ? NULL:
28+
cdef cparent get_cparent(parent) except? NULL:
3029
if parent is None:
3130
return NULL
3231
cdef ntl_ZZ_pEContext_class pec
3332
try:
3433
pec = parent._modulus
3534
except AttributeError:
3635
return NULL
37-
return & (pec.ptrs)
36+
return &(pec.ptrs)
3837

3938
# first we include the definitions
4039
include "sage/libs/ntl/ntl_ZZ_pEX_linkage.pxi"
4140

4241
# and then the interface
4342
include "polynomial_template.pxi"
4443

44+
from sage.libs.ntl.ntl_ZZ_pE cimport ntl_ZZ_pE
4545

4646
cdef inline ZZ_pE_c_to_list(ZZ_pE_c x):
4747
cdef list L = []
@@ -52,12 +52,12 @@ cdef inline ZZ_pE_c_to_list(ZZ_pE_c x):
5252

5353
c_pX = ZZ_pE_to_ZZ_pX(x)
5454
d = ZZ_pX_deg(c_pX)
55-
if d >= 0:
55+
if d>=0:
5656
for 0 <= j <= d:
5757
c_p = ZZ_pX_coeff(c_pX, j)
5858
c_c = ZZ_p_rep(c_p)
5959
ans = Integer.__new__(Integer)
60-
ZZ_to_mpz(ans.value, & c_c)
60+
ZZ_to_mpz(ans.value, &c_c)
6161
L.append(ans)
6262
return L
6363

@@ -73,7 +73,6 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
7373
sage: (x^3 + a*x^2 + 1) * (x + a)
7474
x^4 + 2*a*x^3 + a^2*x^2 + x + a
7575
"""
76-
7776
def __init__(self, parent, x=None, check=True, is_gen=False, construct=False):
7877
r"""
7978
Create a new univariate polynomials over `\GF{p^n}`.
@@ -125,8 +124,8 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
125124
try:
126125
if (x.parent() is parent.base_ring()) or (x.parent() == parent.base_ring()):
127126
Polynomial.__init__(self, parent, is_gen=is_gen)
128-
( < Polynomial_template > self)._cparent = get_cparent(parent)
129-
celement_construct(&self.x, ( < Polynomial_template > self)._cparent)
127+
(<Polynomial_template>self)._cparent = get_cparent(parent)
128+
celement_construct(&self.x, (<Polynomial_template>self)._cparent)
130129
d = parent._modulus.ZZ_pE(list(x.polynomial()))
131130
ZZ_pEX_SetCoeff(self.x, 0, d.x)
132131
return
@@ -138,10 +137,10 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
138137

139138
if isinstance(x, (list, tuple)):
140139
Polynomial.__init__(self, parent, is_gen=is_gen)
141-
( < Polynomial_template > self)._cparent = get_cparent(parent)
142-
celement_construct(&self.x, ( < Polynomial_template > self)._cparent)
140+
(<Polynomial_template>self)._cparent = get_cparent(parent)
141+
celement_construct(&self.x, (<Polynomial_template>self)._cparent)
143142
K = parent.base_ring()
144-
for i, e in enumerate(x):
143+
for i,e in enumerate(x):
145144
# self(x) is supposed to be a conversion,
146145
# not necessarily a coercion. So, we must
147146
# not do K.coerce(e) but K(e).
@@ -196,7 +195,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
196195

197196
K = self._parent.base_ring()
198197
return [K(ZZ_pE_c_to_list(ZZ_pEX_coeff(self.x, i)))
199-
for i in range(celement_len(&self.x, ( < Polynomial_template > self)._cparent))]
198+
for i in range(celement_len(&self.x, (<Polynomial_template>self)._cparent))]
200199

201200
cpdef _lmul_(self, Element left):
202201
r"""
@@ -212,9 +211,9 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
212211
cdef ntl_ZZ_pE d
213212
cdef Polynomial_ZZ_pEX r
214213
r = Polynomial_ZZ_pEX.__new__(Polynomial_ZZ_pEX)
215-
celement_construct(&r.x, ( < Polynomial_template > self)._cparent)
216-
r._parent = ( < Polynomial_template > self)._parent
217-
r._cparent = ( < Polynomial_template > self)._cparent
214+
celement_construct(&r.x, (<Polynomial_template>self)._cparent)
215+
r._parent = (<Polynomial_template>self)._parent
216+
r._cparent = (<Polynomial_template>self)._cparent
218217
d = self._parent._modulus.ZZ_pE(list(left.polynomial()))
219218
ZZ_pEX_mul_ZZ_pE(r.x, self.x, d.x)
220219
return r
@@ -263,15 +262,15 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
263262

264263
if kwds:
265264
if x:
266-
raise TypeError("%s__call__() takes exactly 1 argument" % type(self))
265+
raise TypeError("%s__call__() takes exactly 1 argument"%type(self))
267266
try:
268267
x = [kwds.pop(self.variable_name())]
269268
except KeyError:
270269
pass
271270
if kwds:
272-
raise TypeError("%s__call__() accepts no named argument except '%s'" % (type(self), self.variable_name()))
273-
if len(x) != 1:
274-
raise TypeError("%s__call__() takes exactly 1 positional argument" % type(self))
271+
raise TypeError("%s__call__() accepts no named argument except '%s'"%(type(self),self.variable_name()))
272+
if len(x)!=1:
273+
raise TypeError("%s__call__() takes exactly 1 positional argument"%type(self))
275274

276275
a = x[0]
277276
try:
@@ -311,7 +310,7 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
311310
if other.parent() is not self._parent:
312311
other = self._parent.coerce(other)
313312

314-
ZZ_pEX_resultant(r, self.x, ( < Polynomial_ZZ_pEX > other).x)
313+
ZZ_pEX_resultant(r, self.x, (<Polynomial_ZZ_pEX>other).x)
315314

316315
K = self._parent.base_ring()
317316
return K(K.polynomial_ring()(ZZ_pE_c_to_list(r)))
@@ -350,15 +349,15 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
350349
False
351350
"""
352351
self._parent._modulus.restore()
353-
if algorithm == "fast_when_false":
352+
if algorithm=="fast_when_false":
354353
sig_on()
355354
res = ZZ_pEX_IterIrredTest(self.x)
356355
sig_off()
357-
elif algorithm == "fast_when_true":
356+
elif algorithm=="fast_when_true":
358357
sig_on()
359358
res = ZZ_pEX_DetIrredTest(self.x)
360359
sig_off()
361-
elif algorithm == "probabilistic":
360+
elif algorithm=="probabilistic":
362361
sig_on()
363362
res = ZZ_pEX_ProbIrredTest(self.x, iter)
364363
sig_off()
@@ -403,11 +402,11 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
403402

404403
cdef Polynomial_ZZ_pEX r
405404
r = Polynomial_ZZ_pEX.__new__(Polynomial_ZZ_pEX)
406-
celement_construct(&r.x, ( < Polynomial_template > self)._cparent)
407-
r._parent = ( < Polynomial_template > self)._parent
408-
r._cparent = ( < Polynomial_template > self)._cparent
405+
celement_construct(&r.x, (<Polynomial_template>self)._cparent)
406+
r._parent = (<Polynomial_template>self)._parent
407+
r._cparent = (<Polynomial_template>self)._cparent
409408

410-
ZZ_pEX_MinPolyMod(r.x, ( < Polynomial_ZZ_pEX > (self % other)).x, ( < Polynomial_ZZ_pEX > other).x)
409+
ZZ_pEX_MinPolyMod(r.x, (<Polynomial_ZZ_pEX>(self % other)).x, (<Polynomial_ZZ_pEX>other).x)
411410
return r
412411

413412
cpdef _richcmp_(self, other, int op):
@@ -453,9 +452,9 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
453452
self._parent._modulus.restore()
454453
cdef Polynomial_ZZ_pEX r
455454
r = Polynomial_ZZ_pEX.__new__(Polynomial_ZZ_pEX)
456-
celement_construct(&r.x, ( < Polynomial_template > self)._cparent)
457-
r._parent = ( < Polynomial_template > self)._parent
458-
r._cparent = ( < Polynomial_template > self)._cparent
455+
celement_construct(&r.x, (<Polynomial_template>self)._cparent)
456+
r._parent = (<Polynomial_template>self)._parent
457+
r._cparent = (<Polynomial_template>self)._cparent
459458
ZZ_pEX_LeftShift(r.x, self.x, n)
460459
return r
461460

@@ -527,9 +526,9 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
527526
# Construct output polynomial
528527
cdef Polynomial_ZZ_pEX r
529528
r = Polynomial_ZZ_pEX.__new__(Polynomial_ZZ_pEX)
530-
celement_construct(&r.x, ( < Polynomial_template > self)._cparent)
531-
r._parent = ( < Polynomial_template > self)._parent
532-
r._cparent = ( < Polynomial_template > self)._cparent
529+
celement_construct(&r.x, (<Polynomial_template>self)._cparent)
530+
r._parent = (<Polynomial_template>self)._parent
531+
r._cparent = (<Polynomial_template>self)._cparent
533532

534533
# When a degree has been supplied, ensure it is a valid input
535534
cdef unsigned long d
@@ -540,9 +539,9 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
540539
d = degree
541540
except ValueError:
542541
raise ValueError("degree argument must be a non-negative integer, got %s" % (degree))
543-
ZZ_pEX_reverse_hi(r.x, ( < Polynomial_ZZ_pEX > self).x, d)
542+
ZZ_pEX_reverse_hi(r.x, (<Polynomial_ZZ_pEX> self).x, d)
544543
else:
545-
ZZ_pEX_reverse(r.x, ( < Polynomial_ZZ_pEX > self).x)
544+
ZZ_pEX_reverse(r.x, (<Polynomial_ZZ_pEX> self).x)
546545
return r
547546

548547
def inverse_series_trunc(self, prec):
@@ -602,9 +601,9 @@ cdef class Polynomial_ZZ_pEX(Polynomial_template):
602601
# Construct output polynomial
603602
cdef Polynomial_ZZ_pEX r
604603
r = Polynomial_ZZ_pEX.__new__(Polynomial_ZZ_pEX)
605-
celement_construct(&r.x, (< Polynomial_template > self)._cparent)
606-
r._parent = (< Polynomial_template > self)._parent
607-
r._cparent = (< Polynomial_template > self)._cparent
604+
celement_construct(&r.x, (<Polynomial_template>self)._cparent)
605+
r._parent = (<Polynomial_template>self)._parent
606+
r._cparent = (<Polynomial_template>self)._cparent
608607

609608
# Call to NTL for the inverse truncation
610609
if prec > 0:

0 commit comments

Comments
 (0)