33"""
44const MINPRIME = 9999
55
6- function isirreducible (p:: P ; p0 = MINPRIME) where P<: UnivariatePolynomial{<:ZZ }
6+ function isirreducible (p:: P ; p0 = MINPRIME) where {T <: ZI , P<: UnivariatePolynomial{T} }
77 (iszero (p) || isunit (p)) && return false
88 deg (p) <= 1 && return true
99 iszero (p[0 ]) && return false
1010 X = varname (P)
11- Z = ZZ{BigInt} [X]
11+ Z = wide_type (T) [X]
1212 q = convert (Z, p)
1313 isone (pgcd (q, derive (q))) || return false
1414 zassenhaus_irr (q, p0)
@@ -20,11 +20,11 @@ function isirreducible(p::P; p0 = MINPRIME) where P<:UnivariatePolynomial{<:QQ}
2020 isirreducible (pp; p0)
2121end
2222
23- function factor (p:: P , a:: Integer = 1 ; p0 = MINPRIME) where P<: UnivariatePolynomial{<:ZZ }
23+ function factor (p:: P , a:: Integer = 1 ; p0 = MINPRIME) where {T <: ZI , P<: UnivariatePolynomial{T} }
2424 # println("factor($p)")
2525 X = varname (P)
2626 c = content (p)
27- Z = ZZ{BigInt} [X]
27+ Z = wide_type (T) [X]
2828 q = Z (isone (c) ? copy (p) : p / c)
2929 x = monom (Z)
3030 q, e, k = stripzeroscompress (q)
@@ -145,8 +145,7 @@ function zassenhaus2(u::UnivariatePolynomial{<:ZZ{<:Integer}}, val::Val{BO}, p0)
145145end
146146
147147# D = []
148-
149- function zassenhaus2 (u:: P , :: Val{BO} , p0) where {BO,P<: UnivariatePolynomial{ZZ{BigInt}} }
148+ function zassenhaus2 (u:: P , :: Val{BO} , p0) where {BO,T<: Union{ZZ{BigInt},ZZZ} ,P<: UnivariatePolynomial{T} }
150149 v, p = best_prime (u, p0)
151150 a = allgcdx (v)
152151 # println(" initial v/$p = "); display([v a])
@@ -266,7 +265,7 @@ function factor_exp(u::P, a::Integer, p0) where P<:UnivariatePolynomial
266265end
267266
268267# check if p is coprime with leading coefficient
269- function compatible_with (p:: Integer , u:: ZZ )
268+ function compatible_with (p:: Integer , u:: ZI )
270269 u = abs (value (u))
271270 gcd (p, u) == 1
272271end
@@ -335,7 +334,7 @@ function combinefactors(
335334 u:: Z ,
336335 vv:: AbstractVector{<:UnivariatePolynomial{Zp}} ,
337336 aa:: AbstractVector ,
338- ) where {Z<: UnivariatePolynomial{<:ZZ } ,Zp}
337+ ) where {Z<: UnivariatePolynomial{<:ZI } ,Zp}
339338 res = Tuple{Z,Any,Any}[]
340339 un = LC (u)
341340 unp = Zp (un)
@@ -394,10 +393,10 @@ end
394393function stripmod (
395394 :: Type{P} ,
396395 a:: UnivariatePolynomial{<:ZZmod} ,
397- ) where {Z<: ZZ ,P<: UnivariatePolynomial{Z} }
396+ ) where {Z<: ZI ,P<: UnivariatePolynomial{Z} }
398397 P (stripmod .(Z, a. coeff), ord (a))
399398end
400- stripmod (:: Type{Z} , a:: ZZmod ) where Z<: ZZ = Z (value (a))
399+ stripmod (:: Type{Z} , a:: ZZmod ) where Z<: ZI = Z (value (a))
401400
402401
403402function subset_with_a (v, d, a)
@@ -421,8 +420,8 @@ If `u` has an integer factor polynom `v` with `deg(v) == m`,
421420calculate array of bounds `b` with `abs(v[i]) <= b[i+1] for i = 0:m`.
422421Algorithm see TAoCP 2.Ed 4.6.2 Exercise 20.
423422"""
424- function coeffbounds (u:: UnivariatePolynomial{ZZ{T} ,X} , m:: Integer ) where {T<: Integer ,X}
425- W = widen (T )
423+ function coeffbounds (u:: UnivariatePolynomial{T ,X} , m:: Integer ) where {T<: ZI ,X}
424+ W = widen (basetype (T) )
426425 n = deg (u)
427426 0 <= m <= n || throw (ArgumentError (" required m ∈ [0,deg(u)] but $m ∉ [0,$n ]" ))
428427 accuracy = 100 # use fixed point decimal arithmetic with accuracy 0.01 for the norm
@@ -475,7 +474,7 @@ function hensel_lift(
475474 v:: AbstractVector{Pq} ,
476475 a:: AbstractVector{Pp} ,
477476) where {
478- Z<: ZZ ,
477+ Z<: ZI ,
479478 Zq<: ZZmod ,
480479 Zp<: ZZmod ,
481480 Pq<: UnivariatePolynomial{Zq} ,
@@ -517,10 +516,10 @@ function downmod(::Type{Zp}, f::P, q::Integer) where {Zp,X,T,P<:UnivariatePolyno
517516end
518517
519518
520- function _liftmod (:: Type{Z} , a:: ZZmod ) where {T, Z<: ZZ{T} }
521- Z (signed (T )(value (a)))
519+ function _liftmod (:: Type{Z} , a:: ZZmod ) where {Z<: ZI }
520+ Z (signed (basetype (Z) )(value (a)))
522521end
523- function _liftmod (:: Type{Z} , a:: ZZ ) where {X,T,Z<: ZZmod{X,T} }
522+ function _liftmod (:: Type{Z} , a:: ZI ) where {X,T,Z<: ZZmod{X,T} }
524523 Z (value (a))
525524end
526525function _liftmod (:: Type{Z} , a:: ZZmod ) where {X,T,Z<: ZZmod{X,T} }
0 commit comments