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

New eigen solve interface #71

Merged
merged 4 commits into from
Apr 17, 2024
Merged

New eigen solve interface #71

merged 4 commits into from
Apr 17, 2024

Conversation

ytdHuang
Copy link
Member

@ytdHuang ytdHuang commented Apr 10, 2024

close #39

Summary of this PR:

  • Update definition and docstrings of struct EigsolveResult
  • Update definition of iterate for EigsolveResult
  • New method show for EigsolveResult
  • New function eigenenergies(A::QuantumObject; sparse::Bool=false, kwargs...)
  • New function eigenstates(A::QuantumObject; sparse::Bool=false, kwargs...)

Also, the fields in EigsolveResult like vals and vecs have been renamed to values and vectors, repectively. Make the variable name same as LinearAlgebra.Eigen.

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.87%. Comparing base (aec779f) to head (487982c).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
+ Coverage   90.17%   91.87%   +1.70%     
==========================================
  Files          18       18              
  Lines        1699     1711      +12     
==========================================
+ Hits         1532     1572      +40     
+ Misses        167      139      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/eigsolve.jl Outdated Show resolved Hide resolved
return ([QuantumObject(res.vectors[:, k], OperatorKet, res.dims) for k in 1:length(res.values)], Val(:vectors))
end
end
Base.iterate(res::EigsolveResult, ::Val{:vectors}) = (res.vectors, Val(:done))
Copy link
Member

Choose a reason for hiding this comment

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

Should we return already a QuantumObject? In this way

E, V, U = eigenstates(H)

U is already a QuantumObject.

Copy link
Member Author

@ytdHuang ytdHuang Apr 16, 2024

Choose a reason for hiding this comment

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

I was thinking of returning U as a Qobj in the beginning
but I noticed that for sparse solvers: U is usually a non-squared matrix.
if we do it in this way, it will make the return object type unstable (depends on sparse=true or false).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can leave it like this

@ytdHuang
Copy link
Member Author

ytdHuang commented Apr 16, 2024

All tests in macOS failed at the stage of uploading the code coverage. Maybe we can just bypass it.
It's somehow fixed after I re-run it.

return ([QuantumObject(res.vectors[:, k], OperatorKet, res.dims) for k in 1:length(res.values)], Val(:vectors))
end
end
Base.iterate(res::EigsolveResult, ::Val{:vectors}) = (res.vectors, Val(:done))
Copy link
Member

Choose a reason for hiding this comment

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

Yes, we can leave it like this

@albertomercurio albertomercurio merged commit e59c415 into qutip:main Apr 17, 2024
13 checks passed
@ytdHuang ytdHuang deleted the dev/eigen branch April 18, 2024 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New eigen solve interface
2 participants