Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more convenient conversion methods #6

Open
Krastanov opened this issue Nov 21, 2023 · 0 comments
Open

more convenient conversion methods #6

Krastanov opened this issue Nov 21, 2023 · 0 comments

Comments

@Krastanov
Copy link
Member

It would be nice if QuantumClifford.CliffordOperator(bpgate) and QuantumOptics.Operator(bpgate) worked out of the box. Here is the current workaround

julia> using QuantumOpticsBase, QuantumClifford, BPGates

julia> cnotperm = CNOTPerm(3,4,1,2); # a gate you want converted

julia> accumulate = one(CliffordOperator,2); # an identity operator which we will multiply by the Cliffords that make up cnotperm
X₁ ⟼ + X_
X₂ ⟼ + _X
Z₁ ⟼ + Z_
Z₂ ⟼ + _Z

julia> for gate in BPGates.toQCcircuit(cnotperm) # we are building up the transpiled Clifford from the 
           accumulate = gate*accumulate
       end

julia> accumulate # this is the Clifford gate you want
X₁ ⟼ + Z_
X₂ ⟼ + _Z
Z₁ ⟼ + X_
Z₂ ⟼ + _X

julia> Operator(accumulate) # and here it is converted to a unitary gate representation
Operator(dim=4x4)
  basis: [Spin(1/2) ⊗ Spin(1/2)]
 0.5+0.0im   0.5+0.0im   0.5+0.0im   0.5+0.0im
 0.5+0.0im  -0.5+0.0im   0.5+0.0im  -0.5+0.0im
 0.5+0.0im   0.5+0.0im  -0.5+0.0im  -0.5+0.0im
 0.5+0.0im  -0.5+0.0im  -0.5+0.0im   0.5+0.0im
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant