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

Implement Eigendecomposition #215

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Implement Eigendecomposition #215

wants to merge 6 commits into from

Conversation

mofeing
Copy link
Member

@mofeing mofeing commented Oct 8, 2024

This PR implements LinearAlgebra.eigen (and related methods, eigvals and eigvecs) for Tensor, and LinearAlgebra.eigen! for AbstractTensorNetwork.

The design of this implementation is somewhat more similar to how Julia implements factorizations: there is this new TensorEigen object which eigen(::Tensor) returns. We could have used LinearAlgebra.Eigen (which is the return type of eigen), but it doesn't store the right indices required to construct $U^{-1}$.

The following destructuring syntax is supported:

A = Tensor(normalize!(rand(2,2)), [:i, :j])

Λ, U = eigen(A)
(; U⁻¹) = eigen(A)
(; Uinv) = eigen(A)
(; U, Λ, U⁻¹) = eigen(A)

@mofeing mofeing added the enhancement New feature or request label Oct 8, 2024
Copy link
Member

@jofrevalles jofrevalles left a comment

Choose a reason for hiding this comment

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

Okay thanks! Can you add tests for this? See our test for KrylovKit.eigsolve, which may be very similar.

Also, we should make that both KrylovKit.eigsolve and this function you added should have similar syntax, so if we agree on this TensorEigen thing, we should add it to our KrylovKit extension.

@mofeing
Copy link
Member Author

mofeing commented Oct 8, 2024

Okay thanks! Can you add tests for this? See our test for KrylovKit.eigsolve, which may be very similar.

Sure

Also, we should make that both KrylovKit.eigsolve and this function you added should have similar syntax, so if we agree on this TensorEigen thing, we should add it to our KrylovKit extension.

mmm although it might be a good idea, I see that Krylovkit.eigsolve doesn't return a Factorization object like LinearAlgebra.eigen so I would prefer to leave that for another PR.

src/Numerics.jl Outdated Show resolved Hide resolved
Copy link
Member Author

@mofeing mofeing left a comment

Choose a reason for hiding this comment

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

Nice! Can you add a docstring? :)

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants