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

Rewrites the fidelity function for clarity #226

Merged
merged 7 commits into from
Feb 13, 2021
Merged

Rewrites the fidelity function for clarity #226

merged 7 commits into from
Feb 13, 2021

Conversation

nquesada
Copy link
Collaborator

The fidelity function in quantum/gaussian_checks.py is rewritten to add clarity and also a reference and test are added.
This should clarify the (non-) bug posited in #223

@nquesada nquesada requested review from thisac and removed request for antalszava February 12, 2021 20:00
@codecov
Copy link

codecov bot commented Feb 12, 2021

Codecov Report

Merging #226 (bf6d6c4) into master (49de978) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #226   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         1191      1188    -3     
=========================================
- Hits          1191      1188    -3     
Impacted Files Coverage Δ
thewalrus/quantum/gaussian_checks.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 49de978...bf6d6c4. Read the comment docs.

Copy link
Contributor

@thisac thisac left a comment

Choose a reason for hiding this comment

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

Nice addition @nquesada. Was easy and clear to follow. Just a few minor comments on variable names and code, that you might want to address.

sigma2 = cov2 / hbar
deltar = (mu1 - mu2) / np.sqrt(hbar)

Omega = sympmat(n0 // 2) # The symplectic matrix
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend using lowercase for these variables, since capitalization would be used for classes, and thus get highlighted differently. Any reason for changing to capitalized versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I knew this would come up! So I am just trying to follow the paper and LaTeX naming, i.e., Omega is meant to be $\Omega$. The Walrus has no classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But if you feel strongly about this I am happy to change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry about this. It's a case of programming vs. academic conventions. I would say it's still better to keep lowercase, and follow Python syntax rules here. Either having it as omega or even big_omega (but I think the former is probably better).

thewalrus/quantum/gaussian_checks.py Outdated Show resolved Hide resolved
thewalrus/quantum/gaussian_checks.py Outdated Show resolved Hide resolved
Comment on lines 150 to 151
f = np.sqrt(np.linalg.det(Sigma_inv) * np.linalg.det(det_arg)) * np.exp(
-0.5 * deltar @ Sigma_inv @ deltar
Copy link
Contributor

Choose a reason for hiding this comment

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

No transpose on the first deltar? It seems like the paper writes it np.exp(-0.5 * deltar.T @ Sigma_inv @ deltar), but maybe that's the same in this case. 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It makes no difference, although it could be added. If you do a @ b and a and b are 1D arrays the numpy is smart enough to know that what you want is mathematically speaking a^T \cdot b

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough. That's what I suspected, just wanted to clarify. Thanks!

Comment on lines +110 to +111
The actual implementation used here corresponds to the *square* of Eq. 96 of
`'Gaussian states and operations - a quick reference', Brask <https://arxiv.org/abs/2102.05748>`_.
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

nquesada and others added 3 commits February 12, 2021 15:54
Co-authored-by: Theodor <theodor@xanadu.ai>
Co-authored-by: Theodor <theodor@xanadu.ai>
@nquesada nquesada merged commit 706e38d into master Feb 13, 2021
@nquesada nquesada deleted the fidelity branch February 13, 2021 01:39
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