Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
964cb43
fix #39 Cleaner dispatching onto StaticArrays
Fe-r-oz Feb 21, 2025
5b42460
some tests are broken
Fe-r-oz Feb 21, 2025
ca20715
use cleaner dispatching onto static arrays for gaussian unitaries
Fe-r-oz Feb 21, 2025
1172889
cleaner dispatching for gaussian channels
Fe-r-oz Feb 21, 2025
cd8c8e2
Merge branch 'main' into fa/i39
Fe-r-oz Feb 22, 2025
6721955
fix merge conflict typo caused by resolving merge conflict
Fe-r-oz Feb 22, 2025
dea74cd
fix errors after merge conflict
Fe-r-oz Feb 22, 2025
f85baa3
fixup to resolve merge conflicts errors
Fe-r-oz Feb 22, 2025
a7ba822
add codereview suggestions: use _infer_types via use traits instead o…
Fe-r-oz Feb 26, 2025
9db705d
add wonderful codereview suggestions: minor fixes/generalizations to …
Fe-r-oz Feb 26, 2025
df7612e
add wonderful codereview suggestions: polish
Fe-r-oz Feb 26, 2025
783ec5e
add wonderful codereview suggestions: polish
Fe-r-oz Feb 26, 2025
f33ef14
add more tests for SArray as well
Fe-r-oz Feb 26, 2025
c6f2f83
add missing comments that got removed
Fe-r-oz Feb 26, 2025
ec9cd51
Update ext/StaticArraysExt/utils.jl
Fe-r-oz Feb 27, 2025
589be9c
add wonderful codereview suggestions: improvements to type-based disp…
Fe-r-oz Feb 27, 2025
07e20fc
Merge branch 'apkille:main' into fa/i39
Fe-r-oz Feb 27, 2025
67f594b
add test_broken for some errors and comment out tests for phaseshift …
Fe-r-oz Feb 27, 2025
f8ec8bc
add test broken error that seems to be due to equality checks for Num…
Fe-r-oz Feb 27, 2025
2594d97
Update src/channels.jl
Fe-r-oz Feb 27, 2025
fd7050e
use dtype and ttype :)
Fe-r-oz Feb 27, 2025
ea6dc66
add wonderful codereview suggestions: improvements and polish
Fe-r-oz Feb 27, 2025
68e5665
polish
Fe-r-oz Feb 27, 2025
4fee0c8
polish
Fe-r-oz Feb 27, 2025
920f216
polish
Fe-r-oz Feb 27, 2025
e10368b
polish tests
Fe-r-oz Feb 27, 2025
b4dc7c8
undo tests that used previous notation of using static arrays
Fe-r-oz Feb 27, 2025
9c27458
improvements
Fe-r-oz Mar 9, 2025
1ced61e
cleanup
Fe-r-oz Mar 9, 2025
8526479
improvements
Fe-r-oz Mar 11, 2025
631a001
improvements
Fe-r-oz Mar 11, 2025
8f660b6
improvements
Fe-r-oz Mar 11, 2025
b5e53c5
fixup
Fe-r-oz Mar 11, 2025
7cb4314
simplify the type-based dispatch
Fe-r-oz Mar 11, 2025
d480e0b
enhance tests in test_randoms.jl
Fe-r-oz Mar 11, 2025
be07b78
enhance tests in test_random.jl
Fe-r-oz Mar 11, 2025
0c4799f
rm commit history that accidently got added as file
Fe-r-oz Mar 11, 2025
6be59ce
add more tests for test_random.jl
Fe-r-oz Mar 11, 2025
d31e463
follow the test convention setup by Andrew in test_unitaries.jl
Fe-r-oz Mar 11, 2025
c082dfb
Merge branch 'apkille:main' into fa/i39
Fe-r-oz Mar 23, 2025
8c8044f
Merge branch 'main' into fa/i39
Fe-r-oz May 6, 2025
38d516d
undo the changes here to work on new changes
Fe-r-oz Jun 8, 2025
cb93ef2
Merge branch 'apkille:main' into fa/i39
Fe-r-oz Jun 8, 2025
107039b
🛠️ cleaner dispatching of all gaussian states excluding EPR
Fe-r-oz Jun 15, 2025
b4e49e1
🧐add cleaner dispatching for EPR state
Fe-r-oz Jun 15, 2025
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 docs/src/tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ can specify an array type in its first (and second) arguments. Let's see an exam
```jldoctest
julia> using StaticArrays

julia> state = coherentstate(SVector{2}, SMatrix{2,2}, QuadPairBasis(1), 1.0-im)
julia> state = coherentstate(SVector, SMatrix, QuadPairBasis(1), 1.0-im)
GaussianState for 1 mode.
symplectic basis: QuadPairBasis
mean: 2-element SVector{2, Float64} with indices SOneTo(2):
Expand Down
9 changes: 6 additions & 3 deletions ext/StaticArraysExt/StaticArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ module StaticArraysExt
using StaticArrays: SVector, SMatrix, SArray

using Gabs
import Gabs: ptrace, tensor, ⊗, _promote_output_matrix, _promote_output_vector,
_generaldyne_map
using Gabs: SymplecticBasis, QuadPairBasis

import Gabs: ptrace, tensor, ⊗, _promote_output_matrix, _promote_output_vector,
_generaldyne_map, infer_mean_type, infer_covar_type, infer_displacement_type,
infer_symplectic_type, infer_transform_type

include("utils.jl")
include("measurements.jl")

end
end
27 changes: 26 additions & 1 deletion ext/StaticArraysExt/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,29 @@ Base.@propagate_inbounds function _promote_output_matrix(::Type{<:SMatrix}, mat_
end
Base.@propagate_inbounds function _promote_output_matrix(::Type{<:SMatrix}, mat_out, out_dim::Tuple)
return SMatrix{out_dim[1],out_dim[2]}(mat_out)
end
end

function infer_mean_type(::Type{SVector}, basis::Gabs.SymplecticBasis{N}) where {N}
nmodes = basis.nmodes
return SVector{2*nmodes, Float64}
end

function infer_covar_type(::Type{SMatrix}, basis::Gabs.SymplecticBasis{N}) where {N}
nmodes = basis.nmodes
return SMatrix{2*nmodes, 2*nmodes, Float64, 4*nmodes*nmodes}
end

function infer_displacement_type(::Type{SVector}, basis::Gabs.QuadPairBasis{N}) where {N}
nmodes = basis.nmodes
return SVector{2*nmodes, Float64}
end

function infer_symplectic_type(::Type{SMatrix}, basis::Gabs.QuadPairBasis{N}) where {N}
nmodes = basis.nmodes
return SMatrix{2*nmodes, 2*nmodes, Float64, 4*nmodes*nmodes}
end

function infer_transform_type(::Type{SMatrix}, basis::Gabs.SymplecticBasis{N}) where {N}
nmodes = basis.nmodes
return SMatrix{2*nmodes, 2*nmodes, Float64, 4*nmodes*nmodes}
end
38 changes: 31 additions & 7 deletions src/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
# Predefined Gaussian channels
##

function infer_transform_type end

function infer_transform_type(::Type{Array}, basis::Gabs.SymplecticBasis{N}) where {N}
return Array{Float64, 2}
end

function infer_transform_type(::Type{Array{T}}, basis::Gabs.SymplecticBasis{N}) where {T, N}
return Array{T, 2}

Check warning on line 12 in src/channels.jl

View check run for this annotation

Codecov / codecov/patch

src/channels.jl#L11-L12

Added lines #L11 - L12 were not covered by tests
end

function displace(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, alpha::A, noise::M) where {Td,Tt,N<:Int,A,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform = _displace(basis, alpha)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise))
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise))
end
displace(::Type{T}, basis::SymplecticBasis{N}, alpha::A, noise::M) where {T,N<:Int,A,M} = displace(T, T, basis, alpha, noise)
function displace(basis::SymplecticBasis{N}, alpha::A, noise::M) where {N<:Int,A,M}
Expand All @@ -13,8 +25,10 @@
end

function squeeze(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, r::R, theta::R, noise::M) where {Td,Tt,N<:Int,R,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform = _squeeze(basis, r, theta)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise))
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise))
end
squeeze(::Type{T}, basis::SymplecticBasis{N}, r::R, theta::R, noise::M) where {T,N<:Int,R,M} = squeeze(T, T, basis, r, theta, noise)
function squeeze(basis::SymplecticBasis{N}, r::R, theta::R, noise::M) where {N<:Int,R,M}
Expand All @@ -23,8 +37,10 @@
end

function twosqueeze(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, r::R, theta::R, noise::M) where {Td,Tt,N<:Int,R,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform = _twosqueeze(basis, r, theta)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise))
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise))
end
twosqueeze(::Type{T}, basis::SymplecticBasis{N}, r::R, theta::R, noise::M) where {T,N<:Int,R,M} = twosqueeze(T, T, basis, r, theta, noise)
function twosqueeze(basis::SymplecticBasis{N}, r::R, theta::R, noise::M) where {N<:Int,R,M}
Expand All @@ -33,8 +49,10 @@
end

function phaseshift(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, theta::R, noise::M) where {Td,Tt,N<:Int,R,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform = _phaseshift(basis, theta)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise))
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise))
end
phaseshift(::Type{T}, basis::SymplecticBasis{N}, theta::R, noise::M) where {T,N<:Int,R,M} = phaseshift(T, T, basis, theta, noise)
function phaseshift(basis::SymplecticBasis{N}, theta::R, noise::M) where {N<:Int,R,M}
Expand All @@ -43,8 +61,10 @@
end

function beamsplitter(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, transmit::R, noise::M) where {Td,Tt,N<:Int,R,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform = _beamsplitter(basis, transmit)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise))
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise))
end
beamsplitter(::Type{T}, basis::SymplecticBasis{N}, transmit::R, noise::M) where {T,N<:Int,R,M} = beamsplitter(T, T, basis, transmit, noise)
function beamsplitter(basis::SymplecticBasis{N}, transmit::R, noise::M) where {N<:Int,R,M}
Expand Down Expand Up @@ -84,8 +104,10 @@
```
"""
function attenuator(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, theta::R, n::M; ħ = 2) where {Td,Tt,N<:Int,R,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform, noise = _attenuator(basis, theta, n)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise); ħ = ħ)
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise); ħ = ħ)
end
attenuator(::Type{T}, basis::SymplecticBasis{N}, theta::R, n::M; ħ = 2) where {T,N<:Int,R,M} = attenuator(T, T, basis, theta, n; ħ = ħ)
function attenuator(basis::SymplecticBasis{N}, theta::R, n::M; ħ = 2) where {N<:Int,R,M}
Expand Down Expand Up @@ -168,8 +190,10 @@
```
"""
function amplifier(::Type{Td}, ::Type{Tt}, basis::SymplecticBasis{N}, r::R, n::M; ħ = 2) where {Td,Tt,N<:Int,R,M}
disp_type = infer_displacement_type(Td, basis)
transform_type = infer_transform_type(Tt, basis)
disp, transform, noise = _amplifier(basis, r, n)
return GaussianChannel(basis, Td(disp), Tt(transform), Tt(noise); ħ = ħ)
return GaussianChannel(basis, disp_type(disp), transform_type(transform), transform_type(noise); ħ = ħ)
end
amplifier(::Type{T}, basis::SymplecticBasis{N}, r::R, n::M; ħ = 2) where {T,N<:Int,R,M} = amplifier(T, T, basis, r, n; ħ = ħ)
function amplifier(basis::SymplecticBasis{N}, r::R, n::M; ħ = 2) where {N<:Int,R,M}
Expand Down
48 changes: 39 additions & 9 deletions src/states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
# Predefined Gaussian states
##

