-
Notifications
You must be signed in to change notification settings - Fork 5
Implement two-mode summing unitary #52
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,6 +537,69 @@ | |
| return disp, symplectic | ||
| end | ||
|
|
||
| """ | ||
| Constructs the two-mode SUM gate as a Gaussian unitary operator. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); Δ§ = Δ§) | ||
| end | ||
| function sum_gate(::Type{T}, basis::SymplecticBasis{N}; Δ§ = 2) where {T, N} | ||
| return sum_gate(T, T, basis; Δ§ = Δ§) | ||
| 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} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| nmodes = basis.nmodes | ||
| if nmodes != 2 | ||
| error("SUM gate is defined for 2-mode systems only.") | ||
| 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 | ||
| 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.") | ||
| 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 | ||
| ## | ||
|
|
||
There was a problem hiding this comment.
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
twosumrather thansum_gate? It can then follow similar naming conventions totwosqueeze.