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

Introduce rand_ket and generate rand_dm using Ginibre ensemble method #185

Merged
merged 4 commits into from
Jul 8, 2024

Conversation

ytdHuang
Copy link
Member

@ytdHuang ytdHuang commented Jul 7, 2024

This PR introduces rand_ket, and also modify the method for generating random density matrix rand_dm.

I think the current method for generating random density matrix is not random enough. Because the real value of off-diagonal elements are always positive.

Here, I implement the method to generate random density matrix from Ginibre ensemble, which is also the default method in qutip. I think this method is the more standard one in the literature.

Furthermore, with this method, we can specify the rank of the density matrix, i.e., the number of eigenvalues which are positive. The other eigenvalues will be very close to zero (< 1e-15).

Copy link

codecov bot commented Jul 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.36%. Comparing base (3a68599) to head (c22f230).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #185      +/-   ##
==========================================
+ Coverage   93.33%   93.36%   +0.03%     
==========================================
  Files          28       28              
  Lines        2101     2111      +10     
==========================================
+ Hits         1961     1971      +10     
  Misses        140      140              

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

Copy link
Member

@albertomercurio albertomercurio left a comment

Choose a reason for hiding this comment

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

Is this method equal to the current one in the case rank =N?

src/utilities.jl Outdated Show resolved Hide resolved
@ytdHuang
Copy link
Member Author

ytdHuang commented Jul 8, 2024

Is this method equal to the current one in the case rank =N?

Not equal, as I mentioned in above. I think the current method is not random enough.

@albertomercurio
Copy link
Member

albertomercurio commented Jul 8, 2024

In the case rank = n the Ginibre generates a square complex random matrix and then multiplies it by its adjoint. Like the previous implementation, except for the randn instead of the rand function. It is just to understand. The implementation is good, aside from the two comments made above.

@albertomercurio albertomercurio merged commit 9264e58 into qutip:main Jul 8, 2024
14 checks passed
@ytdHuang ytdHuang deleted the dev/rand-Qobj branch July 9, 2024 02:41
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.

2 participants