@@ -387,7 +387,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
387
387
# Note that we are guaranteed that right is in the base ring, so this could be fast.
388
388
if not left:
389
389
return self ._parent.zero()
390
- return self .parent() (left) * self
390
+ return self ._parent (left) * self
391
391
392
392
cpdef _rmul_(self , Element right):
393
393
"""
@@ -407,7 +407,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
407
407
# Note that we are guaranteed that right is in the base ring, so this could be fast.
408
408
if not right:
409
409
return self ._parent.zero()
410
- return self * self .parent() (right)
410
+ return self * self ._parent (right)
411
411
412
412
def subs (self , *x , **kwds ):
413
413
r """
@@ -433,7 +433,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
433
433
TypeError: keys do not match self's parent
434
434
"""
435
435
if len (x) == 1 and isinstance (x[0 ], dict ):
436
- g = self .parent() .gen()
436
+ g = self ._parent .gen()
437
437
if g in x[0 ]:
438
438
return self (x[0 ][g])
439
439
elif len (x[0 ]) > 0 :
@@ -1279,7 +1279,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
1279
1279
sage: f.variables()
1280
1280
(w,)
1281
1281
"""
1282
- d = dict ([(repr (g), R.var(g)) for g in self .parent() .gens()])
1282
+ d = dict ([(repr (g), R.var(g)) for g in self ._parent .gens()])
1283
1283
return self .subs(** d)
1284
1284
1285
1285
def __invert__ (self ):
@@ -1293,7 +1293,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
1293
1293
sage: ~f
1294
1294
1/(x - 90283)
1295
1295
"""
1296
- return self .parent().one()/ self
1296
+ return self .parent().one() / self
1297
1297
1298
1298
def inverse_of_unit (self ):
1299
1299
"""
@@ -1304,18 +1304,18 @@ cdef class Polynomial(CommutativeAlgebraElement):
1304
1304
sage: f.inverse_of_unit()
1305
1305
Traceback (most recent call last):
1306
1306
...
1307
- ValueError: self is not a unit.
1307
+ ValueError: self is not a unit
1308
1308
sage: f = R(-90283); g = f.inverse_of_unit(); g
1309
1309
-1/90283
1310
1310
sage: parent(g)
1311
1311
Univariate Polynomial Ring in x over Rational Field
1312
1312
"""
1313
1313
if self .degree() > 0 :
1314
1314
if not self .is_unit():
1315
- raise ValueError (" self is not a unit. " )
1315
+ raise ValueError (" self is not a unit" )
1316
1316
else :
1317
1317
raise NotImplementedError (" polynomial inversion over non-integral domains not implemented" )
1318
- return self .parent() (~ (self [0 ]))
1318
+ return self ._parent (~ (self [0 ]))
1319
1319
1320
1320
def inverse_mod (a , m ):
1321
1321
"""
@@ -1767,7 +1767,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
1767
1767
except NotImplementedError :
1768
1768
f = self .factor()
1769
1769
1770
- u = self .parent() .base_ring()(f.unit())
1770
+ u = self ._parent .base_ring()(f.unit())
1771
1771
1772
1772
if all (a[1 ] % 2 == 0 for a in f) and u.is_square():
1773
1773
g = u.sqrt()
@@ -1899,7 +1899,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
1899
1899
raise NotImplementedError
1900
1900
allowed_deg_mult = Integer(ring.factored_order()[0 ][1 ]) # generally it will be the quotient of this by the degree of the base ring.
1901
1901
if degree is None :
1902
- x = self .parent() .gen()
1902
+ x = self ._parent .gen()
1903
1903
if allowed_deg_mult == 1 :
1904
1904
xq = pow (x,q,self )
1905
1905
self = self .gcd(xq- x)
@@ -1954,7 +1954,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
1954
1954
break
1955
1955
if degree == 0 :
1956
1956
raise ValueError (" degree should be nonzero" )
1957
- R = self .parent()
1957
+ R = self ._parent
1958
1958
x = R.gen()
1959
1959
if degree > 0 :
1960
1960
xq = x
@@ -2326,12 +2326,12 @@ cdef class Polynomial(CommutativeAlgebraElement):
2326
2326
def _pow (self , right ):
2327
2327
# TODO: fit __pow__ into the arithmetic structure
2328
2328
if self .degree() <= 0 :
2329
- return self .parent() (self [0 ]** right)
2329
+ return self ._parent (self [0 ]** right)
2330
2330
if right < 0 :
2331
2331
return (~ self )** (- right)
2332
- if (< Polynomial> self ) == self .parent() .gen(): # special case x**n should be faster!
2332
+ if (< Polynomial> self ) == self ._parent .gen(): # special case x**n should be faster!
2333
2333
v = [0 ]* right + [1 ]
2334
- return self .parent() (v, check = True )
2334
+ return self ._parent (v, check = True )
2335
2335
return generic_power(self , right)
2336
2336
2337
2337
def _repr (self , name = None ):
@@ -2371,8 +2371,8 @@ cdef class Polynomial(CommutativeAlgebraElement):
2371
2371
s = " "
2372
2372
m = self .degree() + 1
2373
2373
if name is None :
2374
- name = self .parent() .variable_name()
2375
- atomic_repr = self .parent() .base_ring()._repr_option(' element_is_atomic' )
2374
+ name = self ._parent .variable_name()
2375
+ atomic_repr = self ._parent .base_ring()._repr_option(' element_is_atomic' )
2376
2376
coeffs = self .list(copy = False )
2377
2377
for n in reversed (xrange (m)):
2378
2378
x = coeffs[n]
@@ -2458,8 +2458,8 @@ cdef class Polynomial(CommutativeAlgebraElement):
2458
2458
coeffs = self .list(copy = False )
2459
2459
m = len (coeffs)
2460
2460
if name is None :
2461
- name = self .parent() .latex_variable_names()[0 ]
2462
- atomic_repr = self .parent() .base_ring()._repr_option(' element_is_atomic' )
2461
+ name = self ._parent .latex_variable_names()[0 ]
2462
+ atomic_repr = self ._parent .base_ring()._repr_option(' element_is_atomic' )
2463
2463
for n in reversed (xrange (m)):
2464
2464
x = coeffs[n]
2465
2465
x = y = latex(x)
@@ -2535,7 +2535,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
2535
2535
{binop:- {binop:** {gen:x {constr_parent: {subscr: {atomic:ZZ}[{atomic:'x'} ]} with gens: ( 'x',) }} {atomic:2}} {atomic:1}}
2536
2536
"""
2537
2537
if self .degree() > 0 :
2538
- gen = sib.gen(self .parent() )
2538
+ gen = sib.gen(self ._parent )
2539
2539
coeffs = self .list(copy = False )
2540
2540
terms = []
2541
2541
for i in range (len (coeffs)- 1 , - 1 , - 1 ):
@@ -2551,7 +2551,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
2551
2551
elif coerced:
2552
2552
return sib(self .constant_coefficient(), True )
2553
2553
else :
2554
- return sib(self .parent() )(sib(self .constant_coefficient(), True ))
2554
+ return sib(self ._parent )(sib(self .constant_coefficient(), True ))
2555
2555
2556
2556
def __setitem__ (self , n , value ):
2557
2557
"""
@@ -2791,7 +2791,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
2791
2791
2792
2792
- Didier Deshommes ( 2006-05-25)
2793
2793
"""
2794
- return self .parent() (polynomial_fateman._mul_fateman_mul(self ,right))
2794
+ return self ._parent (polynomial_fateman._mul_fateman_mul(self ,right))
2795
2795
2796
2796
@ cython.boundscheck (False )
2797
2797
@ cython.wraparound (False )
@@ -2976,7 +2976,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
2976
2976
sage: (2*x+3).base_ring()
2977
2977
Integer Ring
2978
2978
"""
2979
- return self .parent() .base_ring()
2979
+ return self ._parent .base_ring()
2980
2980
2981
2981
cpdef base_extend(self , R):
2982
2982
"""
@@ -2994,7 +2994,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
2994
2994
sage: f.change_ring(GF(7))
2995
2995
x^3 + 4*x + 3
2996
2996
"""
2997
- S = self .parent() .base_extend(R)
2997
+ S = self ._parent .base_extend(R)
2998
2998
return S(self )
2999
2999
3000
3000
def change_variable_name (self , var ):
@@ -3010,7 +3010,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
3010
3010
sage: f.change_variable_name('theta')
3011
3011
-2/7*theta^3 + 2/3*theta - 19/993
3012
3012
"""
3013
- R = self .parent() .base_ring()[var]
3013
+ R = self ._parent .base_ring()[var]
3014
3014
return R(self .list())
3015
3015
3016
3016
def change_ring (self , R ):
@@ -3040,10 +3040,10 @@ cdef class Polynomial(CommutativeAlgebraElement):
3040
3040
if isinstance (R, Morphism):
3041
3041
# we're given a hom of the base ring extend to a poly hom
3042
3042
if R.domain() == self .base_ring():
3043
- R = self .parent() .hom(R, self .parent() .change_ring(R.codomain()))
3043
+ R = self ._parent .hom(R, self ._parent .change_ring(R.codomain()))
3044
3044
return R(self )
3045
3045
else :
3046
- return self .parent() .change_ring(R)(self )
3046
+ return self ._parent .change_ring(R)(self )
3047
3047
3048
3048
def _mpoly_dict_recursive (self , variables = None , base_ring = None ):
3049
3049
"""
@@ -3062,9 +3062,9 @@ cdef class Polynomial(CommutativeAlgebraElement):
3062
3062
if not self :
3063
3063
return {}
3064
3064
3065
- var = self .parent() .variable_name()
3065
+ var = self ._parent .variable_name()
3066
3066
if variables is None :
3067
- variables = self .parent() .variable_names_recursive()
3067
+ variables = self ._parent .variable_names_recursive()
3068
3068
if not var in variables:
3069
3069
x = base_ring(self ) if base_ring else self
3070
3070
const_ix = ETuple((0 ,)* len (variables))
@@ -4039,7 +4039,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4039
4039
except NotImplementedError :
4040
4040
pass
4041
4041
4042
- R = self .parent() .base_ring()
4042
+ R = self ._parent .base_ring()
4043
4043
if hasattr (R, ' _factor_univariate_polynomial' ):
4044
4044
return R._factor_univariate_polynomial(self , ** kwargs)
4045
4045
@@ -4069,7 +4069,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4069
4069
from_M, to_M = M.structure()
4070
4070
g = M[' x' ]([to_M(x) for x in self .list()])
4071
4071
F = g.factor()
4072
- S = self .parent()
4072
+ S = self ._parent
4073
4073
v = [(S([from_M(x) for x in f.list()]), e) for f, e in F]
4074
4074
return Factorization(v, from_M(F.unit()))
4075
4075
@@ -4107,7 +4107,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4107
4107
if R.characteristic() > 1 << 29 :
4108
4108
raise NotImplementedError (" Factorization of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented." )
4109
4109
4110
- P = self .parent()
4110
+ P = self ._parent
4111
4111
P._singular_().set_ring()
4112
4112
S = self ._singular_().factorize()
4113
4113
factors = S[1 ]
@@ -4166,7 +4166,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4166
4166
"""
4167
4167
pols = G[0 ]
4168
4168
exps = G[1 ]
4169
- R = self .parent()
4169
+ R = self ._parent
4170
4170
F = [(R(f), int (e)) for f, e in zip (pols, exps)]
4171
4171
4172
4172
if unit is None :
@@ -4401,7 +4401,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4401
4401
raise ZeroDivisionError (" Pseudo-division by zero is not possible" )
4402
4402
4403
4403
# if other is a constant, then R = 0 and Q = self * other^(deg(self))
4404
- if other in self .parent() .base_ring():
4404
+ if other in self ._parent .base_ring():
4405
4405
return (self * other** (self .degree()), self ._parent.zero())
4406
4406
4407
4407
R = self
@@ -4413,7 +4413,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4413
4413
while not R.degree() < B.degree():
4414
4414
c = R.leading_coefficient()
4415
4415
diffdeg = R.degree() - B.degree()
4416
- Q = d* Q + self .parent() (c).shift(diffdeg)
4416
+ Q = d* Q + self ._parent (c).shift(diffdeg)
4417
4417
R = d* R - c* B.shift(diffdeg)
4418
4418
e -= 1
4419
4419
@@ -4669,7 +4669,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4669
4669
if n is None :
4670
4670
q = self .base_ring().order()
4671
4671
n = q ** self .degree() - 1
4672
- y = self .parent() .quo(self ).gen()
4672
+ y = self ._parent .quo(self ).gen()
4673
4673
from sage.groups.generic import order_from_multiple
4674
4674
return n == order_from_multiple(y, n, n_prime_divs, operation = " *" )
4675
4675
else :
@@ -4836,7 +4836,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
4836
4836
if sage.rings.rational_field.is_RationalField(R) or is_NumberField(R):
4837
4837
return NumberField(self , names)
4838
4838
4839
- return R.fraction_field()[self .parent() .variable_name()].quotient(self , names)
4839
+ return R.fraction_field()[self ._parent .variable_name()].quotient(self , names)
4840
4840
4841
4841
def sylvester_matrix (self , right , variable = None ):
4842
4842
"""
@@ -4959,16 +4959,16 @@ cdef class Polynomial(CommutativeAlgebraElement):
4959
4959
# This code is almost exactly the same as that of
4960
4960
# sylvester_matrix() in multi_polynomial.pyx.
4961
4961
4962
- if self .parent() != right.parent():
4962
+ if self ._parent != right.parent():
4963
4963
a, b = coercion_model.canonical_coercion(self ,right)
4964
4964
variable = a.parent()(self .variables()[0 ])
4965
4965
# We add the variable to cover the case that right is a multivariate
4966
4966
# polynomial
4967
4967
return a.sylvester_matrix(b, variable)
4968
4968
4969
4969
if variable:
4970
- if variable.parent() != self .parent() :
4971
- variable = self .parent() (variable)
4970
+ if variable.parent() != self ._parent :
4971
+ variable = self ._parent (variable)
4972
4972
4973
4973
from sage.matrix.constructor import matrix
4974
4974
@@ -5283,7 +5283,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5283
5283
if self .is_monic():
5284
5284
return self
5285
5285
a = ~ self .leading_coefficient()
5286
- R = self .parent()
5286
+ R = self ._parent
5287
5287
if a.parent() != R.base_ring():
5288
5288
S = R.base_extend(a.parent())
5289
5289
return a* S(self )
@@ -5306,7 +5306,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5306
5306
sage: f.coefficients(sparse=False)
5307
5307
[1, 0, 2, 0, 1]
5308
5308
"""
5309
- zero = self .parent() .base_ring().zero()
5309
+ zero = self ._parent .base_ring().zero()
5310
5310
if (sparse):
5311
5311
return [c for c in self .list() if c != zero]
5312
5312
else :
@@ -5323,7 +5323,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5323
5323
sage: f.exponents()
5324
5324
[0, 2, 4]
5325
5325
"""
5326
- zero = self .parent() .base_ring().zero()
5326
+ zero = self ._parent .base_ring().zero()
5327
5327
l = self .list()
5328
5328
return [i for i in range (len (l)) if l[i] != zero]
5329
5329
@@ -5488,15 +5488,15 @@ cdef class Polynomial(CommutativeAlgebraElement):
5488
5488
sage: f.monomial_coefficient(x^3)
5489
5489
0
5490
5490
"""
5491
- if not m.parent() is self .parent() :
5491
+ if not m.parent() is self ._parent :
5492
5492
raise TypeError (" monomial must have same parent as self." )
5493
5493
5494
5494
d = m.degree()
5495
5495
coeffs = self .list()
5496
5496
if 0 <= d < len (coeffs):
5497
5497
return coeffs[d]
5498
5498
else :
5499
- return self .parent() .base_ring().zero()
5499
+ return self ._parent .base_ring().zero()
5500
5500
5501
5501
def monomials (self ):
5502
5502
"""
@@ -5529,8 +5529,8 @@ cdef class Polynomial(CommutativeAlgebraElement):
5529
5529
"""
5530
5530
if self .is_zero():
5531
5531
return []
5532
- v = self .parent() .gen()
5533
- zero = self .parent() .base_ring().zero()
5532
+ v = self ._parent .gen()
5533
+ zero = self ._parent .base_ring().zero()
5534
5534
coeffs = self .list()
5535
5535
return [v** i for i in range (self .degree(), - 1 , - 1 ) if coeffs[i] != zero]
5536
5536
@@ -5570,7 +5570,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5570
5570
"""
5571
5571
n = sage.rings.integer.Integer(n)
5572
5572
df = self .derivative()
5573
- K = self .parent() .base_ring()
5573
+ K = self ._parent .base_ring()
5574
5574
a = K(x0)
5575
5575
L = []
5576
5576
for i in range (n):
@@ -5835,7 +5835,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5835
5835
sage: pari( a* x + 10* x^ 3)
5836
5836
Mod( 2, 8) * x^ 3 + Mod( 1, 8) * a* x
5837
5837
"""
5838
- return self ._pari_with_name(self .parent() .variable_name())
5838
+ return self ._pari_with_name(self ._parent .variable_name())
5839
5839
5840
5840
def _pari_or_constant (self , name = None ):
5841
5841
r """
@@ -5870,7 +5870,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5870
5870
if self .is_constant():
5871
5871
return self [0 ].__pari__()
5872
5872
if name is None :
5873
- name = self .parent() .variable_name()
5873
+ name = self ._parent .variable_name()
5874
5874
return self ._pari_with_name(name)
5875
5875
5876
5876
def _pari_with_name (self , name = ' x' ):
@@ -5931,7 +5931,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5931
5931
a*W^20 + a^7*s*t
5932
5932
"""
5933
5933
# Get a reference to Magma version of parent.
5934
- R = magma(self .parent() )
5934
+ R = magma(self ._parent )
5935
5935
# Get list of coefficients.
5936
5936
v = ' ,' .join([a._magma_init_(magma) for a in self .list()])
5937
5937
return ' %s ![%s ]' % (R.name(), v)
@@ -5977,7 +5977,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
5977
5977
sage: f.factor()
5978
5978
(y + 5) * (y + 1)^2
5979
5979
"""
5980
- R = gap(self .parent() )
5980
+ R = gap(self ._parent )
5981
5981
var = list (R.IndeterminatesOfPolynomialRing())[0 ]
5982
5982
return self (var)
5983
5983
@@ -6102,7 +6102,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
6102
6102
variable = self .variable_name()
6103
6103
try :
6104
6104
res = self .__pari__().polresultant(other, variable)
6105
- return self .parent() .base_ring()(res)
6105
+ return self ._parent .base_ring()(res)
6106
6106
except (TypeError , ValueError , PariError, NotImplementedError ):
6107
6107
return self .sylvester_matrix(other).det()
6108
6108
@@ -6450,7 +6450,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
6450
6450
( x - c^ 3) * ( x - b^ 3) * ( x - a^ 3)
6451
6451
6452
6452
"""
6453
- u, v = PolynomialRing(self .parent() .base_ring(), [' u' , ' v' ]).gens()
6453
+ u, v = PolynomialRing(self ._parent .base_ring(), [' u' , ' v' ]).gens()
6454
6454
R = (u - v** n).resultant(self (v), v)
6455
6455
R = R([self .variables()[0 ], 0 ])
6456
6456
if monic:
@@ -6531,7 +6531,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
6531
6531
g = g.monic()
6532
6532
return g
6533
6533
6534
- fkn = fkd = self .parent() .one()
6534
+ fkn = fkd = self ._parent .one()
6535
6535
for j in range (1 , k + 1 ):
6536
6536
g = star(rpow(self , j), self .symmetric_power(k - j))
6537
6537
if j % 2 :
@@ -6665,7 +6665,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
6665
6665
if self .is_zero():
6666
6666
return self ._parent.zero()
6667
6667
n = self .degree()
6668
- base_ring = self .parent() .base_ring()
6668
+ base_ring = self ._parent .base_ring()
6669
6669
if (is_MPolynomialRing(base_ring) or
6670
6670
is_PowerSeriesRing(base_ring)):
6671
6671
# It is often cheaper to compute discriminant of simple
@@ -7325,9 +7325,16 @@ cdef class Polynomial(CommutativeAlgebraElement):
7325
7325
(0.500000000000000 - 0.866025403784439*I, 5),
7326
7326
(0.500000000000000 + 0.866025403784439*I, 5)]
7327
7327
"""
7328
- K = self .parent().base_ring()
7328
+ K = self ._parent.base_ring()
7329
+ # If the base ring has a method _roots_univariate_polynomial,
7330
+ # try to use it. An exception is raised if the method does not
7331
+ # handle the current parameters
7329
7332
if hasattr (K, ' _roots_univariate_polynomial' ):
7330
- return K._roots_univariate_polynomial(self , ring = ring, multiplicities = multiplicities, algorithm = algorithm, ** kwds)
7333
+ try :
7334
+ return K._roots_univariate_polynomial(self , ring = ring, multiplicities = multiplicities, algorithm = algorithm, ** kwds)
7335
+ except NotImplementedError :
7336
+ # This does not handle something, so keep calm and continue on
7337
+ pass
7331
7338
7332
7339
if kwds:
7333
7340
raise TypeError (" roots() got unexpected keyword argument(s): {}" .format(kwds.keys()))
@@ -7545,11 +7552,11 @@ cdef class Polynomial(CommutativeAlgebraElement):
7545
7552
[2, 0, 1/2]
7546
7553
"""
7547
7554
seq = []
7548
- K = self .parent() .base_ring()
7555
+ K = self ._parent .base_ring()
7549
7556
for fac in F:
7550
7557
g = fac[0 ]
7551
7558
if g.degree() == 1 :
7552
- rt = - g[0 ]/ g[1 ]
7559
+ rt = - g[0 ] / g[1 ]
7553
7560
# We need to check that this root is actually in K;
7554
7561
# otherwise we'd return roots in the fraction field of K.
7555
7562
if rt in K:
@@ -7780,7 +7787,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
7780
7787
sage: f.variable_name()
7781
7788
't'
7782
7789
"""
7783
- return self .parent() .variable_name()
7790
+ return self ._parent .variable_name()
7784
7791
7785
7792
@coerce_binop
7786
7793
def xgcd (self , other ):
@@ -7924,16 +7931,16 @@ cdef class Polynomial(CommutativeAlgebraElement):
7924
7931
if self [k]:
7925
7932
return ZZ(k)
7926
7933
if isinstance (p, Polynomial):
7927
- p = self .parent() .coerce(p)
7928
- elif is_Ideal(p) and p.ring() is self .parent() : # eventually need to handle fractional ideals in the fraction field
7929
- if self .parent() .base_ring().is_field(): # common case
7934
+ p = self ._parent .coerce(p)
7935
+ elif is_Ideal(p) and p.ring() is self ._parent : # eventually need to handle fractional ideals in the fraction field
7936
+ if self ._parent .base_ring().is_field(): # common case
7930
7937
p = p.gen()
7931
7938
else :
7932
7939
raise NotImplementedError
7933
7940
else :
7934
7941
from sage.rings.fraction_field import is_FractionField
7935
- if is_FractionField(p.parent()) and self .parent() .has_coerce_map_from(p.parent().ring()):
7936
- p = self .parent() .coerce(p.parent().ring()(p)) # here we require that p be integral.
7942
+ if is_FractionField(p.parent()) and self ._parent .has_coerce_map_from(p.parent().ring()):
7943
+ p = self ._parent .coerce(p.parent().ring()(p)) # here we require that p be integral.
7937
7944
else :
7938
7945
raise TypeError (" The polynomial, p, must have the same parent as self." )
7939
7946
@@ -7974,7 +7981,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
7974
7981
sage: f. add_bigoh( 2) . parent( )
7975
7982
Power Series Ring in x over Integer Ring
7976
7983
"""
7977
- return self .parent() .completion(self .parent() .gen())(self ).add_bigoh(prec)
7984
+ return self ._parent .completion(self ._parent .gen())(self ).add_bigoh(prec)
7978
7985
7979
7986
@cached_method
7980
7987
def is_irreducible (self ):
@@ -8275,7 +8282,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
8275
8282
sage: del(QQbar._is_squarefree_univariate_polynomial)
8276
8283
8277
8284
"""
8278
- B = self .parent() .base_ring()
8285
+ B = self ._parent .base_ring()
8279
8286
if B not in sage.categories.integral_domains.IntegralDomains():
8280
8287
raise TypeError (" is_squarefree() is not defined for polynomials over {}" .format(B))
8281
8288
@@ -8304,7 +8311,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
8304
8311
# a square-free polynomial has a square-free content
8305
8312
if not B.is_field():
8306
8313
content = self .content()
8307
- if content not in self .parent() .base_ring():
8314
+ if content not in self ._parent .base_ring():
8308
8315
content = content.gen()
8309
8316
if not content.is_squarefree():
8310
8317
return False
@@ -8350,7 +8357,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
8350
8357
sage: (x^3 + x^2).radical()
8351
8358
x^2 + x
8352
8359
"""
8353
- P = self .parent()
8360
+ P = self ._parent
8354
8361
R = P.base_ring()
8355
8362
p = R.characteristic()
8356
8363
if p == 0 or p > self .degree():
@@ -8542,7 +8549,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
8542
8549
sage: g.parent()
8543
8550
Univariate Polynomial Ring in x over Finite Field of size 2 (using NTL)
8544
8551
"""
8545
- R = self .parent()
8552
+ R = self ._parent
8546
8553
if new_base_ring is not None :
8547
8554
R = R.change_ring(new_base_ring)
8548
8555
elif isinstance (f, Map):
@@ -8690,7 +8697,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
8690
8697
if not self .is_monic():
8691
8698
return False
8692
8699
8693
- P = self .parent()
8700
+ P = self ._parent
8694
8701
gen = P.gen()
8695
8702
8696
8703
if self == gen - 1 : # the first cyc. pol. is treated apart
@@ -8815,7 +8822,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
8815
8822
raise NotImplementedError (" not implemented in non-zero characteristic" )
8816
8823
if not S.is_exact():
8817
8824
raise NotImplementedError (" not implemented for inexact base rings" )
8818
- R = self .parent()
8825
+ R = self ._parent
8819
8826
x = R.gen()
8820
8827
# Extract Phi_n when n is odd.
8821
8828
t1 = self
@@ -9098,7 +9105,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
9098
9105
i = self .valuation()
9099
9106
if i% m:
9100
9107
raise ValueError (" not a %s power" % m.ordinal_str())
9101
- S = self .parent()
9108
+ S = self ._parent
9102
9109
return S.gen()** (i// m) * (self >> i).nth_root(m)
9103
9110
else :
9104
9111
c = R.characteristic()
@@ -9112,7 +9119,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
9112
9119
if i% cc:
9113
9120
raise ValueError (" not a %s power" % m.ordinal_str())
9114
9121
ans[i// cc] = self [i].nth_root(cc)
9115
- p = self .parent() (ans)
9122
+ p = self ._parent (ans)
9116
9123
m = m // cc
9117
9124
if m.is_one():
9118
9125
return p
@@ -9174,7 +9181,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
9174
9181
raise ValueError (" either the dictionary or the specialization must be provided" )
9175
9182
else :
9176
9183
from sage.rings.polynomial.flatten import SpecializationMorphism
9177
- phi = SpecializationMorphism(self .parent() ,D)
9184
+ phi = SpecializationMorphism(self ._parent ,D)
9178
9185
return phi(self )
9179
9186
9180
9187
def _log_series (self , long n ):
@@ -10052,13 +10059,13 @@ cdef class Polynomial_generic_dense(Polynomial):
10052
10059
if self .is_zero():
10053
10060
return self , self
10054
10061
10055
- R = self .parent() .base_ring()
10062
+ R = self ._parent .base_ring()
10056
10063
x = (< Polynomial_generic_dense> self ).__coeffs[:] # make a copy
10057
10064
y = (< Polynomial_generic_dense> other).__coeffs
10058
10065
m = len (x) # deg(self)=m-1
10059
10066
n = len (y) # deg(other)=n-1
10060
10067
if m < n:
10061
- return self .parent() .zero(), self
10068
+ return self ._parent .zero(), self
10062
10069
10063
10070
quo = list ()
10064
10071
for k from m- n >= k >= 0 :
0 commit comments