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

fix eigvals,eigvecs,eigen for Diagonal{Matrix} #50897

Merged
merged 4 commits into from
Oct 14, 2023

Conversation

fatteneder
Copy link
Member

@fatteneder fatteneder commented Aug 12, 2023

Fixes JuliaLang/LinearAlgebra.jl#594.

There has been another attempt on fixing this #31509, but that seemed to have stopped two years ago.

@stevengj @dkarrasch Since you were involved in the issue and the other PR, may I ask you to also review this?


I hope I understood correctly how the fix in JuliaLang/LinearAlgebra.jl#594 was meant to work:
I implemented it such that the results of eigvals(D), eigvecs(D), eigen(D) behave as in the case with ordinary matrices, e.g.
if D is a block diagonal matrix then

julia> vals, vecs = eigen(D)
julia> D * vecs == vecs * Diagonal(vals) # true

Closes #31509.

@brenhinkeller brenhinkeller added linear algebra Linear algebra bugfix This change fixes an existing bug labels Aug 12, 2023
@DilumAluthge DilumAluthge requested a review from stevengj August 24, 2023 02:19
@DilumAluthge
Copy link
Member

Bump @dkarrasch @stevengj

@dkarrasch
Copy link
Member

Sorry for the delay; I'll review this next. For the tests that involve multiplication, we should indeed have approximate tests. For tests of functionality where you know you've only shuffled exact data around, exact tests are fine.

Copy link
Member

@dkarrasch dkarrasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments, otherwise LGTM. The crucial thing was to be able to multiply the diagonal matrix of matrices with the eigenvector matrix. That works nicely, as the tests show.

stdlib/LinearAlgebra/test/diagonal.jl Outdated Show resolved Hide resolved
stdlib/LinearAlgebra/test/diagonal.jl Outdated Show resolved Hide resolved
stdlib/LinearAlgebra/src/diagonal.jl Outdated Show resolved Hide resolved
Copy link
Member Author

@fatteneder fatteneder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. Will try to update this soonish.

stdlib/LinearAlgebra/src/diagonal.jl Show resolved Hide resolved
@dkarrasch
Copy link
Member

Just in case: if you agree with the suggestions, you can switch to the "Files changed" tab, then "add suggestion to batch" for the agreed suggestions, and then push the commit. No need to get back to your own codebase.

Co-authored-by: Daniel Karrasch <daniel.karrasch@posteo.de>
@dkarrasch
Copy link
Member

Thanks @fatteneder for your contribution!

@dkarrasch dkarrasch merged commit 1911c00 into JuliaLang:master Oct 14, 2023
2 checks passed
@fatteneder fatteneder deleted the fa/diag-eig branch October 16, 2023 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

broken eig functions for Diagonal{Matrix}
4 participants