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

Commit e3f2b25

Browse files
committed
rebase on top of ticket #21262
1 parent 5929bf9 commit e3f2b25

5 files changed

+1419
-38
lines changed

src/module_list.py

+3
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,9 @@ def uname_specific(name, value, alternative):
15311531
Extension('sage.rings.polynomial.skew_polynomial_finite_order',
15321532
sources = ['sage/rings/polynomial/skew_polynomial_finite_order.pyx']),
15331533

1534+
Extension('sage.rings.polynomial.skew_polynomial_finite_field',
1535+
sources = ['sage/rings/polynomial/skew_polynomial_finite_field.pyx']),
1536+
15341537
# Note that weil_polynomials includes distutils directives in order to support
15351538
# conditional OpenMP compilation (by uncommenting lines)
15361539
Extension('sage.rings.polynomial.weil.weil_polynomials',

src/sage/rings/polynomial/skew_polynomial_element.pyx

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

1384+
def _left_lcm_cofactor(self, other):
1385+
R = self._parent
1386+
U = R.one()
1387+
G = self
1388+
V1 = R.zero()
1389+
V3 = other
1390+
while not V3.is_zero():
1391+
Q, R = G.right_quo_rem(V3)
1392+
T = U - Q*V1
1393+
U = V1
1394+
G = V3
1395+
V1 = T
1396+
V3 = R
1397+
return V1
1398+
1399+
@coerce_binop
1400+
def left_xlcm(self, other, monic=True):
1401+
r"""
1402+
Return the left lcm of ``self`` and ``other`` together
1403+
with two skew polynomials `u` and `v` such that
1404+
`u \cdot \text{self} = v \cdot \text{other} = \text{llcm``
1405+
"""
1406+
if self.base_ring() not in Fields:
1407+
raise TypeError("the base ring must be a field")
1408+
if self.is_zero() or other.is_zero():
1409+
raise ZeroDivisionError("division by zero is not valid")
1410+
V1 = self._left_lcm_cofactor(other)
1411+
L = V1 * self
1412+
if monic:
1413+
s = ~(L.leading_coefficient())
1414+
L = s * L
1415+
V1 = s * V1
1416+
return L, V1, L // other
1417+
1418+
def _right_lcm_cofactor(self, other):
1419+
R = self._parent
1420+
U = R.one()
1421+
G = self
1422+
V1 = R.zero()
1423+
V3 = other
1424+
while not V3.is_zero():
1425+
Q, R = G.left_quo_rem(V3)
1426+
T = U - V1*Q
1427+
U = V1
1428+
G = V3
1429+
V1 = T
1430+
V3 = R
1431+
return V1
1432+
1433+
@coerce_binop
1434+
def right_xlcm(self, other, monic=True):
1435+
if self.base_ring() not in Fields:
1436+
raise TypeError("the base ring must be a field")
1437+
if self.is_zero() or other.is_zero():
1438+
raise ZeroDivisionError("division by zero is not valid")
1439+
V1 = self._right_lcm_cofactor(other)
1440+
L = self * V1
1441+
if monic:
1442+
s = self._parent.twist_map(-self.degree())(~(L.leading_coefficient()))
1443+
L = L * s
1444+
V1 = V1 * s
1445+
W1, _ = L.left_quo_rem(other)
1446+
return L, V1, W1
1447+
1448+
13841449
@coerce_binop
13851450
def left_lcm(self, other, monic=True):
13861451
r"""
@@ -1444,21 +1509,10 @@ cdef class SkewPolynomial(AlgebraElement):
14441509
raise TypeError("the base ring must be a field")
14451510
if self.is_zero() or other.is_zero():
14461511
raise ZeroDivisionError("division by zero is not valid")
1447-
U = self._parent.one()
1448-
G = self
1449-
V1 = self._parent.zero()
1450-
V3 = other
1451-
while not V3.is_zero():
1452-
Q, R = G.right_quo_rem(V3)
1453-
T = U - Q*V1
1454-
U = V1
1455-
G = V3
1456-
V1 = T
1457-
V3 = R
1458-
V1 = V1 * self
1512+
L = self._left_lcm_cofactor(other) * self
14591513
if monic:
1460-
V1 = V1.right_monic()
1461-
return V1
1514+
L = L.right_monic()
1515+
return L
14621516

14631517
@coerce_binop
14641518
def right_lcm(self, other, monic=True):
@@ -1539,22 +1593,10 @@ cdef class SkewPolynomial(AlgebraElement):
15391593
raise TypeError("the base ring must be a field")
15401594
if self.is_zero() or other.is_zero():
15411595
raise ZeroDivisionError("division by zero is not valid")
1542-
R = self.parent()
1543-
U = R.one()
1544-
G = self
1545-
V1 = R.zero()
1546-
V3 = other
1547-
while not V3.is_zero():
1548-
Q, R = G.left_quo_rem(V3)
1549-
T = U - V1*Q
1550-
U = V1
1551-
G = V3
1552-
V1 = T
1553-
V3 = R
1554-
V1 = self * V1
1596+
L = self * self._right_lcm_cofactor(other)
15551597
if monic:
1556-
V1 = V1.left_monic()
1557-
return V1
1598+
L = L.left_monic()
1599+
return L
15581600

15591601
def _repr_(self, name=None):
15601602
r"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from sage.rings.polynomial.skew_polynomial_finite_order cimport SkewPolynomial_finite_order_dense
2+
from sage.matrix.matrix_dense cimport Matrix_dense
3+
4+
cdef class SkewPolynomial_finite_field_dense (SkewPolynomial_finite_order_dense):
5+
cdef _norm_factor
6+
cdef dict _rdivisors
7+
cdef dict _types
8+
cdef _factorization
9+
10+
# Finding divisors
11+
cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, N)
12+
13+
# Finding factorizations
14+
cdef _factor_c(self)
15+
cdef _factor_uniform_c(self)

0 commit comments

Comments
 (0)