@@ -548,7 +548,8 @@ function aag_bareiss!(graph, var_to_diff, mm_orig::SparseMatrixCLIL{T, Ti}) wher
548
548
is_linear_variables = is_algebraic .(1 : length (var_to_diff))
549
549
for i in 𝑠vertices (graph)
550
550
# only consider linear algebraic equations
551
- (i in linear_equations_set && all (is_algebraic, 𝑠neighbors (graph, i))) && continue
551
+ (i in linear_equations_set && all (is_algebraic, 𝑠neighbors (graph, i))) &&
552
+ continue
552
553
for j in 𝑠neighbors (graph, i)
553
554
is_linear_variables[j] = false
554
555
end
@@ -956,11 +957,14 @@ function alias_eliminate_graph!(state::TransformationState, mm_orig::SparseMatri
956
957
957
958
if needs_update
958
959
mm = reduce! (copy (echelon_mm), mm_orig, ag, size (echelon_mm, 1 ))
959
- for (ei, e) in enumerate (mm. nzrows)
960
- set_neighbors! (graph, e, mm. row_cols[ei])
961
- end
962
- update_graph_neighbors! (graph, ag)
963
960
end
961
+ # applying new `ag` to `mm` might lead to linear dependence, so we have to
962
+ # re-run Bareiss.
963
+ mm, = aag_bareiss! (graph, var_to_diff, mm)
964
+ for (ei, e) in enumerate (mm. nzrows)
965
+ set_neighbors! (graph, e, mm. row_cols[ei])
966
+ end
967
+ update_graph_neighbors! (graph, ag)
964
968
965
969
complete_mm = reduce! (copy (echelon_mm), mm_orig, complete_ag, size (echelon_mm, 1 ))
966
970
return ag, mm, complete_ag, complete_mm
0 commit comments