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

Commit 5897dfc

Browse files
committed
address Travis' comments
1 parent e8e9139 commit 5897dfc

4 files changed

+158
-139
lines changed

src/sage/rings/polynomial/skew_polynomial_element.pxd

+8-4
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@ cdef class SkewPolynomial(AlgebraElement):
88
cdef _is_gen
99

1010
cdef long _hash_c(self)
11-
cdef SkewPolynomial _new_c(self,list coeffs,Parent P,char check=*)
12-
cpdef SkewPolynomial _new_constant_poly(self,RingElement a,Parent P,char check=*)
11+
cdef SkewPolynomial _new_c(self, list coeffs, Parent P, char check=*)
12+
cpdef SkewPolynomial _new_constant_poly(self, RingElement a, Parent P, char check=*)
1313
cpdef _neg_(self)
1414
cpdef _floordiv_(self, right)
1515
cpdef _mod_(self, right)
1616

1717
cpdef bint is_zero(self)
1818
cpdef bint is_one(self)
19-
19+
2020
cpdef operator_eval(self, eval_pt)
2121

22+
cdef SkewPolynomial _left_lcm_cofactor(self, SkewPolynomial other)
23+
cdef SkewPolynomial _right_lcm_cofactor(self, SkewPolynomial other)
24+
2225
# Abstract methods
2326
cdef void _inplace_rmul(self, SkewPolynomial_generic_dense right)
2427
cdef void _inplace_pow(self, Py_ssize_t n)
2528
cpdef int degree(self)
2629
cpdef list coefficients(self, sparse=*)
2730

31+
2832
cdef class SkewPolynomial_generic_dense(SkewPolynomial):
2933
cdef list _coeffs
3034

@@ -38,7 +42,7 @@ cdef class SkewPolynomial_generic_dense(SkewPolynomial):
3842
cpdef right_power_mod(self, exp, modulus)
3943
cpdef left_power_mod(self, exp, modulus)
4044

45+
4146
cdef class SkewPolynomialBaseringInjection(Morphism):
4247
cdef RingElement _an_element
4348
cdef object _new_constant_poly_
44-

src/sage/rings/polynomial/skew_polynomial_element.pyx

+39-31
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ cdef class SkewPolynomial(AlgebraElement):
13811381
A = A.left_monic()
13821382
return A
13831383

1384-
def _left_lcm_cofactor(self, other):
1384+
cdef SkewPolynomial _left_lcm_cofactor(self, SkewPolynomial other):
13851385
r"""
13861386
Return a skew polynomial `U` such that `U P = c L`
13871387
where `P` is this skew polynomial (``self``), `L`
@@ -1390,6 +1390,12 @@ cdef class SkewPolynomial(AlgebraElement):
13901390
13911391
TESTS::
13921392
1393+
sage: cython('''
1394+
....: from sage.rings.polynomial.skew_polynomial_element cimport SkewPolynomial
1395+
....: def left_lcm_cofactor(SkewPolynomial P, SkewPolynomial Q):
1396+
....: return P._left_lcm_cofactor(Q)
1397+
....: ''')
1398+
13931399
sage: k.<a> = GF(7^5)
13941400
sage: Frob = k.frobenius_endomorphism(3)
13951401
sage: S.<x> = k['x', Frob]
@@ -1398,23 +1404,21 @@ cdef class SkewPolynomial(AlgebraElement):
13981404
sage: P = S.random_element() * D
13991405
sage: Q = S.random_element() * D
14001406
sage: L = P.left_lcm(Q)
1401-
sage: U = P._left_lcm_cofactor(Q)
1407+
sage: U = left_lcm_cofactor(P, Q)
14021408
sage: (U*P).right_monic() == L
14031409
True
14041410
"""
1405-
R = self._parent
1406-
U = R.one()
1407-
G = self
1408-
V1 = R.zero()
1409-
V3 = other
1410-
while not V3.is_zero():
1411-
Q, R = G.right_quo_rem(V3)
1412-
T = U - Q*V1
1413-
U = V1
1414-
G = V3
1415-
V1 = T
1416-
V3 = R
1417-
return V1
1411+
cdef SkewPolynomial Q, R, T
1412+
cdef SkewPolynomial U = <SkewPolynomial>self._parent.one()
1413+
cdef SkewPolynomial V = <SkewPolynomial>self._parent.zero()
1414+
while other:
1415+
Q, R = self.right_quo_rem(other)
1416+
T = U - Q*V
1417+
U = V
1418+
V = T
1419+
self = other
1420+
other = R
1421+
return V
14181422

