Skip to content

Commit f48c71d

Browse files
committed
Fix for TypedPolynomials
1 parent cb5069c commit f48c71d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/division.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ Base.rem(f::APL, g::Union{APL, AbstractVector{<:APL}}; kwargs...) = divrem(f, g;
3232

3333
proddiff(x, y) = x/y - x/y
3434
function Base.divrem(f::APL{T}, g::APL{S}; kwargs...) where {T, S}
35-
rf = convert(polynomialtype(f, Base.promote_op(proddiff, T, S)), MA.copy_if_mutable(f))
35+
# `promote_type(typeof(f), typeof(g))` is needed for TypedPolynomials in case they use different variables
36+
rf = convert(polynomialtype(promote_type(typeof(f), typeof(g)), Base.promote_op(proddiff, T, S)), MA.copy_if_mutable(f))
3637
q = zero(rf)
3738
r = zero(rf)
3839
lt = leadingterm(g)
@@ -60,7 +61,8 @@ function Base.divrem(f::APL{T}, g::APL{S}; kwargs...) where {T, S}
6061
q, r
6162
end
6263
function Base.divrem(f::APL{T}, g::AbstractVector{<:APL{S}}; kwargs...) where {T, S}
63-
rf = convert(polynomialtype(f, Base.promote_op(proddiff, T, S)), MA.copy_if_mutable(f))
64+
# `promote_type(typeof(f), eltype(g))` is needed for TypedPolynomials in case they use different variables
65+
rf = convert(polynomialtype(promote_type(typeof(f), eltype(g)), Base.promote_op(proddiff, T, S)), MA.copy_if_mutable(f))
6466
r = zero(rf)
6567
q = similar(g, typeof(rf))
6668
for i in eachindex(q)

0 commit comments

Comments
 (0)