XanaduAI / strawberryfields

Strawberry Fields is a full-stack Python library for designing, simulating, and optimizing continuous variable (CV) quantum optical circuits.
https://strawberryfields.ai
Apache License 2.0
737 stars 188 forks source link

change the purity calculation for gaussian state #747

Open sylviemonet opened 1 month ago

sylviemonet commented 1 month ago

Context: The purity calculation for gaussian state depends on the precision in SF, however, in some cases, this value can be small but the tolerance is not enough small to detect it, hence, the state which should be mixed become a "pure" tag in the gaussian backend calculation.

Description of the Change: This PR fix the calculation from a - b <tol into a/b == 1.0 as the condition.

Benefits:

Possible Drawbacks: I believe that when we set of the calculation in the way a - b <tol, there must be some considerations behind. So it may be not a good solution for all library.

Related GitHub Issues: Issue 745