Skip to content

Commit

Permalink
Update Mul constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenszhu committed Jun 19, 2024
1 parent 94f7ef1 commit cc67894
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,18 @@ function _Add(::Type{T}, coeff, dict; kwargs...) where {T}
BasicSymbolic{T}(; impl, kwargs...)
end

function Mul(T, a, b; metadata=NO_METADATA, kw...)
isempty(b) && return a
if _isone(a) && length(b) == 1
pair = first(b)
function _Mul(::Type{T}, coeff, dict; kwargs...) where {T}
isempty(dict) && return coeff
if _isone(coeff) && length(dict) == 1
pair = first(dict)
if _isone(last(pair)) # first value
return first(pair)
else
return unstable_pow(first(pair), last(pair))
end
else
coeff = a
dict = b
Mul{T}(; coeff, dict, hash=Ref(UInt(0)), metadata, arguments=[], issorted=RefValue(false), kw...)
end
impl = Mul(; coeff, dict)
BasicSymbolic{T}(; impl, kwargs...)
end

const Rat = Union{Rational, Integer}
Expand Down

0 comments on commit cc67894

Please sign in to comment.