Skip to content

Commit

Permalink
fix SDagger
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Jun 18, 2024
1 parent ac56628 commit f804bf9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/QSymbolicsBase/predefined.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ arguments(x::SDagger) = [x.obj]
operation(x::SDagger) = dagger
head(x::SDagger) = :dagger
children(x::SDagger) = [:dagger, x.obj]
dagger(x::Symbolic{AbstractBra}) = SDagger{AbstractKet}(x)
dagger(x::Symbolic{AbstractKet}) = SDagger{AbstractBra}(x)
dagger(x::Symbolic{AbstractOperator}) = SDagger{AbstractOperator}(x)
dagger(x::SKet) = SBra(x.name, x.basis)
dagger(x::SScaledKet) = SScaledBra(conj(x.coeff), dagger(x.obj))
dagger(x::SAddKet) = SAddBra(Dict(dagger(k)=>v for (k,v) in pairs(x.dict)))
Expand All @@ -282,7 +285,7 @@ dagger(x::SBraKet) = SBraKet(dagger(x.ket), dagger(x.bra))
dagger(x::SOuterKetBra) = SOuterKetBra(dagger(x.bra), dagger(x.ket))
dagger(x::SDagger) = x.obj
basis(x::SDagger) = basis(x.obj)
function Base.show(io::IO, x::SDagger{AbstractOperator})
function Base.show(io::IO, x::SDagger)
print(io,x.obj)
print(io,"")
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_express_opt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ op = N⊗X
@test express(op*state) express(op)*express(state)
@test express(op*state) express(F1Z2)

#state = (3im*(2*dagger(Z1)+dagger(Y1))) * (3im*(2*X1+X2)) TODO predefined daggers and commutators
state = (3im*(2*dagger(Z1)+dagger(Y1))) * (3im*(2*X1+X2))

0 comments on commit f804bf9

Please sign in to comment.