Skip to content

Commit

Permalink
updating objects
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Jun 13, 2024
1 parent c957db3 commit 893993f
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/QSymbolicsBase/objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct SOperator <: Symbolic{AbstractOperator}
basis::Basis
end
const SymQ = Union{SKet, SBra, SOperator}
istree(::SymQ) = false
isexpr(::SymQ) = false
metadata(::SymQ) = nothing
basis(x::SymQ) = x.basis

Expand All @@ -30,49 +30,42 @@ iscommutative(x::SOperator) = false
@withmetadata struct SInverseOperator <: Symbolic{AbstractOperator}
op::Symbolic{AbstractOperator}
end
istree(::SInverseOperator) = true
isexpr(::SInverseOperator) = true
iscall(::SInverseOperator) = true
arguments(x::SInverseOperator) = [x.op]
operation(x::SInverseOperator) = inverse
head(x::SInverseOperator) = :inverse
children(x::SInverseOperator) = [:inverse, x.op]
basis(x::SInverseOperator) = basis(x.op)
Base.show(io::IO, x::SInverseOperator) = print(io, "$(x.op)⁻¹")
operation(x::SInverseOperator) = inverse
exprhead(x::SInverseOperator) = :inverse
inverse(x::Symbolic{AbstractOperator}) = SInverseOperator(x)

"""Hermitian Operator"""
@withmetadata struct SHermitianOperator <: Symbolic{AbstractOperator}
op::Symbolic{AbstractOperator}
end
istree(::SHermitianOperator) = false
arguments(x::SHermitianOperator) = [x.op]
isexpr(::SHermitianOperator) = false
basis(x::SHermitianOperator) = basis(x.op)
Base.show(io::IO, x::SHermitianOperator) = print(io, "$(x.op)")
operation(x::SHermitianOperator) = hermitian
exprhead(x::SHermitianOperator) = :hermitian
hermitian(x::Symbolic{AbstractOperator}) = SHermitianOperator(x)
ishermitian(x::SHermitianOperator) = true

"""Unitary Operator"""
@withmetadata struct SUnitaryOperator <: Symbolic{AbstractOperator}
op::Symbolic{AbstractOperator}
end
istree(::SUnitaryOperator) = false
arguments(x::SUnitaryOperator) = [x.op]
isexpr(::SUnitaryOperator) = false
basis(x::SUnitaryOperator) = basis(x.op)
Base.show(io::IO, x::SUnitaryOperator) = print(io, "$(x.op)")
operation(x::SUnitaryOperator) = unitary
exprhead(x::SUnitaryOperator) = :unitary
unitary(x::Symbolic{AbstractOperator}) = SUnitaryOperator(x)
isunitary(x::SUnitaryOperator) = true

"""Commutative Operator"""
@withmetadata struct SCommutativeOperator <: Symbolic{AbstractOperator}
op::Symbolic{AbstractOperator}
end
istree(::SCommutativeOperator) = false
arguments(x::SCommutativeOperator) = [x.op]
isexpr(::SCommutativeOperator) = false
basis(x::SCommutativeOperator) = basis(x.op)
Base.show(io::IO, x::SCommutativeOperator) = print(io, "$(x.op)")
operation(x::SCommutativeOperator) = commutative
exprhead(x::SCommutativeOperator) = :commutative
commutative(x::Symbolic{AbstractOperator}) = SCommutativeOperator(x)
iscommutative(x::SCommutativeOperator) = true

0 comments on commit 893993f

Please sign in to comment.