function infer_mean_type end

function infer_mean_type(::Type{Array}, basis::Gabs.SymplecticBasis{N}) where {N}
return Array
end

function infer_mean_type(::Type{Array{T}}, basis::Gabs.SymplecticBasis{N}) where {T, N}
return Array{T, 1}

Check warning on line 12 in src/states.jl

View check run for this annotation

Codecov / codecov/patch

src/states.jl#L11-L12

Added lines #L11 - L12 were not covered by tests
end

function infer_covar_type end

function infer_covar_type(::Type{Array}, basis::Gabs.SymplecticBasis{N}) where {N}
return Array
end

function infer_covar_type(::Type{Array{T}}, basis::Gabs.SymplecticBasis{N}) where {T, N}
return Array{T, 2}

Check warning on line 22 in src/states.jl

View check run for this annotation

Codecov / codecov/patch

src/states.jl#L21-L22

Added lines #L21 - L22 were not covered by tests
end

"""
vacuumstate([Tm=Vector{Float64}, Tc=Matrix{Float64}], basis::SymplecticBasis)
Expand All @@ -27,8 +47,10 @@
```
"""
function vacuumstate(::Type{Tm}, ::Type{Tc}, basis::SymplecticBasis{N}; ħ = 2) where {Tm,Tc,N<:Int}
mean, covar = _vacuumstate(basis; ħ = ħ)
return GaussianState(basis, Tm(mean), Tc(covar); ħ = ħ)
mean_type = infer_mean_type(Tm, basis)
covar_type = infer_covar_type(Tc, basis)
mean, covar = _vacuumstate(basis)
return GaussianState(basis, mean_type(mean), covar_type(covar); ħ = ħ)
end
vacuumstate(::Type{T}, basis::SymplecticBasis{N}; ħ = 2) where {T,N<:Int} = vacuumstate(T, T, basis; ħ = ħ)
function vacuumstate(basis::SymplecticBasis{N}; ħ = 2) where {N<:Int}
Expand Down Expand Up @@ -69,8 +91,10 @@
```
"""
function thermalstate(::Type{Tm}, ::Type{Tc}, basis::SymplecticBasis{N}, photons::P; ħ = 2) where {Tm,Tc,N<:Int,P}
mean_type = infer_mean_type(Tm, basis)
covar_type = infer_covar_type(Tc, basis)
mean, covar = _thermalstate(basis, photons; ħ = ħ)
return GaussianState(basis, Tm(mean), Tc(covar); ħ = ħ)
return GaussianState(basis, mean_type(mean), covar_type(covar); ħ = ħ)
end
thermalstate(::Type{T}, basis::SymplecticBasis{N}, photons::P; ħ = 2) where {T,N<:Int,P} = thermalstate(T, T, basis, photons; ħ = ħ)
function thermalstate(basis::SymplecticBasis{N}, photons::P; ħ = 2) where {N<:Int,P}
Expand Down Expand Up @@ -137,8 +161,10 @@
```
"""
function coherentstate(::Type{Tm}, ::Type{Tc}, basis::SymplecticBasis{N}, alpha::A; ħ = 2) where {Tm,Tc,N<:Int,A}
mean, covar = _coherentstate(basis, alpha; ħ = ħ)
return GaussianState(basis, Tm(mean), Tc(covar); ħ = ħ)
mean_type = infer_mean_type(Tm, basis)
covar_type = infer_covar_type(Tc, basis)
mean, covar = _coherentstate(basis, alpha)
return GaussianState(basis, mean_type(mean), covar_type(covar); ħ = ħ)
end
coherentstate(::Type{T}, basis::SymplecticBasis{N}, alpha::A; ħ = 2) where {T,N<:Int,A} = coherentstate(T, T, basis, alpha; ħ = ħ)
function coherentstate(basis::SymplecticBasis{N}, alpha::A; ħ = 2) where {N<:Int,A}
Expand Down Expand Up @@ -203,8 +229,10 @@
```
"""
function squeezedstate(::Type{Tm}, ::Type{Tc}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {Tm,Tc,N<:Int,R}
mean, covar = _squeezedstate(basis, r, theta; ħ = ħ)
return GaussianState(basis, Tm(mean), Tc(covar); ħ = ħ)
mean_type = infer_mean_type(Tm, basis)
covar_type = infer_covar_type(Tc, basis)
mean, covar = _squeezedstate(basis, r, theta)
return GaussianState(basis, mean_type(mean), covar_type(covar); ħ = ħ)
end
squeezedstate(::Type{T}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {T,N<:Int,R} = squeezedstate(T, T, basis, r, theta; ħ = ħ)
function squeezedstate(basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {N<:Int,R}
Expand Down Expand Up @@ -303,8 +331,10 @@
```
"""
function eprstate(::Type{Tm}, ::Type{Tc}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {Tm,Tc,N<:Int,R}
mean, covar = _eprstate(basis, r, theta; ħ = ħ)
return GaussianState(basis, Tm(mean), Tc(covar); ħ = ħ)
mean_type = infer_mean_type(Tm, basis)
covar_type = infer_covar_type(Tc, basis)
mean, covar = _eprstate(basis, r, theta)
return GaussianState(basis, mean_type(mean), covar_type(covar); ħ = ħ)
end
eprstate(::Type{T}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {T,N<:Int,R} = eprstate(T, T, basis, r, theta; ħ = ħ)
function eprstate(basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {N<:Int,R}
Expand Down
46 changes: 40 additions & 6 deletions src/unitaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
# Predefined Gaussian unitaries
##

function infer_displacement_type end

function infer_symplectic_type end

function infer_displacement_type(::Type{Array{T}}, basis::Gabs.QuadPairBasis{N}) where {T, N}
nmodes = basis.nmodes
return Array{T, 1}
end

function infer_displacement_type(::Type{Array}, basis::Gabs.QuadPairBasis{N}) where {N}
nmodes = basis.nmodes
return Array{Float64, 1}
end

function infer_symplectic_type(::Type{Array{T}}, basis::Gabs.QuadPairBasis{N}) where {T, N}
nmodes = basis.nmodes
return Array{T, 2}
end

function infer_symplectic_type(::Type{Array}, basis::Gabs.QuadPairBasis{N}) where {N}
nmodes = basis.nmodes
return Array{Float64, 2}
end

"""
displace([Tm=Vector{Float64}, Ts=Matrix{Float64}], basis::SymplecticBasis, alpha<:Number)
displace([Tm=Vector{Float64}, Ts=Matrix{Float64}], basis::SymplecticBasis, alpha<:Number, noise::Ts)
Expand Down Expand Up @@ -32,8 +56,10 @@ symplectic: 2×2 Matrix{Float64}:
```
"""
function displace(::Type{Td}, ::Type{Ts}, basis::SymplecticBasis{N}, alpha::A; ħ = 2) where {Td,Ts,N<:Int,A}
disp, symplectic = _displace(basis, alpha; ħ = ħ)
return GaussianUnitary(basis, Td(disp), Ts(symplectic); ħ = ħ)
disp_type = infer_displacement_type(Td, basis)
symplectic_type = infer_symplectic_type(Ts, basis)
disp, symplectic = _displace(basis, alpha)
return GaussianUnitary(basis, disp_type(disp), symplectic_type(symplectic); ħ = ħ)
end
displace(::Type{T}, basis::SymplecticBasis{N}, alpha::A; ħ = 2) where {T,N<:Int,A} = displace(T, T, basis, alpha; ħ = ħ)
function displace(basis::SymplecticBasis{N}, alpha::A; ħ = 2) where {N<:Int,A}
Expand Down Expand Up @@ -103,8 +129,10 @@ symplectic: 2×2 Matrix{Float64}:
```
"""
function squeeze(::Type{Td}, ::Type{Ts}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {Td,Ts,N<:Int,R}
disp_type = infer_displacement_type(Td, basis)
symplectic_type = infer_symplectic_type(Ts, basis)
disp, symplectic = _squeeze(basis, r, theta)
return GaussianUnitary(basis, Td(disp), Ts(symplectic); ħ = ħ)
return GaussianUnitary(basis, disp_type(disp), symplectic_type(symplectic); ħ = ħ)
end
squeeze(::Type{T}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {T,N<:Int,R} = squeeze(T, T, basis, r, theta; ħ = ħ)
function squeeze(basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {N<:Int, R}
Expand Down Expand Up @@ -208,8 +236,10 @@ symplectic: 4×4 Matrix{Float64}:
```
"""
function twosqueeze(::Type{Td}, ::Type{Ts}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {Td,Ts,N<:Int,R}
disp_type = infer_displacement_type(Td, basis)
symplectic_type = infer_symplectic_type(Ts, basis)
disp, symplectic = _twosqueeze(basis, r, theta)
return GaussianUnitary(basis, Td(disp), Ts(symplectic); ħ = ħ)
return GaussianUnitary(basis, disp_type(disp), symplectic_type(symplectic); ħ = ħ)
end
twosqueeze(::Type{T}, basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {T,N<:Int,R} = twosqueeze(T, T, basis, r, theta; ħ = ħ)
function twosqueeze(basis::SymplecticBasis{N}, r::R, theta::R; ħ = 2) where {N<:Int,R}
Expand Down Expand Up @@ -353,8 +383,10 @@ symplectic: 2×2 Matrix{Float64}:
```
"""
function phaseshift(::Type{Td}, ::Type{Ts}, basis::SymplecticBasis{N}, theta::R; ħ = 2) where {Td,Ts,N<:Int,R}
disp_type = infer_displacement_type(Td, basis)
symplectic_type = infer_symplectic_type(Ts, basis)
disp, symplectic = _phaseshift(basis, theta)
return GaussianUnitary(basis, Td(disp), Ts(symplectic); ħ = ħ)
return GaussianUnitary(basis, disp_type(disp), symplectic_type(symplectic); ħ = ħ)
end
phaseshift(::Type{T}, basis::SymplecticBasis{N}, theta::R; ħ = 2) where {T,N<:Int,R} = phaseshift(T, T, basis, theta; ħ = ħ)
function phaseshift(basis::SymplecticBasis{N}, theta::R; ħ = 2) where {N<:Int,R}
Expand Down Expand Up @@ -453,8 +485,10 @@ symplectic: 4×4 Matrix{Float64}:
```
"""
function beamsplitter(::Type{Td}, ::Type{Ts}, basis::SymplecticBasis{N}, transmit::R; ħ = 2) where {Td,Ts,N<:Int,R}
disp_type = infer_displacement_type(Td, basis)
symplectic_type = infer_symplectic_type(Ts, basis)
disp, symplectic = _beamsplitter(basis, transmit)
return GaussianUnitary(basis, Td(disp), Ts(symplectic); ħ = ħ)
return GaussianUnitary(basis, disp_type(disp), symplectic_type(symplectic); ħ = ħ)
end
beamsplitter(::Type{T}, basis::SymplecticBasis{N}, transmit::R; ħ = 2) where {T,N<:Int,R} = beamsplitter(T, T, basis, transmit; ħ = ħ)
function beamsplitter(basis::SymplecticBasis{N}, transmit::R; ħ = 2) where {N<:Int,R}
Expand Down
Loading
Loading