Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# News

## v0.4.3 - 2026-06-14

- Add a `lazy::Bool=false` option to `QuantumOpticsRepr`. When set, downstream `express` conversions (in `QuantumSymbolics.jl`) translate symbolic operator sums, products, and tensor products into `QuantumOpticsBase` lazy operators. The existing `QuantumOpticsRepr()` and `QuantumOpticsRepr(cutoff)` constructors are preserved.

## v0.4.2 - 2025-11-29

- Define `commutator` and `anticommutator`.
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumInterface"
uuid = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
authors = ["QuantumInterface.jl contributors"]
version = "0.4.2"
version = "0.4.3"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
10 changes: 8 additions & 2 deletions src/express.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ express(s, repr::AbstractRepresentation) = express(s, repr, UseAsState())
# Commonly used representations -- interfaces for each one defined in separate packages
##

"""Representation using kets, bras, density matrices, and superoperators governed by `QuantumOptics.jl`."""
Base.@kwdef struct QuantumOpticsRepr <: AbstractRepresentation
"""Representation using kets, bras, density matrices, and superoperators governed by `QuantumOptics.jl`.

With `lazy=true`, downstream `express` conversions build the lazy operator types of
`QuantumOpticsBase` (`LazySum`, `LazyProduct`, `LazyTensor`) for symbolic sums, products,
and tensor products instead of materializing dense matrices."""
Base.@kwdef struct QuantumOpticsRepr <: AbstractRepresentation
cutoff::Int = 2
lazy::Bool = false
end
QuantumOpticsRepr(cutoff::Int) = QuantumOpticsRepr(; cutoff)
"""Similar to `QuantumOpticsRepr`, but using trajectories instead of superoperators."""
struct QuantumMCRepr <: AbstractRepresentation end
"""Representation using tableaux governed by `QuantumClifford.jl`"""
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREA

@doset "sortedindices"
@doset "bases"
@doset "express"
#VERSION >= v"1.9" && @doset "doctests"
get(ENV,"JET_TEST","")=="true" && @doset "jet"
VERSION >= v"1.9" && @doset "aqua"
28 changes: 28 additions & 0 deletions test/test_express.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Test
using QuantumInterface: QuantumOpticsRepr

@testset "QuantumOpticsRepr constructors" begin
# the default stays eager
@test QuantumOpticsRepr() == QuantumOpticsRepr(2, false)
@test QuantumOpticsRepr().cutoff == 2
@test QuantumOpticsRepr().lazy == false

# the positional `cutoff` constructor is preserved
@test QuantumOpticsRepr(4) == QuantumOpticsRepr(cutoff=4)
@test QuantumOpticsRepr(4).cutoff == 4
@test QuantumOpticsRepr(4).lazy == false

# the new `lazy` option is opt-in via keyword
@test QuantumOpticsRepr(lazy=true).lazy == true
@test QuantumOpticsRepr(cutoff=4, lazy=true) == QuantumOpticsRepr(4, true)
end

@testset "QuantumOpticsRepr cache-key equality" begin
# `express` caches conversions in a `Dict` keyed on the representation value, so an
# eager and a lazy representation of the same object must compare unequal (and hash
# differently) or the cache would hand back the wrong type.
@test QuantumOpticsRepr(4) == QuantumOpticsRepr(cutoff=4, lazy=false)
@test QuantumOpticsRepr(4) != QuantumOpticsRepr(4, true)
@test hash(QuantumOpticsRepr(4)) == hash(QuantumOpticsRepr(cutoff=4, lazy=false))
@test hash(QuantumOpticsRepr(2)) != hash(QuantumOpticsRepr(2, true))
end