2828Base. show (io:: IO , t:: IdTerm ) = show (io, t. arg)
2929
3030struct FunctionTerm <: Term
31- op:: Function
31+ op # ::Function
3232 coeff:: RingElement
3333 arg:: RingElement
3434end
@@ -252,12 +252,9 @@ function PartialFraction(a::T, d::Vector{T}, e::Vector{Int}) where T <: RingElem
252252 a0, A
253253end
254254
255- function SubResultant (A:: PolyElem{T} , B:: PolyElem{T} ) where T <: FieldElement
255+ function SubResultant (A:: PolyElem{T} , B:: PolyElem{T} ) where T <: RingElement
256256 # See Bronstein's book, Section 1.5, p. 24
257- # Note: This implementation requires that A, B are polynomials over a field
258- # (and not mereley over an integral domain), because some intermediate
259- # calculations use divisons. For example, negative exponents of γ[i-1]
260- # can occur, or the division in the definition of q.
257+ degree (A) >= degree (B) || error (" degree(A) must be >= degree(B)" )
261258 T_one = one (leading_coefficient (A)) # 1 of type T
262259 Rs = [A, B] # indices shifted!
263260 i = 1
@@ -271,7 +268,8 @@ function SubResultant(A::PolyElem{T}, B::PolyElem{T}) where T <: FieldElement
271268 q = divexact (R, β[i])
272269 push! (Rs, q)
273270 i += 1
274- push! (γ, (- r[i- 1 ])^ δ[i- 1 ]* γ[i- 1 ]^ (1 - δ[i- 1 ]) )
271+ h = δ[i- 1 ]<= 1 ? (- r[i- 1 ])^ δ[i- 1 ]* γ[i- 1 ]^ (1 - δ[i- 1 ]) : divexact ((- r[i- 1 ])^ δ[i- 1 ], γ[i- 1 ]^ (δ[i- 1 ]- 1 ))
272+ push! (γ, h)
275273 push! (δ, degree (Rs[i- 1 + 1 ]) - degree (Rs[i+ 1 ]) )
276274 push! (β, - r[i- 1 ]* γ[i]^ δ[i])
277275 end
@@ -295,22 +293,6 @@ function SubResultant(A::PolyElem{T}, B::PolyElem{T}) where T <: FieldElement
295293 constant_coefficient ((s* c)* Rs[k+ 1 ]^ degree (Rs[k- 1 + 1 ])), vcat (Rs[1 : k+ 1 ], zero_poly)
296294end
297295
298- function SubResultant (A:: PolyElem{T} , B:: PolyElem{T} ) where T <: RingElement
299- # If we have polynomials over integral domain we upgrade them to polynomials
300- # over the fraction field. Then we call the above implementation of SubResultant
301- # for polynomials over fields. Finally we downgrade the results to elements
302- # over the base integral domain.
303- Z = zero (leading_coefficient (A))// one (leading_coefficient (A))
304- # upgrade A, B \in R[t] to elements a, b of K[t] where K is the fraction ring of R
305- a = map_coefficients (c-> (c+ Z), A)
306- b = map_coefficients (c-> (c+ Z), B)
307- r0, Rs0 = SubResultant (a, b)
308- # downgrade r, RS from elements of K[t] to elements of R[t]
309- r = numerator (r0)
310- Rs = [map_coefficients (c-> numerator (c), R) for R in Rs0]
311- r, Rs
312- end
313-
314296function Squarefree_Musser (A:: PolyElem{T} ) where T <: RingElement
315297 # See Bronstein's book, Section 1.7, p. 29
316298 c = content (A)
0 commit comments