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

Separate normalized and unnormalized objects #50

Merged
merged 9 commits into from
Nov 3, 2023

Conversation

ba2tro
Copy link
Member

@ba2tro ba2tro commented Oct 18, 2023

Separated the symbolic objects into normalized and unnormalized, added a dispatch of tr from LinearAlgebra.jl for computing the trace of the unnormalized objects and fixed tests according to the new naming convention

## trace

tr(x::SingleRailMidSwapBellU) = Float64(tr(express(x).data))
Copy link
Member

Choose a reason for hiding this comment

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

lets remove these -- unless it is some special constant, it does not make sense to implicitly turn a symbolic object into a float


## trace
tr(x::ZALMSpinPairU) = Float64(tr(express(x).data))
Copy link
Member

Choose a reason for hiding this comment

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

same here


@test tr(zalmU) < 1.0
@test tr(express(zalmN).data) ≈ 1
Copy link
Member

Choose a reason for hiding this comment

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

on the other hand, these should be exactly equal to 1 thanks to a special dispatch rule (so that express does not need to be used, nor .data)

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't we still need to use express to convert it to QuantumOptics formalism so that this specialised method can be called

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer if we do not rely on quantumoptics.jl at all for that.

In symbolic CAS tools usually 1 and 0 are treated more specially than other numbers. For the normalized density matrices here it is guaranteed that the trace is 1, so I would like to have a special-cased method for them that completely shortcuts any expression functionality.

@test tr(rho) = tr(express(rho)) should work for them.

Please add these special-cased methods for tr and I should be able to merge.

Copy link
Member

Choose a reason for hiding this comment

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

@Abhishek-1Bhatt , bump

@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #50 (1b07957) into master (60d60e2) will increase coverage by 0.39%.
The diff coverage is 82.35%.

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
+ Coverage   63.29%   63.69%   +0.39%     
==========================================
  Files          27       27              
  Lines        1079     1099      +20     
==========================================
+ Hits          683      700      +17     
- Misses        396      399       +3     
Files Coverage Δ
src/StatesZoo/StatesZoo.jl 50.00% <ø> (ø)
src/StatesZoo/zalm_pair/zalm_pair.jl 27.11% <83.33%> (+4.89%) ⬆️
...ngle_dual_rail_midswap/single_dual_rail_midswap.jl 87.87% <81.81%> (-3.43%) ⬇️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Krastanov
Copy link
Member

I have been trying to think about names, specifically suffixes, that will lead to the least amount of confusion. My main worry is that U frequently stands for Unitary, and N frequently stands for number of qubits or for dimensionality.

Maybe changing U to W would make sense (for "weighted", given that it is weighted by the probability for success) and just removing the N (given that people usually expect if something is a density matrix for it to be normalized).

Do you have any thoughts on this? Happy to merge as is and then do a renaming PR or to discuss naming here before merging.

@Krastanov Krastanov merged commit f33b181 into QuantumSavory:master Nov 3, 2023
5 of 9 checks passed
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