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

Add eigen for general purpose computation of eigenvectors/eigenvalues #1572

Closed
GVigne opened this issue Aug 4, 2022 · 1 comment
Closed
Labels
cuda libraries Stuff about CUDA library wrappers. enhancement New feature or request help wanted Extra attention is needed

Comments

@GVigne
Copy link
Contributor

GVigne commented Aug 4, 2022

Is your feature request related to a problem? Please describe.
I would like to be able to compute the eigenvectors and eigenvalues a matrix which can either hold floats or complex. I didn't see a generic way to do this (like LinearAlgebra's eigen) and instead have to manually check the type before calling the appropriate functions, namely syevd!and heevd! (the matrix is always Hermitian/symmetric).

Describe the solution you'd like
A high level function taking a matrix A and returning, if possible, the eigenvectors and eigenvalues of A. This function may throw if no appropriate function was found (I think there aren't a lot of solvers for non-Hermitian complex matrixces in cuSolver).

Describe alternatives you've considered
Right now, I am doing something like

if eltype(A) <: Complex
        vals, vects = CUDA.CUSOLVER.heevd!('V','U',A)
    else
        vals, vects = CUDA.CUSOLVER.syevd!('V','U',A)
    end

This is the type of thing I imagined eigen could do.

Additional context
Maybe there is a very good reason as why this wasn't implemented, but I couldn't find it in the docs or the code. If eigen is not to be implemented, maybe we could add a little paragraph somewhere to explain this?

@maleadt
Copy link
Member

maleadt commented Apr 27, 2024

We seem to have this now:

function LinearAlgebra.eigen(A::Symmetric{T,<:CuMatrix}) where {T<:BlasReal}
A2 = copy(A.data)
Eigen(syevd!('V', 'U', A2)...)
end
function LinearAlgebra.eigen(A::Hermitian{T,<:CuMatrix}) where {T<:BlasComplex}
A2 = copy(A.data)
Eigen(heevd!('V', 'U', A2)...)
end
function LinearAlgebra.eigen(A::Hermitian{T,<:CuMatrix}) where {T<:BlasReal}
eigen(Symmetric(A))
end

@maleadt maleadt closed this as completed Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda libraries Stuff about CUDA library wrappers. enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants