From bd1c54c3542a55a702854c624eea9e998f760ea6 Mon Sep 17 00:00:00 2001 From: Dedavond Date: Sat, 23 Jul 2022 22:01:34 +0200 Subject: [PATCH 1/3] Adding a more general method for complexroots which works for other datatypes --- src/roots.jl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/roots.jl b/src/roots.jl index f49ce63..cbcc3f2 100644 --- a/src/roots.jl +++ b/src/roots.jl @@ -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) + complexroots(cfs::Vector{T}) where {T<:Union{Float64,ComplexF64}} = hesseneigvals(companion_matrix(chop(cfs,10eps()))) # end @@ -46,7 +49,7 @@ function complexroots(cfs::Vector{T}) where T<:Union{BigFloat,Complex{BigFloat}} end complexroots(neg::Vector, pos::Vector) = - complexroots([reverse(chop(neg,10eps()), dims=1);pos]) + complexroots([reverse(chop(neg,10*eps()), dims=1);pos]) complexroots(f::Fun{Laurent{DD,RR}}) where {DD,RR} = mappoint.(Ref(Circle()), Ref(domain(f)), complexroots(f.coefficients[2:2:end],f.coefficients[1:2:end])) @@ -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) From cb9a69eb9dc99039e41c64487bfecc314ef88788 Mon Sep 17 00:00:00 2001 From: Dedavond <44230387+Dedavond@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:06:07 +0200 Subject: [PATCH 2/3] Update roots.jl --- src/roots.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/roots.jl b/src/roots.jl index cbcc3f2..c61a9bf 100644 --- a/src/roots.jl +++ b/src/roots.jl @@ -49,7 +49,7 @@ function complexroots(cfs::Vector{T}) where T<:Union{BigFloat,Complex{BigFloat}} end complexroots(neg::Vector, pos::Vector) = - complexroots([reverse(chop(neg,10*eps()), dims=1);pos]) + complexroots([reverse(chop(neg,10eps()), dims=1);pos]) complexroots(f::Fun{Laurent{DD,RR}}) where {DD,RR} = mappoint.(Ref(Circle()), Ref(domain(f)), complexroots(f.coefficients[2:2:end],f.coefficients[1:2:end])) @@ -73,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)) \ No newline at end of file +roots(f::Fun{Fourier{D,R}}) where {D,R} = roots(Fun(f,Laurent)) From c2a70ad089e44005c9d891bd39b9651f9181c5fe Mon Sep 17 00:00:00 2001 From: Dedavond <44230387+Dedavond@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:08:59 +0200 Subject: [PATCH 3/3] Update roots.jl