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

Conversation

DavidMeadon
Copy link

@DavidMeadon DavidMeadon commented Jul 23, 2022

Hi,

I needed to do division between two Laurent functions using the Double64 datatype from DoubleFloats.jl. I kept running into issues because the complexroots function only had methods for Float64, BigFloat and their Complex counterparts. So I here propose a more general fallback method which I have tested and works for Double64.

The sort is added ontop of the eigvals call so that the returned eigenvalues are in the same order as those returned from hesseneigvals.

Furthermore inside the roots function I have added the type inside the Circle of the filter! call otherwise there was some issues with domains.

Finally, in the if-statement of roots, the returned vector should not be hardcoded to be a Complex{Float64} but perhaps irts (as I have done) or someother way to make it more general.

@jishnub
Copy link
Member

jishnub commented Apr 4, 2023

Sorry I just noticed this PR, are you still interested in this? Would be good to have this added

@@ -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))

@MikaelSlevinsky
Copy link
Member

This would seem like a reasonable use for https://github.com/JuliaLinearAlgebra/GenericLinearAlgebra.jl which has eigvals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants