Skip to content

Commit d11c261

Browse files
authored
Introduce Gabs extensions for Gaussian state and unitary conversions (#124)
* add Gabs as an extension * introduce `GabsRepr` from QInterface 0.4.0 * add v0.4.1 for QInterface for tensor conversions * add supporting Gabs tests * rm emptyline * bump Gabs to v1.3.1 for QInterface compat * update changelog and bump to v0.4.12-dev
1 parent 20ae204 commit d11c261

File tree

6 files changed

+77
-4
lines changed

6 files changed

+77
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# News
22

3+
## v0.4.12 - dev
4+
5+
- Add Gabs extension for numerical translations of symbolic Gaussian states and operators.
6+
37
## v0.4.11 - 2025-06-22
48

59
- Bump compats for QuantumInterface and QuantumClifford.

Project.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuantumSymbolics"
22
uuid = "efa7fd63-0460-4890-beb7-be1bbdfbaeae"
33
authors = ["QuantumSymbolics.jl contributors"]
4-
version = "0.4.11"
4+
version = "0.4.12-dev"
55

66
[deps]
77
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
@@ -14,21 +14,24 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1414
TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
1515

1616
[weakdeps]
17+
Gabs = "0eb812ee-a11f-4f5e-b8d4-bb8a44f06f50"
1718
QuantumClifford = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
1819
QuantumOpticsBase = "4f57444f-1401-5e15-980d-4471b28d5678"
1920

2021
[extensions]
22+
GabsExt = "Gabs"
2123
MixedCliffordOpticsExt = ["QuantumClifford", "QuantumOpticsBase"]
2224
QuantumCliffordExt = "QuantumClifford"
2325
QuantumOpticsExt = "QuantumOpticsBase"
2426

2527
[compat]
28+
Gabs = "1.3.1"
2629
Latexify = "0.16"
2730
LinearAlgebra = "1.9"
2831
MacroTools = "0.5.13"
2932
PrecompileTools = "1.2"
3033
QuantumClifford = "0.8.19, 0.9, 0.10"
31-
QuantumInterface = "0.3.7, 0.4"
34+
QuantumInterface = "0.3.7, 0.4.1"
3235
QuantumOpticsBase = "0.4.22, 0.5"
3336
SymbolicUtils = "3.7"
3437
Symbolics = "6"

ext/GabsExt/GabsExt.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module GabsExt
2+
3+
using QuantumSymbolics
4+
using QuantumSymbolics: CoherentState, GabsRepr
5+
import QuantumSymbolics: express, express_nolookup
6+
7+
using Gabs
8+
9+
function express_nolookup(x::FockState, repr::GabsRepr)
10+
x.idx == 0 || throw(ArgumentError("Fock states with index ≥ 0 are non-Gaussian and unsupported via the Gabs representation."))
11+
return vacuumstate(repr.basis(1))
12+
end
13+
express_nolookup(x::CoherentState, repr::GabsRepr) = coherentstate(repr.basis(1), x.alpha)
14+
express_nolookup(x::BosonicThermalState, repr::GabsRepr) = thermalstate(repr.basis(1), x.photons)
15+
express_nolookup(x::PhaseShiftOp, repr::GabsRepr) = phaseshift(repr.basis(1), x.phase)
16+
express_nolookup(x::DisplaceOp, repr::GabsRepr) = displace(repr.basis(1), x.alpha)
17+
express_nolookup(x::BeamSplitterOp, repr::GabsRepr) = beamsplitter(repr.basis(2), x.transmit)
18+
19+
for (f,g) in [(:SqueezedState, :squeezedstate),(:SqueezeOp,:squeeze)]
20+
@eval function express_nolookup(x::$f, repr::GabsRepr)
21+
r, i = (real(x.z), imag(x.z))
22+
return ($g)(repr.basis(1), sqrt(r^2 + i^2), atan(i, r))
23+
end
24+
end
25+
for (f,g) in [(:TwoSqueezedState, :eprstate),(:TwoSqueezeOp,:twosqueeze)]
26+
@eval function express_nolookup(x::$f, repr::GabsRepr)
27+
r, i = (real(x.z), imag(x.z))
28+
return ($g)(repr.basis(2), sqrt(r^2 + i^2), atan(i, r))
29+
end
30+
end
31+
32+
end

src/QSymbolicsBase/QSymbolicsBase.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import QuantumInterface:
1818
projector,dagger,tr,ptrace,
1919
AbstractBra,AbstractKet,AbstractOperator,AbstractSuperOperator,
2020
express,AbstractRepresentation,AbstractUse,UseAsState,UseAsObservable,UseAsOperation,
21-
QuantumOpticsRepr,QuantumMCRepr,CliffordRepr
21+
QuantumOpticsRepr,QuantumMCRepr,CliffordRepr,GabsRepr
2222

2323
export SymQObj,QObj,
2424
AbstractRepresentation,AbstractUse,
25-
QuantumOpticsRepr,QuantumMCRepr,CliffordRepr,
25+
QuantumOpticsRepr,QuantumMCRepr,CliffordRepr,GabsRepr,
2626
UseAsState,UseAsObservable,UseAsOperation,
2727
apply!,
2828
express,

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[deps]
22
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
Gabs = "0eb812ee-a11f-4f5e-b8d4-bb8a44f06f50"
45
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
56
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
67
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"

test/test_gabs.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@testitem "Gabs objects" begin
2+
using QuantumSymbolics
3+
using Gabs
4+
5+
α = rand(ComplexF64)
6+
r, θ, τ = rand(Float64), rand(Float64), rand(Float64)
7+
= rand(1:10)
8+
9+
for basis in [QuadBlockBasis, QuadPairBasis]
10+
@testset "Gaussian states - $(basis)" begin
11+
@test express(vac, GabsRepr(basis)) vacuumstate(basis(1))
12+
@test express(CoherentState(α), GabsRepr(basis)) coherentstate(basis(1), α)
13+
@test express(SqueezedState(r*exp(im*θ)), GabsRepr(basis)) squeezedstate(basis(1), r, θ)
14+
@test express(TwoSqueezedState(r*exp(im*θ)), GabsRepr(basis)) eprstate(basis(2), r, θ)
15+
@test express(BosonicThermalState(n̄), GabsRepr(basis)) thermalstate(basis(1), n̄)
16+
end
17+
18+
@testset "Gaussian unitaries - $(basis)" begin
19+
@test express(PhaseShiftOp(θ), GabsRepr(basis)) phaseshift(basis(1), θ)
20+
@test express(DisplaceOp(α), GabsRepr(basis)) displace(basis(1), α)
21+
@test express(SqueezeOp(r*exp(im*θ)), GabsRepr(basis)) squeeze(basis(1), r, θ)
22+
@test express(TwoSqueezeOp(r*exp(im*θ)), GabsRepr(basis)) twosqueeze(basis(2), r, θ)
23+
@test express(BeamSplitterOp(τ), GabsRepr(basis)) beamsplitter(basis(2), τ)
24+
end
25+
26+
@testset "Linear algebra operations" begin
27+
@test express(CoherentState(α) TwoSqueezedState(r*exp(im*θ)) vac, GabsRepr(basis)) coherentstate(basis(1), α) eprstate(basis(2), r, θ) vacuumstate(basis(1))
28+
@test express(DisplaceOp(α) * vac, GabsRepr(basis)) coherentstate(basis(1), α)
29+
@test express(DisplaceOp(α) SqueezeOp(r*exp(im*θ)) * (vac vac), GabsRepr(basis)) coherentstate(basis(1), α) squeezedstate(basis(1), r, θ)
30+
@test_broken express(ptrace(DisplaceOp(α) PhaseShiftOp(θ) BeamSplitterOp(τ), [2, 3]), GabsRepr(basis)) ptrace(displace(basis(1), α) phaseshift(basis(1), θ) beamsplitter(basis(2), τ), [2, 3])
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)