Skip to content

Commit

Permalink
Merge branch 'QuantumSavory:master' into q_channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ba2tro authored Nov 2, 2023
2 parents dd5da70 + 60d60e2 commit 55c6256
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ QuantumOpticsBase = "0.4.17"
QuantumSymbolics = "0.2.4"
Reexport = "1.2.2"
ResumableFunctions = "0.6.1"
Statistics = "1"
julia = "1.9"
22 changes: 11 additions & 11 deletions src/CircuitZoo/CircuitZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -870,20 +870,20 @@ julia> initialize!((regA[1], regB[1]), (L0⊗L0+L1⊗L1)/√2);
julia> message = [1, 1];
julia> SDEncode()(regA, message);
julia> SDEncode()(regA[1], message);
```
See also [`SDDecode`](@ref)
"""
struct SDEncode <: AbstractCircuit
end

function (circuit::SDEncode)(reg, message)
function (circuit::SDEncode)(rref, message)
if message[2] == 1
apply!(reg[1], X)
apply!(rref, X)
end
if message[1] == 1
apply!(reg[1], Z)
apply!(rref, Z)
end
end

Expand All @@ -900,15 +900,15 @@ using the entangled bell pair stored in the registers regA and regB after Alice'
Returns a Tuple of the decoded message.
```jldoctest
julia> regA = Register(1); regB = Register(2);
julia> regA = Register(1); regB = Register(1);
julia> initialize!((regA[1], regB[1]), (L0⊗L0+L1⊗L1)/√2);
julia> message = [1, 1];
julia> SDEncode()(regA, message);
julia> SDDecode()(regA, regB)
julia> SDDecode()(regA[1], regB[1])
(1, 1)
```
Expand All @@ -917,11 +917,11 @@ See also [`SDEncode`](@ref)
struct SDDecode <: AbstractCircuit
end

function (circuit::SDDecode)(regA, regB)
apply!((regA[1], regB[1]), CNOT)
apply!(regA[1], H)
b1 = project_traceout!(regA, 1, Z)
b2 = project_traceout!(regB, 1, Z)
function (circuit::SDDecode)(rrefA, rrefB)
apply!((rrefA, rrefB), CNOT)
apply!(rrefA, H)
b1 = project_traceout!(rrefA, Z)
b2 = project_traceout!(rrefB, Z)
return b1-1, b2-1
end

Expand Down
4 changes: 2 additions & 2 deletions test/test_circuitzoo_superdense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ for i in 1:8
message = Tuple(rand(0:1, 2))

# Use the circuits to encode and decode the message
SDEncode()(ra, message)
rec = SDDecode()(ra, rb)
SDEncode()(ra[1], message)
rec = SDDecode()(ra[1], rb[1])

@test message == rec
end

0 comments on commit 55c6256

Please sign in to comment.