-
Notifications
You must be signed in to change notification settings - Fork 76
Add DepolarizedBellPair #359
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
78ff6e7
Add depolirzed state
hanakl 6fdecff
add test
hanakl cc3e35d
Replace noisy_pair_func
hanakl 46bd93d
Use shorthand keyword argument in noisy_pair_func
hanakl 320a697
Changes to DepolarizedBellPair
hanakl 3ab7dd1
Use DepolarizedBellPair in examples and tests
hanakl 0e0ddca
Merge remote-tracking branch 'origin/master' into hana_depolarized_state
hanakl d74e47a
Change test names
hanakl 9ba0bc4
Add description to CHANGELOG.md
hanakl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| """ | ||
| $TYPEDEF | ||
|
|
||
| Fields: | ||
|
|
||
| $FIELDS | ||
|
|
||
| A symbolic representation of a depolarized pure state: | ||
| `p |ψ⟩⟨ψ| + (1-p) I/d` | ||
|
|
||
| where `|ψ⟩` is an arbitrary pure two-qubit state (default: |Φ⁺⟩ = (|00⟩+|11⟩)/√2), | ||
| and `I/d` is the maximally mixed state in the same Hilbert space. | ||
|
|
||
| The fidelity `F = ⟨ψ|ρ|ψ⟩` with respect to `|ψ⟩` relates to the depolarization parameter by: | ||
| - `F = (3p + 1) / 4` | ||
| - `p = (4F - 1) / 3` | ||
|
|
||
| Can be constructed from either parameter: | ||
| - `DepolarizedBellPair(p)` — depolarization parameter `p ∈ [0, 1]`, defaults to |Φ⁺⟩ | ||
| - `DepolarizedBellPair(p, pure_state)` — with a custom pure state | ||
| - `DepolarizedBellPair(F=F)` — from fidelity `F ∈ [1/4, 1]`, defaults to |Φ⁺⟩ | ||
| - `DepolarizedBellPair(F=F, pure_state=s)` — from fidelity with a custom pure state | ||
| """ | ||
| @withmetadata struct DepolarizedBellPair <: AbstractTwoQubitState | ||
| """Depolarization parameter `p ∈ [0, 1]`, related to fidelity by `F = (3p+1)/4`""" | ||
| p | ||
| """The ideal pure state being depolarized (default: |Φ⁺⟩)""" | ||
| pure_state | ||
| end | ||
|
|
||
| const _depolarized_default_bell = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2) | ||
|
|
||
| DepolarizedBellPair(p) = DepolarizedBellPair(p, _depolarized_default_bell) | ||
| DepolarizedBellPair(; F, pure_state=_depolarized_default_bell) = DepolarizedBellPair((4 * F - 1) / 3, pure_state) | ||
|
|
||
| stateparameters(::Type{DepolarizedBellPair}) = (:p,) | ||
| stateparametersrange(::Type{DepolarizedBellPair}) = (p=(;min=0,max=1,good=1),) | ||
|
|
||
| symbollabel(x::DepolarizedBellPair) = "ρᵖ" | ||
|
|
||
| function express_nolookup(x::DepolarizedBellPair, r::QuantumOpticsRepr) | ||
| (; p, pure_state) = x | ||
| pure_dm = SProjector(pure_state) | ||
| mixed_dm = MixedState(pure_dm) | ||
| return express(p*pure_dm + (1-p)*mixed_dm, r) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| @testitem "StatesZoo DepolarizedBellPair" begin | ||
| using Test | ||
| using QuantumSavory | ||
| using QuantumSavory.StatesZoo | ||
| using QuantumOpticsBase | ||
| using LinearAlgebra | ||
|
|
||
| # p-constructor and fidelity-constructor consistency | ||
| p = 0.7 | ||
| F = (3p + 1) / 4 | ||
| s_from_p = DepolarizedBellPair(p) | ||
| s_from_F = DepolarizedBellPair(F=F) | ||
| @test express(s_from_p) ≈ express(s_from_F) | ||
|
|
||
| # trace is 1 for any p | ||
| for p in [0.0, 0.5, 1.0] | ||
| dm = express(DepolarizedBellPair(p)) | ||
| @test tr(dm) ≈ 1 | ||
| end | ||
|
|
||
| # at p=1, pure Bell state: ⟨ZZ⟩ = 1 | ||
| reg = Register(2) | ||
| initialize!(reg[1:2], DepolarizedBellPair(1.0)) | ||
| @test observable(reg[1:2], Z⊗Z) ≈ 1 | ||
|
|
||
| # at p=0, maximally mixed: density matrix = I/4 | ||
| dm_mixed = express(DepolarizedBellPair(0.0)) | ||
| @test dm_mixed.data ≈ LinearAlgebra.I / 4 | ||
|
|
||
| # fidelity-to-p and p-to-fidelity roundtrip | ||
| for F in [0.25, 0.5, 0.75, 1.0] | ||
| p_rt = (4F - 1) / 3 | ||
| @test (3p_rt + 1) / 4 ≈ F | ||
| dm = express(DepolarizedBellPair(F=F)) | ||
| @test tr(dm) ≈ 1 | ||
| end | ||
|
|
||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.