14191423
@coerce_binop
14201424
def left_xlcm(self, other, monic=True):
@@ -1454,14 +1458,20 @@ cdef class SkewPolynomial(AlgebraElement):
14541458
V1 = s * V1
14551459
return L, V1, L // other
14561460

1457-
def _right_lcm_cofactor(self, other):
1461+
cdef SkewPolynomial _right_lcm_cofactor(self, SkewPolynomial other):
14581462
r"""
14591463
Return a skew polynomial `U` such that `P U = L c`
14601464
where `P` is this skew polynomial (``self``), `L`
14611465
is the right lcm of `P` and ``other`` and `c` is a
14621466
constant
14631467
1464-
EXAMPLES::
1468+
TESTS::
1469+
1470+
sage: cython('''
1471+
....: from sage.rings.polynomial.skew_polynomial_element cimport SkewPolynomial
1472+
....: def right_lcm_cofactor(SkewPolynomial P, SkewPolynomial Q):
1473+
....: return P._right_lcm_cofactor(Q)
1474+
....: ''')
14651475
14661476
sage: k.<a> = GF(7^5)
14671477
sage: Frob = k.frobenius_endomorphism(3)
@@ -1471,23 +1481,21 @@ cdef class SkewPolynomial(AlgebraElement):
14711481
sage: P = D * S.random_element()
14721482
sage: Q = D * S.random_element()
14731483
sage: L = P.right_lcm(Q)
1474-
sage: U = P._right_lcm_cofactor(Q)
1484+
sage: U = right_lcm_cofactor(P, Q)
14751485
sage: (P*U).left_monic() == L
14761486
True
14771487
"""
1478-
R = self._parent
1479-
U = R.one()
1480-
G = self
1481-
V1 = R.zero()
1482-
V3 = other
1483-
while not V3.is_zero():
1484-
Q, R = G.left_quo_rem(V3)
1485-
T = U - V1*Q
1486-
U = V1
1487-
G = V3
1488-
V1 = T
1489-
V3 = R
1490-
return V1
1488+
cdef SkewPolynomial Q, R, T
1489+
cdef SkewPolynomial U = <SkewPolynomial>self._parent.one()
1490+
cdef SkewPolynomial V = <SkewPolynomial>self._parent.zero()
1491+
while other:
1492+
Q, R = self.left_quo_rem(other)
1493+
T = U - V*Q
1494+
U = V
1495+
V = T
1496+
self = other
1497+
other = R
1498+
return V
14911499

14921500
@coerce_binop
14931501
def right_xlcm(self, other, monic=True):

src/sage/rings/polynomial/skew_polynomial_finite_field.pxd

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from sage.rings.polynomial.skew_polynomial_finite_order cimport SkewPolynomial_finite_order_dense
2-
from sage.matrix.matrix_dense cimport Matrix_dense
32

43
cdef class SkewPolynomial_finite_field_dense (SkewPolynomial_finite_order_dense):
54
cdef _norm_factor
6-
cdef dict _rdivisors
75
cdef dict _types
86
cdef _factorization
97

8+
cdef inline _reduced_norm_factored(self)
9+
1010
# Finding divisors
1111
cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, N)
1212

0 commit comments

Comments
 (0)