Skip to content

Commit

Permalink
add SymbolicsUtils.expand function for QAdd (#205)
Browse files Browse the repository at this point in the history
* add SymbolicsUtils.expand function for QAdd

* define Symbolics.expand for QNumber
  • Loading branch information
oameye authored Jul 1, 2024
1 parent 91053b3 commit 1cfc729
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/qnumber.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ SymbolicUtils.promote_symtype(f,T::Type{<:QNumber},S::Type{<:QNumber}) = promote

SymbolicUtils.symtype(x::T) where T<:QNumber = T

# Standard simplify
# Standard simplify and expand functions
function SymbolicUtils.simplify(x::QNumber;kwargs...)
avg = average(x)
avg_ = SymbolicUtils.simplify(avg;kwargs...)
return undo_average(avg_)
end

function Symbolics.expand(x::QNumber;kwargs...)
expansion = average(x)
expansion_ = SymbolicUtils.expand(expansion; kwargs...)
return undo_average(expansion_)
end

## End of interface

## Methods
Expand Down

0 comments on commit 1cfc729

Please sign in to comment.