Skip to content

Commit

Permalink
commutativity adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
apkille committed Jun 17, 2024
1 parent d90092f commit 26d6653
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/QSymbolicsBase/QSymbolicsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,23 @@ const SymQObj = Symbolic{<:QObj} # TODO Should we use Sym or Symbolic... Sym has
Base.:(-)(x::SymQObj) = (-1)*x
Base.:(-)(x::SymQObj,y::SymQObj) = x + (-y)

function _in(x::SymQObj, y::SymQObj)
for i in arguments(y)
if isequal(x, i)
return true
end
end
false
end
function Base.isequal(x::X,y::Y) where {X<:Union{SymQObj, Symbolic{Complex}}, Y<:Union{SymQObj, Symbolic{Complex}}}
if X==Y
if isexpr(x)
if operation(x)==operation(y)
ax,ay = arguments(x),arguments(y)
if operation(x) === :+
Set(ax) == Set(ay)
if (operation(x) === +) && (length(ax) == length(ay))
all(x -> _in(x, y), ax)
else
(length(ax) == length(ay)) && all(zip(ax,ay)) do xy isequal(xy...) end
all(zip(ax,ay)) do xy isequal(xy...) end
end
else
false
Expand Down

0 comments on commit 26d6653

Please sign in to comment.