-
-
Couldn't load subscription status.
- Fork 5.7k
LinearAlgebra: move alg to a keyword argument in symmetric eigen #55481
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
Conversation
|
Losing the ability to specialize on a custom alg type seems like a pretty big loss. How would one write EigenAlgorithms.jl? FWIW, specialization on algorithms in sorting using the public API is a mess. |
|
Aren't eigenvalue computations large and slow enough that there wouldn't be gains from specialization? Is the argument that it would make the rest of the computation type unstable in some way? |
|
Perhaps we may have an internal function that specialises on |
|
@ViralBShah, the argument is that the extension API is not as discoverable. Performance and type stability should be fine. # LinearAlgebra.jl
public eigen
eigen(::AbstractMatrix, ::Algorithm) = ...
---
# EigenAlgorithms.jl
eigen(::AbstractMatrix, ::MyFancyAlgorithm) = ...vs # LinearAlgebra.jl
public eigen, eigen_dispatch
eigen(x::AbstractMatrix; alg::Algorithm) = eigen_dispatch(x, a)
eigen_dispatch(::AbstracMatrix, ::Algorithm) = ...
---
# EigenAlgorithms.jl
eigen_dispatch(::AbstractMatrix, ::MyFancyAlgorithm) = ... |
|
I don't think this needs to be particularly discoverable, as this isn't user-facing. We may add a note to developers in the docstring of eigen to point to this function. |
|
We have moved the LinearAlgebra stdlib to an external repo: https://github.com/JuliaLang/LinearAlgebra.jl @jishnub If you think that this PR is still relevant, please open a new PR on the LinearAlgebra.jl repo. |
This reopens JuliaLang/julia#55481 One argument there was that packages may wish to define custom eigenvalue algorithms. I'm unsure if this is common, but in principle, we may provide an internal method `eigen(A, alg)` that packages extend, and users may call the method with `alg` as a keyword argument. Fixes #1208 --------- Co-authored-by: Viral B. Shah <[email protected]>
This reopens JuliaLang/julia#55481 One argument there was that packages may wish to define custom eigenvalue algorithms. I'm unsure if this is common, but in principle, we may provide an internal method `eigen(A, alg)` that packages extend, and users may call the method with `alg` as a keyword argument. Fixes #1208 --------- Co-authored-by: Viral B. Shah <[email protected]>
Currently,
eigenfor symmetric matrices accepts analgas the second positional argument, but this departs from the pattern ofeigen(A, B)representing a generalized eigenvalue problem. This PR movesalgto a keyword argument instead. This prevents packages from specializing onalg, but I'm unsure if there's demand for that.Incidentally,
algas a keyword argument ineigenis also consistent with how it is passed to thesortfamily of functions, although there's no direct relation between these.