Julia: `eigmax` type constrained differently than `eigmin`

Created on 26 Apr 2019  Â·  4Comments  Â·  Source: JuliaLang/julia

Implementing eigvals for an AbstractMatrix gets you eigmin but not eigmax.

I think the definition for eigmax should change StridedMatrix -> AbstractMatrix (to match the definition of eigmin)?

Example:

julia> using LinearAlgebra

julia> struct MyMat{T} <: AbstractMatrix{T}
           data::AbstractMatrix{T}
       end

julia> Base.getindex(m::MyMat, i, j) = getindex(m.data, i, j)

julia> Base.size(m::MyMat) = size(m.data)

julia> LinearAlgebra.eigvals(m::MyMat; kwargs...) = eigvals(m.data; kwargs...)

julia> M = MyMat(rand(3,3))
3×3 MyMat{Float64}:
 0.316192  0.915257  0.559555
 0.153994  0.978667  0.406342
 0.114911  0.249647  0.87979

julia> eigvals(M)
3-element Array{Float64,1}:
 1.4367338354952857
 0.13582144904446486
 0.6020940832444935

julia> eigmin(M)
0.13582144904446486

julia> eigmax(M)
ERROR: MethodError: no method matching eigmax(::MyMat{Float64})
Closest candidates are:
  eigmax(::SymTridiagonal) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/LinearAlgebra/src/tridiag.jl:227
linear algebra

Most helpful comment

Looks like this is fixed and can be closed? The above code does no longer error.

All 4 comments

I agree. It would be great if you could prepare a PR.

(related https://github.com/JuliaLang/julia/issues/31389)

actually should be fixed by https://github.com/JuliaLang/julia/pull/31117 :D

Looks like this is fixed and can be closed? The above code does no longer error.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixrehren picture felixrehren  Â·  3Comments

StefanKarpinski picture StefanKarpinski  Â·  3Comments

tkoolen picture tkoolen  Â·  3Comments

iamed2 picture iamed2  Â·  3Comments

wilburtownsend picture wilburtownsend  Â·  3Comments