Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Gabs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export
vacuumstate, thermalstate, coherentstate, squeezedstate, eprstate,
# predefined Gaussian channels
displace, squeeze, twosqueeze, phaseshift, beamsplitter,
attenuator, amplifier,
attenuator, amplifier, sum_gate,
Copy link
Member

Choose a reason for hiding this comment

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

Can you change it to twosum rather than sum_gate? It can then follow similar naming conventions to twosqueeze.

# random objects
randstate, randunitary, randchannel, randsymplectic,
# wigner functions
Expand Down
63 changes: 63 additions & 0 deletions src/unitaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,69 @@
return disp, symplectic
end

"""
Constructs the two-mode SUM gate as a Gaussian unitary operator.
Copy link
Member

Choose a reason for hiding this comment

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

Can you describe mathematically what it does? Similar to this docstring: https://github.com/apkille/Gabs.jl/blob/fe7180a1de0f276f6bc4f5bb5ddeff3e4beb6b13/src/unitaries.jl#L5-L33

```jldoctest
julia> sum_gate(QuadPairBasis(2))
GaussianUnitary for 2 modes.
symplectic basis: QuadPairBasis
displacement: 4-element Vector{Float64}:
0.0
0.0
0.0
0.0
symplectic: 4Γ—4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 1.0 0.0 -1.0
1.0 0.0 1.0 0.0
0.0 0.0 0.0 1.0
```
"""
function sum_gate(::Type{Td}, ::Type{Ts}, basis::SymplecticBasis{N}; Δ§ = 2) where {Td, Ts, N}
disp, symplectic = _sum_gate(basis)
return GaussianUnitary(basis, Td(disp), Ts(symplectic); Δ§ = Δ§)

Check warning on line 561 in src/unitaries.jl

View check run for this annotation

Codecov / codecov/patch

src/unitaries.jl#L559-L561

Added lines #L559 - L561 were not covered by tests
end
function sum_gate(::Type{T}, basis::SymplecticBasis{N}; Δ§ = 2) where {T, N}
return sum_gate(T, T, basis; Δ§ = Δ§)

Check warning on line 564 in src/unitaries.jl

View check run for this annotation

Codecov / codecov/patch

src/unitaries.jl#L563-L564

Added lines #L563 - L564 were not covered by tests
end
function sum_gate(basis::SymplecticBasis{N}; Δ§ = 2) where {N}
disp, symplectic = _sum_gate(basis)
return GaussianUnitary(basis, disp, symplectic; Δ§ = Δ§)
end
function _sum_gate(basis::QuadBlockBasis{N}) where {N<:Int}
Copy link
Member

Choose a reason for hiding this comment

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

Can you make it so that the sum gate supports arbitrary 2n-mode systems, rather than only 2-mode systems? This is done similarly in the twosqueeze function: https://github.com/apkille/Gabs.jl/blob/fe7180a1de0f276f6bc4f5bb5ddeff3e4beb6b13/src/unitaries.jl#L211-L323
This section of the docs might be helpful.

nmodes = basis.nmodes
if nmodes != 2
error("SUM gate is defined for 2-mode systems only.")

Check warning on line 573 in src/unitaries.jl

View check run for this annotation

Codecov / codecov/patch

src/unitaries.jl#L570-L573

Added lines #L570 - L573 were not covered by tests
end
disp = zeros(Float64, 2 * nmodes)
symplectic = zeros(Float64, 2 * nmodes, 2 * nmodes)
symplectic[1, 1] = 1.0
symplectic[2, 1] = 1.0
symplectic[2, 2] = 1.0
symplectic[3, 3] = 1.0
symplectic[3, 4] = -1.0
symplectic[4, 4] = 1.0
return disp, symplectic

Check warning on line 583 in src/unitaries.jl

View check run for this annotation

Codecov / codecov/patch

src/unitaries.jl#L575-L583

Added lines #L575 - L583 were not covered by tests
end
function _sum_gate(basis::QuadPairBasis{N}) where {N<:Int}
nmodes = basis.nmodes
if nmodes != 2
error("SUM gate is defined for 2-mode systems only.")

Check warning on line 588 in src/unitaries.jl

View check run for this annotation

Codecov / codecov/patch

src/unitaries.jl#L588

Added line #L588 was not covered by tests
end
disp = zeros(Float64, 2 * nmodes)
S = [1.0 0.0 0.0 0.0;
1.0 1.0 0.0 0.0;
0.0 0.0 1.0 -1.0;
0.0 0.0 0.0 1.0]
P = [1.0 0.0 0.0 0.0;
0.0 0.0 1.0 0.0;
0.0 1.0 0.0 0.0;
0.0 0.0 0.0 1.0]
symplectic = P * S * P'
return disp, symplectic
end

##
# Operations on Gaussian unitaries
##
Expand Down
Loading