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

Commit

Permalink
Merge branch 'skew_polynomial_finite_field' into skew_polynomial_fini…
Browse files Browse the repository at this point in the history
…te_field_rc0
  • Loading branch information
xcaruso committed Apr 16, 2020
2 parents fddbb5e + cccfef5 commit f7e08ff
Show file tree
Hide file tree
Showing 5 changed files with 1,256 additions and 39 deletions.
3 changes: 3 additions & 0 deletions src/module_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,9 @@ def uname_specific(name, value, alternative):
Extension('sage.rings.polynomial.skew_polynomial_finite_order',
sources = ['sage/rings/polynomial/skew_polynomial_finite_order.pyx']),

Extension('sage.rings.polynomial.skew_polynomial_finite_field',
sources = ['sage/rings/polynomial/skew_polynomial_finite_field.pyx']),

# Note that weil_polynomials includes distutils directives in order to support
# conditional OpenMP compilation (by uncommenting lines)
Extension('sage.rings.polynomial.weil.weil_polynomials',
Expand Down
100 changes: 71 additions & 29 deletions src/sage/rings/polynomial/skew_polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,71 @@ cdef class SkewPolynomial(AlgebraElement):
A = A.left_monic()
return A

def _left_lcm_cofactor(self, other):
R = self._parent
U = R.one()
G = self
V1 = R.zero()
V3 = other
while not V3.is_zero():
Q, R = G.right_quo_rem(V3)
T = U - Q*V1
U = V1
G = V3
V1 = T
V3 = R
return V1

@coerce_binop
def left_xlcm(self, other, monic=True):
r"""
Return the left lcm of ``self`` and ``other`` together
with two skew polynomials `u` and `v` such that
`u \cdot \text{self} = v \cdot \text{other} = \text{llcm``
"""
if self.base_ring() not in Fields:
raise TypeError("the base ring must be a field")
if self.is_zero() or other.is_zero():
raise ZeroDivisionError("division by zero is not valid")
V1 = self._left_lcm_cofactor(other)
L = V1 * self
if monic:
s = ~(L.leading_coefficient())
L = s * L
V1 = s * V1
return L, V1, L // other

def _right_lcm_cofactor(self, other):
R = self._parent
U = R.one()
G = self
V1 = R.zero()
V3 = other
while not V3.is_zero():
Q, R = G.left_quo_rem(V3)
T = U - V1*Q
U = V1
G = V3
V1 = T
V3 = R
return V1

@coerce_binop
def right_xlcm(self, other, monic=True):
if self.base_ring() not in Fields:
raise TypeError("the base ring must be a field")
if self.is_zero() or other.is_zero():
raise ZeroDivisionError("division by zero is not valid")
V1 = self._right_lcm_cofactor(other)
L = self * V1
if monic:
s = self._parent.twist_map(-self.degree())(~(L.leading_coefficient()))
L = L * s
V1 = V1 * s
W1, _ = L.left_quo_rem(other)
return L, V1, W1


@coerce_binop
def left_lcm(self, other, monic=True):
r"""
Expand Down Expand Up @@ -1444,21 +1509,10 @@ cdef class SkewPolynomial(AlgebraElement):
raise TypeError("the base ring must be a field")
if self.is_zero() or other.is_zero():
raise ZeroDivisionError("division by zero is not valid")
U = self._parent.one()
G = self
V1 = self._parent.zero()
V3 = other
while not V3.is_zero():
Q, R = G.right_quo_rem(V3)
T = U - Q*V1
U = V1
G = V3
V1 = T
V3 = R
V1 = V1 * self
L = self._left_lcm_cofactor(other) * self
if monic:
V1 = V1.right_monic()
return V1
L = L.right_monic()
return L

@coerce_binop
def right_lcm(self, other, monic=True):
Expand Down Expand Up @@ -1539,22 +1593,10 @@ cdef class SkewPolynomial(AlgebraElement):
raise TypeError("the base ring must be a field")
if self.is_zero() or other.is_zero():
raise ZeroDivisionError("division by zero is not valid")
R = self.parent()
U = R.one()
G = self
V1 = R.zero()
V3 = other
while not V3.is_zero():
Q, R = G.left_quo_rem(V3)
T = U - V1*Q
U = V1
G = V3
V1 = T
V3 = R
V1 = self * V1
L = self * self._right_lcm_cofactor(other)
if monic:
V1 = V1.left_monic()
return V1
L = L.left_monic()
return L

def _repr_(self, name=None):
r"""
Expand Down
15 changes: 15 additions & 0 deletions src/sage/rings/polynomial/skew_polynomial_finite_field.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from sage.rings.polynomial.skew_polynomial_finite_order cimport SkewPolynomial_finite_order_dense
from sage.matrix.matrix_dense cimport Matrix_dense

cdef class SkewPolynomial_finite_field_dense (SkewPolynomial_finite_order_dense):
cdef _norm_factor
cdef dict _rdivisors
cdef dict _types
cdef _factorization

# Finding divisors
cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, N)

# Finding factorizations
cdef _factor_c(self)
cdef _factor_uniform_c(self)
Loading

0 comments on commit f7e08ff

Please sign in to comment.