Skip to content

Commit

Permalink
migrate express functionality to QuantumInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Dec 22, 2024
1 parent f2cda40 commit 484b15e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/QSymbolicsBase/QSymbolicsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import QuantumInterface:
basis,Basis,samebases,IncompatibleBases,SpinBasis,FockBasis,CompositeBasis,
nqubits,
projector,dagger,tr,ptrace,
AbstractBra,AbstractKet,AbstractOperator,AbstractSuperOperator
AbstractBra,AbstractKet,AbstractOperator,AbstractSuperOperator,
express,AbstractRepresentation,QuantumOpticsRepr,QuantumMCRepr,CliffordRepr

export SymQObj,QObj,
AbstractRepresentation,AbstractUse,
Expand Down Expand Up @@ -53,8 +54,6 @@ export SymQObj,QObj,
# Metadata cache helpers
##

"""An abstract type for the supported representation of quantum objects."""
abstract type AbstractRepresentation end
abstract type AbstractUse end
struct UseAsState <: AbstractUse end
struct UseAsOperation <: AbstractUse end
Expand Down
19 changes: 1 addition & 18 deletions src/QSymbolicsBase/express.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ julia> express(QuantumSymbolics.X, CliffordRepr(), UseAsObservable())
+ X
```
"""
function express end

function express(state::Symbolic, repr::AbstractRepresentation, use::AbstractUse)
md = metadata(state)
isnothing(md) && return express_from_cache(express_nolookup(state, repr, use))
Expand Down Expand Up @@ -72,28 +70,13 @@ function consistent_representation(reprs,state)
end
first(reprs)
end

##
# Commonly used representations -- interfaces for each one defined in separate packages
##

"""Representation using kets, bras, density matrices, and superoperators governed by `QuantumOptics.jl`."""
@kwdef struct QuantumOpticsRepr <: AbstractRepresentation
cutoff::Int = 2
end
"""Similar to `QuantumOpticsRepr`, but using trajectories instead of superoperators."""
struct QuantumMCRepr <: AbstractRepresentation end
"""Representation using tableaux governed by `QuantumClifford.jl`"""
struct CliffordRepr <: AbstractRepresentation end

express(state::Symbolic) = express(state, QuantumOpticsRepr()) # The default representation
express_nolookup(state, ::QuantumMCRepr) = express_nolookup(state, QuantumOpticsRepr())
express(state) = state

function express_nolookup(s, repr::AbstractRepresentation)
if isexpr(s)
operation(s)(express.(arguments(s), (repr,))...)
else
error("Encountered an object $(s) of type $(typeof(s)) that can not be converted to $(repr) representation") # TODO make a nice error type
end
end
end

0 comments on commit 484b15e

Please sign in to comment.