Skip to content

Commit 2bb0ccf

Browse files
committed
better fix to #159
1 parent 4b2330b commit 2bb0ccf

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/Polynomials.jl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,20 +560,11 @@ function polyder(p::Poly{T}, order::Int=1) where {T}
560560
_polyder(p, order)
561561
end
562562

563-
# _int(T) returns matching Integer type to T
564-
# to avoid overflow in `prod` usage below
565-
_int(::Type{T}) where {T <: Union{Integer, Int8, Int16, Int64, Int128, BigInt}} = T
566-
_int(::Type{Float16}) = Int16
567-
_int(::Type{Float32}) = Int32
568-
_int(::Type{Float64}) = Int64
569-
_int(::Type{BigFloat}) = BigInt
570-
_int(x) = Int
571-
572563
function _polyder(p::Poly{T}, order::Int=1) where {T}
573564
n = length(p)
574565
a2 = Vector{T}(undef, n-order)
575566
for i = order:n-1
576-
a2[i-order+1] = p[i] * prod((one(_int(T)) * (i-order+1)):i)
567+
a2[i-order+1] = reduce(*, (i-order+1):i, init=p[i])
577568
end
578569

579570
return Poly(a2, p.var)

0 commit comments

Comments
 (0)