Skip to content

broken eig functions for Diagonal{Matrix} #594

Closed
JuliaLang/julia
#50897
@stevengj

Description

Bug noted in JuliaLang/julia#21598, filing a separate issue so that it doesn't get lost.

julia> using LinearAlgebra

julia> I2 = Matrix(I, 2,2); D = Diagonal([2.0*I2, 3.0*I2])
2×2 Diagonal{Array{Float64,2},Array{Array{Float64,2},1}}:
 [2.0 0.0; 0.0 2.0]                   
                    [3.0 0.0; 0.0 3.0]

julia> eigvals(Diagonal([2.0*I2, 3.0*I2]))  # SHOULD RETURN ARRAY OF SCALARS!
2-element Array{Array{Float64,1},1}:
 [2.0, 2.0]
 [3.0, 3.0]

julia> eigvecs(D)
ERROR: MethodError: no method matching zero(::Type{Array{Float64,2}})
Closest candidates are:
  zero(::Type{LibGit2.GitHash}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/LibGit2/src/oid.jl:220
  zero(::Type{Pkg.Resolve.VersionWeights.VersionWeight}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/resolve/VersionWeights.jl:19
  zero(::Type{Pkg.Resolve.MaxSum.FieldValues.FieldValue}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/resolve/FieldValues.jl:44
  ...
Stacktrace:
 [1] zeros(::Type{Array{Float64,2}}, ::Tuple{Int64,Int64}) at ./array.jl:467
 [2] Array{Array{Float64,2},2}(::UniformScaling{Bool}, ::Tuple{Int64,Int64}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/uniformscaling.jl:317
 [3] eigvecs(::Diagonal{Array{Float64,2},Array{Array{Float64,2},1}}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/diagonal.jl:486
 [4] top-level scope at none:0

julia> eigen(D)
ERROR: MethodError: no method matching isfinite(::Array{Float64,2})
Closest candidates are:
  isfinite(::BigFloat) at mpfr.jl:858
  isfinite(::Missing) at missing.jl:79
  isfinite(::Float16) at float.jl:545
  ...
Stacktrace:
 [1] (::getfield(Base, Symbol("##54#55")){typeof(isfinite)})(::Array{Float64,2}) at ./operators.jl:853
 [2] _any at ./reduce.jl:614 [inlined]
 [3] #any#548 at ./reducedim.jl:655 [inlined]
 [4] any at ./reducedim.jl:655 [inlined]
 [5] #eigen#114(::Bool, ::Bool, ::Function, ::Diagonal{Array{Float64,2},Array{Array{Float64,2},1}}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/diagonal.jl:488
 [6] eigen(::Diagonal{Array{Float64,2},Array{Array{Float64,2},1}}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/LinearAlgebra/src/diagonal.jl:488
 [7] top-level scope at none:0

Should be quite easy to fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcorrectness bug ⚠Bugs that are likely to lead to incorrect results in user code without throwinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions