Skip to content

Commit

Permalink
whitespace cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov committed Oct 20, 2024
1 parent f582b87 commit 43da8c7
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/BPGates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export BellState,
BellSinglePermutation, BellDoublePermutation, BellPauliPermutation,
BellMeasure, bellmeasure!,
BellGate, CNOTPerm, GoodSingleQubitPerm,
PauliNoiseOp, PauliNoiseBellGate, NoisyBellMeasure, NoisyBellMeasureNoisyReset,
PauliNoiseOp, PauliNoiseBellGate, NoisyBellMeasure, NoisyBellMeasureNoisyReset,
BellSwap, NoisyBellSwap

const IT = Union{Int8,Int16,Int32,Int64,UInt8,UInt16,UInt32,UInt64}
Expand Down Expand Up @@ -543,15 +543,15 @@ function QuantumClifford.apply!(state::BellState, g::PauliNoiseOp)
end

"""Simulates twirled T1 noise"""
struct T1NoiseOp <: BellOp
struct T1NoiseOp <: BellOp
idx::Int
λ₁::Float64
end

function QuantumClifford.apply!(state::BellState, g::T1NoiseOp)
phase = state.phases
input_state = bit_to_int(phase[g.idx*2-1],phase[g.idx*2]) # this is my initial state

r = rand()
λ₁ = g.λ₁

Expand All @@ -576,11 +576,11 @@ function QuantumClifford.apply!(state::BellState, g::T1NoiseOp)
4
end
elseif input_state==3
if r < 0.25*λ₁*(λ₁+1)
if r < 0.25*λ₁*(λ₁+1)
1
elseif r < 0.25*λ₁*(λ₁+1) + 0.5*λ₁*(1-λ₁)
2
elseif r < 0.25*λ₁*(λ₁+1) + 0.5*λ₁*(1-λ₁) + 0.25*λ₁*(λ₁+1)
elseif r < 0.25*λ₁*(λ₁+1) + 0.5*λ₁*(1-λ₁) + 0.25*λ₁*(λ₁+1)
3
else # r < 1 = 0.25*λ₁*(λ₁+1) + 0.5*λ₁*(1-λ₁) + 0.25*λ₁*(λ₁+1) + 0.5*λ₁*(1-λ₁)
4
Expand All @@ -596,52 +596,52 @@ function QuantumClifford.apply!(state::BellState, g::T1NoiseOp)
4
end
end

bit1, bit2 = int_to_bit(output_state, Val(2))
@inbounds phase[g.idx*2-1] = bit1
@inbounds phase[g.idx*2] = bit2
return state
end

"""Simulates T2 noise"""
struct T2NoiseOp <: BellOp
struct T2NoiseOp <: BellOp
idx::Int
λ₂::Float64
end

function QuantumClifford.apply!(state::BellState, g::T2NoiseOp)
phase = state.phases
input_state = bit_to_int(phase[g.idx*2-1],phase[g.idx*2]) # this is my initial state

r = rand()
λ₂ = g.λ₂

output_state = if input_state==1
if r < 0.5*λ₂^2 - λ₂ + 1
1
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
3
end
elseif input_state==2
if r < 0.5*λ₂^2 - λ₂ + 1
2
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
4
end
elseif input_state==3
if r < 0.5*λ₂^2 - λ₂ + 1
3
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
1
end
else # input_state==4
if r < 0.5*λ₂^2 - λ₂ + 1
4
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
else # r < 1 = 0.5*λ₂^2 - λ₂ + 1 + 0.5*λ₂*(2-λ₂)
2
end
end

bit1, bit2 = int_to_bit(output_state, Val(2))
@inbounds phase[g.idx*2-1] = bit1
@inbounds phase[g.idx*2] = bit2
Expand Down

0 comments on commit 43da8c7

Please sign in to comment.