Skip to content

Commit f5f8562

Browse files
authored
Fix promotion of multiplication (#89)
1 parent 885064b commit f5f8562

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/mult.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ function _mul(::Type{T}, p::Polynomial{true}, q::Polynomial{true}) where T
128128
return allvars, a, Z
129129
end
130130
function Base.:(*)(p::Polynomial{true, S}, q::Polynomial{true, T}) where {S, T}
131+
PT = MA.promote_operation(*, typeof(p), typeof(q))
131132
if iszero(p) || iszero(q)
132-
zero(MA.promote_operation(*, typeof(p), typeof(q)))
133+
zero(PT)
133134
else
134-
polynomialclean(_mul(MA.promote_operation(MA.add_mul, S, T), p, q)...)
135+
polynomialclean(_mul(MP.coefficienttype(PT), p, q)...)
135136
end
136137
end
137138
function MA.mutable_operate_to!(p::Polynomial{false, T}, ::typeof(*), q1::MP.AbstractPolynomialLike, q2::MP.AbstractPolynomialLike) where T

0 commit comments

Comments
 (0)