Skip to content

Commit

Permalink
boson op change
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Jul 8, 2024
1 parent e3d7eb0 commit ffd9c26
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/QSymbolicsBase/predefined.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,28 @@ const CPHASE = CPHASEGate()
abstract type AbstractSingleBosonOp <: Symbolic{AbstractOperator} end
abstract type AbstractSingleBosonGate <: AbstractSingleBosonOp end # TODO maybe an IsUnitaryTrait is a better choice
isexpr(::AbstractSingleBosonGate) = false
basis(x::AbstractSingleBosonOp) = x.basis
basis(::AbstractSingleBosonGate) = inf_fock_basis

@withmetadata struct NumberOp <: AbstractSingleBosonOp end
@withmetadata struct NumberOp <: AbstractSingleBosonOp
basis::Basis
end
symbollabel(::NumberOp) = "n"
@withmetadata struct CreateOp <: AbstractSingleBosonOp end
@withmetadata struct CreateOp <: AbstractSingleBosonOp
basis::Basis
end
symbollabel(::CreateOp) = "a†"
@withmetadata struct DestroyOp <: AbstractSingleBosonOp end
@withmetadata struct DestroyOp <: AbstractSingleBosonOp
basis::Basis
end
symbollabel(::DestroyOp) = "a"
basis(::Union{NumberOp, CreateOp, DestroyOp}) = inf_fock_basis

"""Number operator, also available as the constant `n̂`"""
const N = const= NumberOp()
const N = const= NumberOp(inf_fock_basis)
"""Creation operator, also available as the constant `âꜛ` - there is no unicode dagger superscript, so we use the uparrow"""
const Create = const âꜛ = CreateOp()
const Create = const âꜛ = CreateOp(inf_fock_basis)
"""Annihilation operator, also available as the constant `â`"""
const Destroy = const= DestroyOp()
const Destroy = const= DestroyOp(inf_fock_basis)

##
# Other special or useful objects
Expand Down

0 comments on commit ffd9c26

Please sign in to comment.