Skip to content

Commit ba22d8e

Browse files
committed
Add TermCombination overloads
1 parent 39506eb commit ba22d8e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/direct.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ let
164164
u = map(value, u)
165165
idx(i) = TermCombination(Set([Dict(i=>1)]))
166166
dict = Dict(u .=> idx.(1:length(u)))
167-
found = []
168167
f = Rewriters.Prewalk(x->haskey(dict, x) ? dict[x] : x)(f)
169-
_sparse(linearity_propagator(f), length(u))
168+
lp = linearity_propagator(f)
169+
_sparse(lp, length(u))
170170
end
171171
end
172172

src/linearity.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ function Base.:(==)(comb1::TermCombination, comb2::TermCombination)
7878
end
7979
=#
8080

81+
# we don't care about the ordering in this case
82+
SymbolicUtils.:<(comb1::TermCombination, comb2::TermCombination) = true
83+
# to make Mul and Add work
84+
Base.:*(::Number, comb::TermCombination) = comb
85+
Base.:^(comb::TermCombination, ::Number) = comb
8186
function Base.:+(comb1::TermCombination, comb2::TermCombination)
8287
if isone(comb1) && !iszero(comb2)
8388
return comb2

0 commit comments

Comments
 (0)