@@ -3918,6 +3918,19 @@ cdef class Polynomial(CommutativeAlgebraElement):
3918
3918
if self .degree() == 0 :
3919
3919
return Factorization([], unit = self [0 ])
3920
3920
3921
+ # Use multivariate implementations for polynomials over polynomial rings
3922
+ variables = self ._parent.variable_names_recursive()
3923
+ if len (variables) > 1 :
3924
+ base = self ._parent._mpoly_base_ring()
3925
+ ring = PolynomialRing(base, variables)
3926
+ if ring._has_singular:
3927
+ try :
3928
+ d = self ._mpoly_dict_recursive()
3929
+ F = ring(d).factor(** kwargs)
3930
+ return Factorization([(self ._parent(f),m) for (f,m) in F], unit = F.unit())
3931
+ except NotImplementedError :
3932
+ pass
3933
+
3921
3934
R = self .parent().base_ring()
3922
3935
if hasattr (R, ' _factor_univariate_polynomial' ):
3923
3936
return R._factor_univariate_polynomial(self , ** kwargs)
@@ -6291,7 +6304,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
6291
6304
6292
6305
return self .parent()(v)
6293
6306
6294
- def roots (self , ring = None , multiplicities = True , algorithm = None ):
6307
+ def roots (self , ring = None , multiplicities = True , algorithm = None , ** kwds ):
6295
6308
"""
6296
6309
Return the roots of this polynomial (by default, in the base ring
6297
6310
of this polynomial).
@@ -6873,7 +6886,10 @@ cdef class Polynomial(CommutativeAlgebraElement):
6873
6886
"""
6874
6887
K = self .parent().base_ring()
6875
6888
if hasattr (K, ' _roots_univariate_polynomial' ):
6876
- return K._roots_univariate_polynomial(self , ring = ring, multiplicities = multiplicities, algorithm = algorithm)
6889
+ return K._roots_univariate_polynomial(self , ring = ring, multiplicities = multiplicities, algorithm = algorithm, ** kwds)
6890
+
6891
+ if kwds:
6892
+ raise TypeError (" roots() got unexpected keyword argument(s): {}" .format(kwds.keys()))
6877
6893
6878
6894
L = K if ring is None else ring
6879
6895
@@ -8621,7 +8637,6 @@ cdef class Polynomial(CommutativeAlgebraElement):
8621
8637
raise ValueError (" not a %s power" % m.ordinal_str())
8622
8638
raise ValueError (" not a %s power" % m.ordinal_str())
8623
8639
8624
-
8625
8640
# ----------------- inner functions -------------
8626
8641
# Cython can't handle function definitions inside other function
8627
8642
0 commit comments