Skip to content

Commit

Permalink
Merge pull request #43 from ytdHuang/dev/superopeator
Browse files Browse the repository at this point in the history
define `OperatorKetQuantumObject` and `OperatorBraQuantumObject`
  • Loading branch information
ytdHuang authored Apr 1, 2024
2 parents 59f7a0a + baeed86 commit 8994e7d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ CurrentModule = QuantumToolbox
BraQuantumObject
KetQuantumObject
OperatorQuantumObject
OperatorBraQuantumObject
OperatorKetQuantumObject
SuperOperatorQuantumObject
QuantumObject
Qobj
ket2dm
isbra
isket
isoper
isoperbra
isoperket
issuper
size
eltype
Expand Down
4 changes: 2 additions & 2 deletions src/QuantumToolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ include("arnoldi.jl")
include("eigsolve.jl")
include("negativity.jl")

export QuantumObject, Qobj, BraQuantumObject, KetQuantumObject, OperatorQuantumObject, SuperOperatorQuantumObject, TimeEvolutionSol
export isket, isbra, isoper, issuper, ket2dm
export QuantumObject, Qobj, BraQuantumObject, KetQuantumObject, OperatorQuantumObject, OperatorBraQuantumObject, OperatorKetQuantumObject, SuperOperatorQuantumObject, TimeEvolutionSol
export isket, isbra, isoper, isoperbra, isoperket, issuper, ket2dm
export spre, spost, sprepost, lindblad_dissipator
export fock, basis, coherent
export sigmam, sigmap, sigmax, sigmay, sigmaz
Expand Down
34 changes: 33 additions & 1 deletion src/quantum_object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ Abstract type representing a super-operator ``\hat{\mathcal{O}}``.
"""
abstract type SuperOperatorQuantumObject <: QuantumObjectType end

@doc raw"""
OperatorBraQuantumObject <: QuantumObjectType
Abstract type representing a bra state in the super-operator formalism ``\langle\langle\rho|``.
"""
abstract type OperatorBraQuantumObject <: QuantumObjectType end

@doc raw"""
OperatorKetQuantumObject <: QuantumObjectType
Abstract type representing a ket state in the super-operator formalism ``|\rho\rangle\rangle``.
"""
abstract type OperatorKetQuantumObject <: QuantumObjectType end

@doc raw"""
mutable struct QuantumObject{MT<:AbstractArray,ObjType<:QuantumObjectType}
data::MT
Expand Down Expand Up @@ -134,6 +148,20 @@ Checks if the [`QuantumObject`](@ref) `A` is a [`OperatorQuantumObject`](@ref) s
"""
isoper(A::QuantumObject{<:AbstractArray{T},OpType}) where {T,OpType<:QuantumObjectType} = A.type <: OperatorQuantumObject

"""
isoperbra(A::QuantumObject)
Checks if the [`QuantumObject`](@ref) `A` is a [`OperatorBraQuantumObject`](@ref) state.
"""
isoperbra(A::QuantumObject{<:AbstractArray{T},OpType}) where {T,OpType<:QuantumObjectType} = A.type <: OperatorBraQuantumObject

"""
isoperket(A::QuantumObject)
Checks if the [`QuantumObject`](@ref) `A` is a [`OperatorKetQuantumObject`](@ref) state.
"""
isoperket(A::QuantumObject{<:AbstractArray{T},OpType}) where {T,OpType<:QuantumObjectType} = A.type <: OperatorKetQuantumObject

"""
issuper(A::QuantumObject)
Expand Down Expand Up @@ -213,7 +241,7 @@ LinearAlgebra.Hermitian(A::QuantumObject{<:AbstractArray{T},OpType}, uplo::Symbo
QuantumObject(Hermitian(A.data, uplo), A.type, A.dims)

function Base.show(io::IO, ::MIME"text/plain", QO::QuantumObject{<:AbstractArray{T},OpType}) where
{T,OpType<:Union{BraQuantumObject,KetQuantumObject,SuperOperatorQuantumObject}}
{T,OpType<:Union{BraQuantumObject,KetQuantumObject,OperatorBraQuantumObject,OperatorKetQuantumObject,SuperOperatorQuantumObject}}

op_data = QO.data
op_dims = QO.dims
Expand All @@ -222,6 +250,10 @@ function Base.show(io::IO, ::MIME"text/plain", QO::QuantumObject{<:AbstractArray
op_type = "Ket"
elseif op_type <: BraQuantumObject
op_type = "Bra"
elseif op_type <: OperatorKetQuantumObject
op_type = "Operator-Ket"
elseif op_type <: OperatorBraQuantumObject
op_type = "Operator-Bra"
else
op_type = "SuperOperator"
end
Expand Down

0 comments on commit 8994e7d

Please sign in to comment.