Skip to content

Commit ef00c1c

Browse files
committed
Call BasicSymbolic arithmetic operations to construct similarterm
1 parent 6964c76 commit ef00c1c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/types.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,12 @@ function TermInterface.similarterm(t::Type{<:BasicSymbolic{<:Number}}, f, args,
535535
if T === nothing
536536
T = _promote_symtype(f, args)
537537
end
538-
if f === (+)
539-
Add(T, makeadd(1, 0, args...)...; metadata=metadata)
540-
elseif f == (*)
541-
Mul(T, makemul(1, args...)...; metadata=metadata)
542-
elseif f == (/)
543-
@assert length(args) == 2
544-
Div{T}(args...; metadata=metadata)
545-
elseif f == (^) && length(args) == 2
546-
Pow{T}(makepow(args...)...; metadata=metadata)
538+
if f in (+, *) || (f in (/, ^) && length(args) == 2)
539+
res = f(args...)
540+
if res isa Symbolic
541+
@set! res.metadata = metadata
542+
end
543+
return res
547544
else
548545
Term{T}(f, args, metadata=metadata)
549546
end

0 commit comments

Comments
 (0)