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

noncliff: scaffolding for projectrand! for GeneralizedStabilizer #420

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 56 additions & 8 deletions src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end

Expectation value for the [PauliOperator](@ref) observable given the [`GeneralizedStabilizer`](@ref) state `s`.

```jldoctest
```jldoctest genstab
julia> sm = GeneralizedStabilizer(S"-X")
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
Expand Down Expand Up @@ -172,15 +172,63 @@ function _allthreesumtozero(a,b,c)
true
end

function project!(sm::GeneralizedStabilizer, p::PauliOperator)
eval = expect(p, sm)
prob₁ = (real(eval)+1)/2
error("This functionality is not implemented yet")
end
"""$(TYPEDSIGNATURES)

Performs a randomized projection of the state represented by the [`GeneralizedStabilizer`](@ref) `sm`,
based on the measurement of a [PauliOperator](@ref) `p`.

Unlike in the case of stabilizer states, the expectation value χ′ of a Pauli operator
with respect to these more general states can be any real number between -1 and 1.
The expectation value can be calculated with `expect(p, sm)`.

```math
\\chi' = \\langle p \\rangle = \\text{expect}(p, sm)
```

To convert χ′ into a probability of projecting on the +1 eigenvalue branch:

function _proj₋(sm::GeneralizedStabilizer, p::PauliOperator)
```math
\\text{probability}_{1} = \\frac{\\text{real}(\\chi') + 1}{2}
```

!!! note Because the possible measurement results are themselves not stabilizer states anymore,
we can not use the `project!` API, which assumes a stabilizer tableau and reports detailed
information about whether the tableau and measurement commute or anticommute.

```jldoctest genstab
julia> sm = GeneralizedStabilizer(S"-X");

julia> apply!(sm, pcT)
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z
𝒮𝓉𝒶𝒷
- X
with ϕᵢⱼ | Pᵢ | Pⱼ:
0.0+0.353553im | + _ | + Z
0.0-0.353553im | + Z | + _
0.853553+0.0im | + _ | + _
0.146447+0.0im | + Z | + Z

julia> expect(P"-X", sm)
0.7071067811865475 + 0.0im

julia> prob₁ = (real(χ′)+1)/2
0.8535533905932737
```

See also: [`expect`](@ref)
"""
function projectrand!(sm::GeneralizedStabilizer, p::PauliOperator)
χ′ = expect(p, sm)
# Compute the probability of measuring in the +1 eigenstate
prob₁ = (real(χ′)+1)/2
# Randomly choose projection based on this probability
return _proj(sm, rand() < prob₁ ? p : -p)
end
function _proj₊(sm::GeneralizedStabilizer, p::PauliOperator)

function _proj(sm::GeneralizedStabilizer, p::PauliOperator)
error("This functionality is not implemented yet")
end

nqubits(sm::GeneralizedStabilizer) = nqubits(sm.stab)
Expand Down
Loading