Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate express functionality and AbstractRepresentation type to QuantumInterface #93

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
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
20 changes: 1 addition & 19 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,12 @@ 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
Loading