From 169d0c916239d5888825e39fa85bb71e39d2c8e9 Mon Sep 17 00:00:00 2001 From: ruthwikchikoti Date: Thu, 4 Jun 2026 01:18:58 +0530 Subject: [PATCH] Add lazy option to QuantumOpticsRepr Add a `lazy::Bool=false` field to `QuantumOpticsRepr` so that downstream packages (QuantumSymbolics.jl) can opt into structure-preserving lazy operator output. The existing `QuantumOpticsRepr()` and `QuantumOpticsRepr(cutoff)` constructors are preserved via an explicit single-argument constructor. --- CHANGELOG.md | 4 ++++ Project.toml | 2 +- src/express.jl | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa9af19..38a6679 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # News +## v0.4.3 - 2026-06-04 + +- Add a `lazy::Bool=false` option to `QuantumOpticsRepr`. The existing `QuantumOpticsRepr()` and `QuantumOpticsRepr(cutoff)` constructors are preserved. + ## v0.4.2 - 2025-11-29 - Define `commutator` and `anticommutator`. diff --git a/Project.toml b/Project.toml index 2029043..4b0e668 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/express.jl b/src/express.jl index c088c27..98201ad 100644 --- a/src/express.jl +++ b/src/express.jl @@ -22,10 +22,18 @@ 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`. + +Set `lazy=true` to express symbolic sums, products, and tensor products using the lazy operator +types from `QuantumOpticsBase` (`LazySum`, `LazyProduct`, `LazyTensor`) where the basis structure +supports it, instead of eagerly materializing dense operators.""" +Base.@kwdef struct QuantumOpticsRepr <: AbstractRepresentation cutoff::Int = 2 + lazy::Bool = false end +# Preserve the single positional-argument constructor `QuantumOpticsRepr(cutoff)`, which the +# `@kwdef`-generated all-positional constructor would otherwise shadow once a second field exists. +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`"""