Skip to content

Commit

Permalink
inv implementation for SingleQubitOperator (#314)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Stefan Krastanov <github.acc@krastanov.org>
  • Loading branch information
Fe-r-oz and Krastanov committed Jul 17, 2024
1 parent 59e399d commit 10bb4b6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumClifford"
uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
authors = ["Stefan Krastanov <stefan@krastanov.org> and QuantumSavory community members"]
version = "0.9.5"
version = "0.9.6"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
13 changes: 13 additions & 0 deletions src/symbolic_cliffords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
##############################
Expand Down
14 changes: 13 additions & 1 deletion test/test_symcliff.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

2 comments on commit 10bb4b6

@Krastanov
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/111243

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.6 -m "<description of version>" 10bb4b6cef05341caad61162b518735ae82fe3fd
git push origin v0.9.6

Please sign in to comment.