Skip to content

Eigenvalues not sorted for almost perfectly symmetric matrix #343

Closed
@jeff-regier

Description

I'm not sure whether this qualifies as a bug, though the behavior seems undesirable. Below A is a matrix that is almost exactly symmetric. eigvals(A) returns the singular values without sorting them. For perfectly symmetric matrices (e.g., B below), the eigenvalues are always sorted. It seems like eigvals(A) should sort them too, since due to numerical issues, even symmetric matrices are often not exactly symmetric.

julia> A = [2.319564160285209 20.613046913136856 -0.5068584177942504
            20.613046913136856 201.80977596527438 -1.2031203195074227
            -0.5068584177942503 -1.203120319507423 11.188307566885028];

julia> eigvals(A)  # these singular values are not sorted
3-element Array{Float64,1}:
 203.926   
   0.198637
  11.1935  

julia> norm(A - A')  # though A is almost perfectly symmetric
2.482534153247273e-16

julia> B = (A + A') / 2.  # but if A is symmetrized
3x3 Array{Float64,2}:
  2.31956    20.613    -0.506858
 20.613     201.81     -1.20312 
 -0.506858   -1.20312  11.1883  

julia> eigvals(B)  # then they are sorted
3-element Array{Float64,1}:
   0.198637
  11.1935  
 203.926   

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

    breakingThis change will break codedesignDesign of APIs or of the language itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions