Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed fallback method for Datatypes not of type Float64, BigFloat and their Complex counterparts #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/roots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ end
# end
# end
# else
complexroots(cfs::Vector{T}) where T =
sort(eigvals(companion_matrix(chop(cfs, 10*eps(T)))), lt = (x, y) -> real(x) < real(y) ? true : (real(x) > real(y) ? false : (imag(x) < imag(y) ? true : false)), rev=true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this lexicographic ordering? In that case perhaps we might want to set the by keyword argument instead of the lt one, as by = x->(real(x), imag(x))


complexroots(cfs::Vector{T}) where {T<:Union{Float64,ComplexF64}} =
hesseneigvals(companion_matrix(chop(cfs,10eps())))
# end
Expand All @@ -56,9 +59,9 @@ complexroots(f::Fun{Taylor{DD,RR}}) where {DD,RR} =


function roots(f::Fun{Laurent{DD,RR}}) where {DD,RR}
irts=filter!(z->in(z,Circle()),complexroots(Fun(Laurent(Circle()),f.coefficients)))
irts=filter!(z->in(z,Circle(real(eltype(z)))),complexroots(Fun(Laurent(Circle()),f.coefficients)))
if length(irts)==0
Complex{Float64}[]
irts
else
rts=fromcanonical.(f, tocanonical.(Ref(Circle()), irts))
if isa(domain(f),PeriodicSegment)
Expand All @@ -70,4 +73,4 @@ function roots(f::Fun{Laurent{DD,RR}}) where {DD,RR}
end


roots(f::Fun{Fourier{D,R}}) where {D,R} = roots(Fun(f,Laurent))
roots(f::Fun{Fourier{D,R}}) where {D,R} = roots(Fun(f,Laurent))