Skip to content

Support passing Hermitian matrix to eigh_x #35

@mtfishman

Description

@mtfishman

For example:

julia> using MatrixAlgebraKit, LinearAlgebra

julia> eigh_full(Hermitian(randn(4, 4)))
ERROR: MethodError: no method matching default_eigh_algorithm(::Type{Hermitian{Float64, Matrix{Float64}}})
This error has been manually thrown, explicitly, so the method may exist but be intentionally marked as unimplemented.

Closest candidates are:
  default_eigh_algorithm(::Type; kwargs...)
   @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:90
  default_eigh_algorithm(::Any; kwargs...)
   @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:89
  default_eigh_algorithm(::Type{T}; kwargs...) where T<:(StridedMatrix{T} where T<:Union{Float32, Float64, ComplexF64, ComplexF32})
   @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:93

Stacktrace:
  [1] default_eigh_algorithm(T::Type; kwargs::@Kwargs{})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:91
  [2] default_eigh_algorithm(T::Type)
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:90
  [3] default_algorithm(::typeof(eigh_full!), ::Type{Hermitian{Float64, Matrix{Float64}}}; kwargs::@Kwargs{})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:99
  [4] default_algorithm(::typeof(eigh_full!), ::Type{Hermitian{Float64, Matrix{Float64}}})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/interface/eigh.jl:98
  [5] default_algorithm(f::typeof(eigh_full!), A::Hermitian{Float64, Matrix{Float64}}; kwargs::@Kwargs{})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:108
  [6] default_algorithm(f::typeof(eigh_full!), A::Hermitian{Float64, Matrix{Float64}})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:108
  [7] select_algorithm(f::typeof(eigh_full!), A::Hermitian{Float64, Matrix{Float64}}, alg::Nothing; kwargs::@Kwargs{})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:81
  [8] select_algorithm(f::typeof(eigh_full!), A::Hermitian{Float64, Matrix{Float64}}, alg::Nothing)
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:79
  [9] eigh_full!(A::Hermitian{Float64, Matrix{Float64}}; alg::Nothing, kwargs::@Kwargs{})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:183
 [10] eigh_full!(A::Hermitian{Float64, Matrix{Float64}})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:182
 [11] eigh_full(A::Hermitian{Float64, Matrix{Float64}}; kwargs::@Kwargs{})
    @ MatrixAlgebraKit ~/.julia/packages/MatrixAlgebraKit/0wHx6/src/algorithms.jl:178
 [12] top-level scope
    @ REPL[2]:1
 [13] top-level scope
    @ none:1

(test) pkg> st MatrixAlgebraKit
Status `~/.julia/dev/MatrixAlgebraKit/test/Project.toml`
  [6c742aac] MatrixAlgebraKit v0.2.2

I think this would be nice to support for convenience. For example, a convenient way to make a Hermitian matrix is LinearAlgebra.hermitianpart, but that outputs the matrix wrapped in Hermitian (obviously you can then unwrap it but honestly there isn't a great generic interface for that, for example one that support GPU arrays). (EDIT: I was being dense, one way to do it would be eigh_full(parent(hermitianpart(A))), but still that is a bit annoying.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions