@@ -1381,7 +1381,7 @@ cdef class SkewPolynomial(AlgebraElement):
1381
1381
A = A.left_monic()
1382
1382
return A
1383
1383
1384
- def _left_lcm_cofactor (self , other ):
1384
+ cdef SkewPolynomial _left_lcm_cofactor(self , SkewPolynomial other):
1385
1385
r """
1386
1386
Return a skew polynomial `U` such that `U P = c L`
1387
1387
where `P` is this skew polynomial ( ``self``) , `L`
@@ -1390,6 +1390,12 @@ cdef class SkewPolynomial(AlgebraElement):
1390
1390
1391
1391
TESTS::
1392
1392
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
+
1393
1399
sage: k. <a> = GF( 7^ 5)
1394
1400
sage: Frob = k. frobenius_endomorphism( 3)
1395
1401
sage: S. <x> = k['x', Frob ]
@@ -1398,23 +1404,21 @@ cdef class SkewPolynomial(AlgebraElement):
1398
1404
sage: P = S. random_element( ) * D
1399
1405
sage: Q = S. random_element( ) * D
1400
1406
sage: L = P. left_lcm( Q)
1401
- sage: U = P . _left_lcm_cofactor ( Q)
1407
+ sage: U = left_lcm_cofactor ( P, Q)
1402
1408
sage: ( U* P) . right_monic( ) == L
1403
1409
True
1404
1410
"""
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
1418
1422
1419
1423
@coerce_binop
1420
1424
def left_xlcm (self , other , monic = True ):
@@ -1454,14 +1458,20 @@ cdef class SkewPolynomial(AlgebraElement):
1454
1458
V1 = s * V1
1455
1459
return L, V1, L // other
1456
1460
1457
- def _right_lcm_cofactor (self , other ):
1461
+ cdef SkewPolynomial _right_lcm_cofactor(self , SkewPolynomial other):
1458
1462
r """
1459
1463
Return a skew polynomial `U` such that `P U = L c`
1460
1464
where `P` is this skew polynomial ( ``self``) , `L`
1461
1465
is the right lcm of `P` and ``other`` and `c` is a
1462
1466
constant
1463
1467
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
+ .... : ''')
1465
1475
1466
1476
sage: k. <a> = GF( 7^ 5)
1467
1477
sage: Frob = k. frobenius_endomorphism( 3)
@@ -1471,23 +1481,21 @@ cdef class SkewPolynomial(AlgebraElement):
1471
1481
sage: P = D * S. random_element( )
1472
1482
sage: Q = D * S. random_element( )
1473
1483
sage: L = P. right_lcm( Q)
1474
- sage: U = P . _right_lcm_cofactor ( Q)
1484
+ sage: U = right_lcm_cofactor ( P, Q)
1475
1485
sage: ( P* U) . left_monic( ) == L
1476
1486
True
1477
1487
"""
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
1491
1499
1492
1500
@coerce_binop
1493
1501
def right_xlcm (self , other , monic = True ):
0 commit comments