-
Notifications
You must be signed in to change notification settings - Fork 1
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
Extend KrylovKit.eigsolve
by allowing the initial guess x₀
to be a Tensor
#171
Conversation
KrylovKit.eigsolve
by allowing the initial guess x₀ to be a Tensor
KrylovKit.eigsolve
by allowing the initial guess x₀
to be a Tensor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you gain something by making x0
a Tensor
?
function KrylovKit.eigsolve( | ||
f::Tensor, x₀, howmany::Int=1, which::KrylovKit.Selector=:LM; left_inds=Symbol[], right_inds=Symbol[], kwargs... | ||
) | ||
Amat, left_sizes, right_sizes = eigsolve_prehook_tensor_reshape(A, left_inds, right_inds) | ||
|
||
# Compute eigenvalues and eigenvectors | ||
vals, vecs, info = KrylovKit.eigsolve(Amat, x₀, howmany, which; kwargs...) | ||
|
||
# Tensorify the eigenvectors | ||
Avecs = [Tensor(reshape(vec, left_sizes...), left_inds) for vec in vecs] | ||
|
||
return vals, Avecs, info | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you removed this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment from above.
In some iterative algorithms (e.g., DMRG), we may have an initial tensor |
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Yes, but as far as I've seen, the result of calling |
No, the result of |
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
Ok 👍 You just need to deduplicate the code and the PR should be ready. |
Done! |
Summary
This PR extends the
eigsolve
function introduced in PR #157 by allowing the initial guess eigenvectorx₀
to be aTensor
. Previously, this variable had to be anAbstractVector
. We also updated the tests to cover this extension.Example