Skip to content

Commit

Permalink
use random_clifford in the multi-qubit projection test and normalize …
Browse files Browse the repository at this point in the history
…projected states
  • Loading branch information
Fe-r-oz committed Nov 8, 2024
1 parent 6966d11 commit 1afdf8a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/test_nonclifford_quantumoptics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ end
s = random_stabilizer(n)
p = random_pauli(n)
gs = GeneralizedStabilizer(s)
apply!(gs, p)
apply!(gs, random_clifford(n))
qo_state = Operator(gs)
projectrand!(gs, p)[1]
qo_state_after_proj = Operator(gs)
Expand All @@ -102,7 +102,11 @@ end
qo_proj2 = (identityoperator(qo_pauli) + qo_pauli)/2
result1 = qo_proj1*qo_state*qo_proj1'
result2 = qo_proj2*qo_state*qo_proj2'
@test qo_state_after_proj result2 || qo_state_after_proj result1 || qo_state_after_proj 2*result2 || qo_state_after_proj 2*result1
# Normalize to ensure consistent comparison of the projected state, independent of scaling factors
norm_qo_state_after_proj = qo_state_after_proj/tr(qo_state_after_proj)
norm_result1 = result1/tr(result1)
norm_result2 = result2/tr(result2)
@test norm_qo_state_after_proj norm_result2 || norm_qo_state_after_proj norm_result1
end
end
end

0 comments on commit 1afdf8a

Please sign in to comment.