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: add tests for conjugate destabs #413

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ with ϕᵢⱼ | Pᵢ | Pⱼ:

See also: [`GeneralizedStabilizer`](@ref)
"""
function apply!(state::GeneralizedStabilizer, gate::AbstractCliffordOperator) # TODO conjugate also the destabs
function apply!(state::GeneralizedStabilizer, gate::AbstractCliffordOperator)
apply!(state.stab, gate)
state
end
Expand Down
23 changes: 23 additions & 0 deletions test/test_nonclifford_quantumoptics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ qo_tgate.data[2,2] = exp(im*pi/4)
end
end

@testset "apply!" begin
for n in [1,2,3,4] # exponential cost in this term
s = random_stabilizer(n)
sm = GeneralizedStabilizer(s)
@test dm(Ket(s)) ≈ Operator(sm)
# test clifford gates
for _ in 1:10
c = random_clifford(n)
uc = Operator(c)
@test uc * Operator(sm) * uc' ≈ Operator(apply!(sm, c)) # sm is modified in place for the next round
end
# and now some (repeated) non-clifford ops
for _ in 1:5 # exponential cost in this term
i = rand(1:n)
nc = embed(n, i, pcT)
apply!(sm, nc) # in-place
c = random_clifford(n)
uc = Operator(c)
@test uc * Operator(sm) * uc' ≈ Operator(apply!(sm, c)) # sm is modified in place for the next round
end
end
end

@testset "copy and ==" begin
for n in 1:10
s = random_stabilizer(n)
Expand Down
Loading