diff --git a/CHANGELOG.md b/CHANGELOG.md index 18c7f5a8b..ec4e15c24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ # News +## v0.9.6 - 2024-07-12 + +- `inv` implementation for single-qubit "symbolic" Clifford operators (subtypes of `AbstractSingleQubitOperator`). + ## v0.9.5 - 2024-07-04 - Implementation of random all-to-all and brickwork Clifford circuits and corresponding ECC codes. diff --git a/Project.toml b/Project.toml index 92a6bbb5d..2f3303f4b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuantumClifford" uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1" authors = ["Stefan Krastanov and QuantumSavory community members"] -version = "0.9.5" +version = "0.9.6" [deps] Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" diff --git a/src/symbolic_cliffords.jl b/src/symbolic_cliffords.jl index b143589b3..0d2c26c40 100644 --- a/src/symbolic_cliffords.jl +++ b/src/symbolic_cliffords.jl @@ -227,6 +227,19 @@ function random_clifford1(rng::AbstractRNG, qubit) end random_clifford1(qubit) = random_clifford1(GLOBAL_RNG, qubit) +function LinearAlgebra.inv(op::SingleQubitOperator) + c = LinearAlgebra.inv(CliffordOperator(SingleQubitOperator(op), 1, compact=true)) + return SingleQubitOperator(c, op.q) +end + +LinearAlgebra.inv(h::sHadamard) = sHadamard(h.q) +LinearAlgebra.inv(p::sPhase) = sInvPhase(p.q) +LinearAlgebra.inv(p::sInvPhase) = sPhase(p.q) +LinearAlgebra.inv(p::sId1) = sId1(p.q) +LinearAlgebra.inv(p::sX) = sX(p.q) +LinearAlgebra.inv(p::sY) = sY(p.q) +LinearAlgebra.inv(p::sZ) = sZ(p.q) + ############################## # Two-qubit gates ############################## diff --git a/test/test_symcliff.jl b/test/test_symcliff.jl index 9cfddb976..2af1fd538 100644 --- a/test/test_symcliff.jl +++ b/test/test_symcliff.jl @@ -1,6 +1,5 @@ using Random using QuantumClifford - using QuantumClifford: stab_looks_good, destab_looks_good, mixed_stab_looks_good, mixed_destab_looks_good using QuantumClifford: apply_single_x!, apply_single_y!, apply_single_z! using InteractiveUtils @@ -66,3 +65,16 @@ end @test op1 == op2 end end + +@testset "SingleQubitOperator inv methods" begin + for gate_type in [sHadamard, sX, sY, sZ, sId1 , sPhase, sInvPhase] + n = rand(1:10) + @test CliffordOperator(inv(SingleQubitOperator(gate_type(n))), n) == inv(CliffordOperator(gate_type(n), n)) + @test CliffordOperator(inv(gate_type(n)), n) == inv(CliffordOperator(gate_type(n), n)) + end + for i in 1:10 + random_op = random_clifford1(i) + @test CliffordOperator(inv(random_op), i) == inv(CliffordOperator(random_op, i)) + @test CliffordOperator(inv(SingleQubitOperator(random_op)), i) == inv(CliffordOperator(random_op, i)) + end +end