XanaduAI / thewalrus

A library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling.
https://the-walrus.readthedocs.io
Apache License 2.0
99 stars 54 forks source link

Entanglement #322

Closed fab1an-q closed 2 years ago

fab1an-q commented 2 years ago

Context: We want to equip TW with entanglement measures for Gaussian states.

Description of the Change: There are two new entanglement measures implemented: entanglement entropy (only for pure states) and logarithmic negativity (for pure and mixed states). With a given covariance matrix cov, these can be obtained by

from thewalrus.quantum import entanglement_entropy, log_negativity

ent_entrop = entanglement_entropy(cov, modes_A=[1, 12, 123])
log_negat = log_negativity(cov, modes_A=[1, 12, 123])

where modes_A is the subset of modes that defines the bipartition. Alternatively, the kwarg modes_A can be replaced by split, an integer which defines at which mode index the state is divided into two substates.

Benefits: Quantify entanglement of pure and mixed states along arbitrary bipartitions.

Possible Drawbacks: None

Related GitHub Issues: None

codecov[bot] commented 2 years ago

Codecov Report

Merging #322 (cb30e94) into master (7f56333) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #322   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           23        24    +1     
  Lines         1644      1697   +53     
=========================================
+ Hits          1644      1697   +53     
Impacted Files Coverage Δ
thewalrus/decompositions.py 100.00% <100.00%> (ø)
thewalrus/quantum/__init__.py 100.00% <100.00%> (ø)
thewalrus/quantum/entanglement.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 7f56333...cb30e94. Read the comment docs.

nquesada commented 2 years ago

This is a great addition @fab1an-q ! Three minor comments:

  1. Make sure to pass black -l 100 to all the files in the PR
  2. There is a line that is missing coverage:

image

  1. It seems like you are not using pytest here:

image

nquesada commented 2 years ago

Also @fab1an-q don't forget to update the ACKNOWLEDGEMENTS and CHANGELOG. It is awesome to have you as a contributor to the mightiest marine mammal!

fab1an-q commented 2 years ago

Should we wait for more approvals, or is this ready to be merged?

nquesada commented 2 years ago

Assuming the changes in files like docs/_ext/edit_on_github.py are intentional, then this is ready to go. @thisac