Skip to content

Commit

Permalink
normalize the projected states to have consistent comparison and use …
Browse files Browse the repository at this point in the history
…random_clifford
  • Loading branch information
Fe-r-oz committed Nov 8, 2024
1 parent d0c4f83 commit 602d18d
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)
md = MixedDestabilizer(s)
apply!(md, p) # or apply!(s, p)
apply!(md, random_clifford(n)) # or apply!(s, random_clifford(n))
qo_state = Operator(md) # or Operator(s)
projectrand!(md, p)[1] # or projectrand!(s, p)[1]
qo_state_after_proj = Operator(md) # or Operator(s)
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 602d18d

Please sign in to comment.