Skip to content

Commit 10bb4b6

Browse files
Fe-r-ozKrastanov
andauthored
inv implementation for SingleQubitOperator (#314)
--------- Co-authored-by: Stefan Krastanov <[email protected]>
1 parent 59e399d commit 10bb4b6

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
# News
77

8+
## v0.9.6 - 2024-07-12
9+
10+
- `inv` implementation for single-qubit "symbolic" Clifford operators (subtypes of `AbstractSingleQubitOperator`).
11+
812
## v0.9.5 - 2024-07-04
913

1014
- Implementation of random all-to-all and brickwork Clifford circuits and corresponding ECC codes.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuantumClifford"
22
uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
33
authors = ["Stefan Krastanov <[email protected]> and QuantumSavory community members"]
4-
version = "0.9.5"
4+
version = "0.9.6"
55

66
[deps]
77
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"

src/symbolic_cliffords.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,19 @@ function random_clifford1(rng::AbstractRNG, qubit)
227227
end
228228
random_clifford1(qubit) = random_clifford1(GLOBAL_RNG, qubit)
229229

230+
function LinearAlgebra.inv(op::SingleQubitOperator)
231+
c = LinearAlgebra.inv(CliffordOperator(SingleQubitOperator(op), 1, compact=true))
232+
return SingleQubitOperator(c, op.q)
233+
end
234+
235+
LinearAlgebra.inv(h::sHadamard) = sHadamard(h.q)
236+
LinearAlgebra.inv(p::sPhase) = sInvPhase(p.q)
237+
LinearAlgebra.inv(p::sInvPhase) = sPhase(p.q)
238+
LinearAlgebra.inv(p::sId1) = sId1(p.q)
239+
LinearAlgebra.inv(p::sX) = sX(p.q)
240+
LinearAlgebra.inv(p::sY) = sY(p.q)
241+
LinearAlgebra.inv(p::sZ) = sZ(p.q)
242+
230243
##############################
231244
# Two-qubit gates
232245
##############################

test/test_symcliff.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Random
22
using QuantumClifford
3-
43
using QuantumClifford: stab_looks_good, destab_looks_good, mixed_stab_looks_good, mixed_destab_looks_good
54
using QuantumClifford: apply_single_x!, apply_single_y!, apply_single_z!
65
using InteractiveUtils
@@ -66,3 +65,16 @@ end
6665
@test op1 == op2
6766
end
6867
end
68+
69+
@testset "SingleQubitOperator inv methods" begin
70+
for gate_type in [sHadamard, sX, sY, sZ, sId1 , sPhase, sInvPhase]
71+
n = rand(1:10)
72+
@test CliffordOperator(inv(SingleQubitOperator(gate_type(n))), n) == inv(CliffordOperator(gate_type(n), n))
73+
@test CliffordOperator(inv(gate_type(n)), n) == inv(CliffordOperator(gate_type(n), n))
74+
end
75+
for i in 1:10
76+
random_op = random_clifford1(i)
77+
@test CliffordOperator(inv(random_op), i) == inv(CliffordOperator(random_op, i))
78+
@test CliffordOperator(inv(SingleQubitOperator(random_op)), i) == inv(CliffordOperator(random_op, i))
79+
end
80+
end

0 commit comments

Comments
 (0)