Skip to content

Commit

Permalink
Added asymmetric depolarizing channel gate
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonhan3 committed Jul 31, 2024
1 parent 6aed465 commit 0f26045
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/BPGates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export BellState,
BellMeasure, bellmeasure!,
BellGate, CNOTPerm, GoodSingleQubitPerm,
PauliNoiseOp, PauliZOp, PauliNoiseBellGate, NoisyBellMeasure, NoisyBellMeasureNoisyReset, AbstractNoiseBellOp,
MixedStateOp
MixedStateOp, AsymmDepOp

function int_to_bit(int,digits)
int = int - 1 # -1 so that we use julia indexing conventions
Expand Down Expand Up @@ -608,6 +608,29 @@ function QuantumClifford.apply!(state::BellState, g::MixedStateOp)
return state
end

struct AsymmDepOp <: AbstractNoiseBellOp
idx::Int
px::Float64
py::Float64
pz::Float64
end

function QuantumClifford.apply!(state::BellState, g::AsymmDepOp)
i = g.idx

Check warning on line 619 in src/BPGates.jl

View check run for this annotation

Codecov / codecov/patch

src/BPGates.jl#L618-L619

Added lines #L618 - L619 were not covered by tests
# TODO repetition with ...NoisyReset and PauliNoise...
# ^ ?
r = rand()

Check warning on line 622 in src/BPGates.jl

View check run for this annotation

Codecov / codecov/patch

src/BPGates.jl#L622

Added line #L622 was not covered by tests
# 2: Z, 3: X, 4: Y
if r<g.px
apply!(state, BellPauliPermutation(3, i))
elseif r<g.px+g.pz
apply!(state, BellPauliPermutation(2, i))
elseif r<g.px+g.pz+g.py
apply!(state, BellPauliPermutation(4, i))

Check warning on line 629 in src/BPGates.jl

View check run for this annotation

Codecov / codecov/patch

src/BPGates.jl#L624-L629

Added lines #L624 - L629 were not covered by tests
end
return state

Check warning on line 631 in src/BPGates.jl

View check run for this annotation

Codecov / codecov/patch

src/BPGates.jl#L631

Added line #L631 was not covered by tests
end

"""A wrapper for [`BellMeasure`](@ref) that implements measurement noise."""
struct NoisyBellMeasure <: BellOp # TODO make it work with the QuantumClifford noise ops
m::BellMeasure
Expand Down

0 comments on commit 0f26045

Please sign in to comment.