From 2bb0ccffc0cffd6d3cea92694cabf287b8fa4f0c Mon Sep 17 00:00:00 2001 From: jverzani Date: Fri, 18 Jan 2019 10:59:56 -0500 Subject: [PATCH] better fix to #159 --- src/Polynomials.jl | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Polynomials.jl b/src/Polynomials.jl index 184184bc..b70b051c 100644 --- a/src/Polynomials.jl +++ b/src/Polynomials.jl @@ -560,20 +560,11 @@ function polyder(p::Poly{T}, order::Int=1) where {T} _polyder(p, order) end -# _int(T) returns matching Integer type to T -# to avoid overflow in `prod` usage below -_int(::Type{T}) where {T <: Union{Integer, Int8, Int16, Int64, Int128, BigInt}} = T -_int(::Type{Float16}) = Int16 -_int(::Type{Float32}) = Int32 -_int(::Type{Float64}) = Int64 -_int(::Type{BigFloat}) = BigInt -_int(x) = Int - function _polyder(p::Poly{T}, order::Int=1) where {T} n = length(p) a2 = Vector{T}(undef, n-order) for i = order:n-1 - a2[i-order+1] = p[i] * prod((one(_int(T)) * (i-order+1)):i) + a2[i-order+1] = reduce(*, (i-order+1):i, init=p[i]) end return Poly(a2, p.var)