@@ -35,7 +35,6 @@ from sage.matrix.matrix_dense cimport Matrix_dense
35
35
from sage.matrix.matrix_space import MatrixSpace
36
36
from sage.rings.all import ZZ
37
37
from sage.rings.polynomial.polynomial_element cimport Polynomial
38
- from sage.rings.polynomial.skew_polynomial_element cimport CenterSkewPolynomial_generic_dense
39
38
from sage.rings.integer cimport Integer
40
39
from sage.structure.element cimport RingElement
41
40
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
@@ -225,7 +224,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
225
224
# Finding divisors
226
225
# ----------------
227
226
228
- cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, CenterSkewPolynomial_generic_dense N):
227
+ cdef SkewPolynomial_finite_field_dense _rdivisor_c(P, N):
229
228
"""
230
229
cython procedure computing an irreducible monic right divisor
231
230
of `P` whose reduced norm is `N`
@@ -246,8 +245,8 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
246
245
D = D.right_monic()
247
246
return D
248
247
249
- Z = PolynomialRing( N.parent().base_ring(), name = ' xr ' )
250
- E = Z .quo(Z(N.list()) )
248
+ center = N.parent()
249
+ E = center .quo(N )
251
250
PE = PolynomialRing(E, name = ' T' )
252
251
cdef Integer exp
253
252
if skew_ring.characteristic() != 2 :
@@ -293,7 +292,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
293
292
yy += 2
294
293
dd = xx.gcd(yy)
295
294
if dd.degree() != 1 : continue
296
- D = P.right_gcd(R + skew_ring. center()(( dd[0 ]/ dd[1 ]).list()))
295
+ D = P.right_gcd(R + skew_ring( center(( dd[0 ]/ dd[1 ]).list() )))
297
296
if D.degree() == 0 :
298
297
continue
299
298
D = D.right_monic()
@@ -467,7 +466,6 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
467
466
x + 2*t^2 + 4*t
468
467
"""
469
468
cdef SkewPolynomial_finite_field_dense cP1
470
- cdef CenterSkewPolynomial_generic_dense cN
471
469
if self .is_zero():
472
470
raise " No irreducible divisor having given reduced norm"
473
471
skew_ring = self ._parent
@@ -491,7 +489,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
491
489
except (KeyError , TypeError ):
492
490
if N.is_irreducible():
493
491
cP1 = < SkewPolynomial_finite_field_dense> self .right_gcd(self ._parent(N))
494
- cN = < CenterSkewPolynomial_generic_dense > N
492
+ cN = N
495
493
if cP1.degree() > 0 :
496
494
D = cP1._rdivisor_c(cN)
497
495
if self ._rdivisors is None :
@@ -762,7 +760,7 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
762
760
val += 1
763
761
764
762
cdef Py_ssize_t degQ, degrandom, m, mP, i
765
- cdef CenterSkewPolynomial_generic_dense N
763
+ cdef N
766
764
cdef list factors = [ (skew_ring.gen(), val) ]
767
765
cdef SkewPolynomial_finite_field_dense P, Q, P1, NS, g, right, Pn
768
766
cdef RingElement unit = < RingElement> self .leading_coefficient()
@@ -826,14 +824,13 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
826
824
"""
827
825
skew_ring = self ._parent
828
826
cdef Integer cardE, cardcenter = skew_ring.center().base_ring().cardinality()
829
- cdef CenterSkewPolynomial_generic_dense gencenter = < CenterSkewPolynomial_generic_dense > skew_ring.center().gen()
827
+ cdef gencenter = skew_ring.center().gen()
830
828
cdef SkewPolynomial_finite_field_dense gen = < SkewPolynomial_finite_field_dense> skew_ring.gen()
831
829
832
830
cdef list factorsN = [ ]
833
831
cdef dict dict_divisor = { }
834
832
cdef dict dict_type = { }
835
833
cdef dict dict_right = { }
836
- cdef CenterSkewPolynomial_generic_dense N
837
834
cdef Py_ssize_t m
838
835
cdef list type
839
836
@@ -1055,37 +1052,9 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
1055
1052
count /= factorial(m)
1056
1053
return count * factorial(summ)
1057
1054
1058
- def count_factorisations (self ):
1059
- """
1060
- Return the number of factorisations (as a product of a
1061
- unit and a product of irreducible monic factors) of this
1062
- skew polynomial.
1063
-
1064
- EXAMPLES::
1065
-
1066
- sage: k.<t> = GF(5^3)
1067
- sage: Frob = k.frobenius_endomorphism()
1068
- sage: S.<x> = k['x',Frob]
1069
- sage: a = x^4 + (4*t + 3)*x^3 + t^2*x^2 + (4*t^2 + 3*t)*x + 3*t
1070
- sage: a.count_factorisations()
1071
- 216
1072
-
1073
- We illustrate that an irreducible polynomial in the center have
1074
- in general a lot of distinct factorisations in the skew polynomial
1075
- ring::
1076
-
1077
- sage: Z = S.center(); x3 = Z.gen()
1078
- sage: N = x3^5 + 4*x3^4 + 4*x3^2 + 4*x3 + 3; N
1079
- (x^3)^5 + 4*(x^3)^4 + 4*(x^3)^2 + 4*(x^3) + 3
1080
- sage: N.is_irreducible()
1081
- True
1082
- sage: S(N).count_factorisations()
1083
- 30537115626
1084
- """
1085
- return self .count_factorizations()
1086
1055
1087
-
1088
- # Not optimized ( many calls to reduced_norm, reduced_norm_factor,_rdivisor_c, which are slow)
1056
+ # Not optimized:
1057
+ # many calls to reduced_norm, reduced_norm_factor,_rdivisor_c, which are slow
1089
1058
def factorizations (self ):
1090
1059
"""
1091
1060
Return an iterator over all factorizations (as a product
@@ -1132,65 +1101,16 @@ cdef class SkewPolynomial_finite_field_dense(SkewPolynomial_finite_order_dense):
1132
1101
"""
1133
1102
if self .is_zero():
1134
1103
raise ValueError (" factorization of 0 not defined" )
1135
- unit = self .leading_coefficient()
1136
- poly = self .right_monic()
1137
- for factors in self ._factorizations_rec():
1104
+ def factorizations_rec (P ):
1105
+ if P.is_irreducible():
1106
+ yield [ (P,1 ) ]
1107
+ else :
1108
+ for div in P._irreducible_divisors(True ):
1109
+ poly = self // div
1110
+ # Here, we should update poly._norm, poly._norm_factor, poly._rdivisors
1111
+ for factors in P._factorizations_rec():
1112
+ factors.append((div,1 ))
1113
+ yield factors
1114
+ for factors in factorizations_rec(self ):
1138
1115
yield Factorization(factors,sort = False ,unit = unit)
1139
1116
1140
- def _factorizations_rec (self ):
1141
- if self .is_irreducible():
1142
- yield [ (self ,1 ) ]
1143
- else :
1144
- for div in self ._irreducible_divisors(True ):
1145
- poly = self // div
1146
- # Here, we should update poly._norm, poly._norm_factor, poly._rdivisors
1147
- for factors in poly._factorizations_rec():
1148
- factors.append((div,1 ))
1149
- yield factors
1150
-
1151
-
1152
- def factorisations (self ):
1153
- """
1154
- Return an iterator over all factorisations (as a product
1155
- of a unit and a product of irreducible monic factors) of
1156
- this skew polynomial.
1157
-
1158
- .. NOTE::
1159
-
1160
- The algorithm is probabilistic. As a consequence, if
1161
- we execute two times with the same input we can get
1162
- the list of all factorizations in two differents orders.
1163
-
1164
- EXAMPLES::
1165
-
1166
- sage: k.<t> = GF(5^3)
1167
- sage: Frob = k.frobenius_endomorphism()
1168
- sage: S.<x> = k['x',Frob]
1169
- sage: a = x^3 + (t^2 + 1)*x^2 + (2*t + 3)*x + t^2 + t + 2
1170
- sage: iter = a.factorisations(); iter
1171
- <generator object at 0x...>
1172
- sage: iter.next() # random
1173
- (x + 3*t^2 + 4*t) * (x + 2*t^2) * (x + 4*t^2 + 4*t + 2)
1174
- sage: iter.next() # random
1175
- (x + 3*t^2 + 4*t) * (x + 3*t^2 + 2*t + 2) * (x + 4*t^2 + t + 2)
1176
-
1177
- We can use this function to build the list of factorizations
1178
- of `a`::
1179
-
1180
- sage: factorisations = [ F for F in a.factorisations() ]
1181
-
1182
- We do some checks::
1183
-
1184
- sage: len(factorisations) == a.count_factorisations()
1185
- True
1186
- sage: len(factorisations) == len(Set(factorisations)) # check no duplicates
1187
- True
1188
- sage: for F in factorisations:
1189
- ... if F.value() != a:
1190
- ... print "Found %s which is not a correct factorization" % d
1191
- ... continue
1192
- ... for d,_ in F:
1193
- ... if not d.is_irreducible():
1194
- ... print "Found %s which is not a correct factorization" % d
1195
- """
1196
- return self .factorizations()
0 commit comments