giordano / PolynomialRoots.jl

Fast complex polynomial root finder, with support for arbitrary precision calculations
Other
53 stars 15 forks source link

Why restricted to AbstractFloat? #13

Open dlfivefifty opened 4 years ago

dlfivefifty commented 4 years ago

This package doesn't work with interval arithmetic because it restricts to AbstractFloat:

julia> roots([1.,@interval(2),3])
ERROR: MethodError: no method matching roots!(::Array{Complex{Interval{Float64}},1}, ::Array{Complex{Interval{Float64}},1}, ::Float64, ::Int64, ::Bool)
Closest candidates are:
  roots!(::Array{Complex{T<:AbstractFloat},1}, ::Array{Complex{T<:AbstractFloat},1}, ::E<:AbstractFloat, ::Integer, ::Bool) where {T<:AbstractFloat, E<:AbstractFloat} at /Users/sheehanolver/.julia/packages/PolynomialRoots/gl0Ka/src/PolynomialRoots.jl:568
Stacktrace:
 [1] #roots#2(::Float64, ::Bool, ::typeof(roots), ::Array{Interval{Float64},1}) at /Users/sheehanolver/.julia/packages/PolynomialRoots/gl0Ka/src/PolynomialRoots.jl:613
 [2] roots(::Array{Interval{Float64},1}) at /Users/sheehanolver/.julia/packages/PolynomialRoots/gl0Ka/src/PolynomialRoots.jl:612
 [3] top-level scope at REPL[7]:1
giordano commented 4 years ago

About the why, it was done mostly for type-stability. I guess some signatures can be loosened while preserving type-stability. For context, this was one of my first Julia packages, I was overly conservative back then :slightly_smiling_face: