Skip to content

Commit a05ad25

Browse files
committed
Add one missing case in complete alias generation
1 parent 00590bf commit a05ad25

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/systems/alias_elimination.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,17 +708,27 @@ function alias_eliminate_graph!(graph, var_to_diff, mm_orig::SparseMatrixCLIL)
708708
prev_r = -1
709709
for _ in 1:10_000 # just to make sure that we don't stuck in an infinite loop
710710
reach₌ = Pair{Int, Int}[]
711+
# `r` is aliased to its equality aliases
711712
r === nothing || for n in neighbors(eqg, r)
712713
(n == r || is_diff_edge(r, n)) && continue
713714
c = get_weight(eqg, r, n)
714715
push!(reach₌, c => n)
715716
end
717+
# `r` is aliased to its previous differentiation level's aliases'
718+
# derivative
716719
if (n = length(diff_aliases)) >= 1
717720
as = diff_aliases[n]
718721
for (c, a) in as
719722
(da = var_to_diff[a]) === nothing && continue
720723
da === r && continue
721724
push!(reach₌, c => da)
725+
# `r` is aliased to its previous differentiation level's
726+
# aliases' derivative's equality aliases
727+
for n in neighbors(eqg, da)
728+
(n == da || n == r || is_diff_edge(r, n)) && continue
729+
c′ = get_weight(eqg, da, n)
730+
push!(reach₌, c * c′ => n)
731+
end
722732
end
723733
end
724734
if r === nothing

0 commit comments

Comments
 (0)