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

Create a copy while evaluating eigvals(::Diagonal) #45048

Merged
merged 2 commits into from
May 2, 2022

Commits on Apr 21, 2022

  1. Create a copy while evaluating eigvals(::Diagonal)

    Currently, `eigvals(D::Diagonal{<:Number})` returns `D.diag`, which means that subsequent changes to `D` will change previously computed eigenvalues.
    
    ```
    julia> D = Diagonal([1,2,3])
    3×3 Diagonal{Int64, Vector{Int64}}:
     1  ⋅  ⋅
     ⋅  2  ⋅
     ⋅  ⋅  3
    
    julia> λ = eigvals(D)
    3-element Vector{Int64}:
     1
     2
     3
    
    julia> D[3,3] = 4
    4
    
    julia> λ
    3-element Vector{Int64}:
     1
     2
     4
    ```
    
    Creating a copy should fix this
    jishnub authored Apr 21, 2022
    Configuration menu
    Copy the full SHA
    6206a51 View commit details
    Browse the repository at this point in the history
  2. Add test

    jishnub committed Apr 21, 2022
    Configuration menu
    Copy the full SHA
    ca316fb View commit details
    Browse the repository at this point in the history