Skip to content

Commit 9687cb9

Browse files
committed
Fix lss in the trivial case
1 parent c87aaad commit 9687cb9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/systems/alias_elimination.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,9 @@ function locally_structure_simplify!(adj_row, pivot_var, ag)
772772
iszero(pivot_val) && return false
773773

774774
nirreducible = 0
775-
alias_candidate::Pair{Int, Int} = 0 => 0
775+
# When this row only as the pivot element, the pivot is zero by homogeneity
776+
# of the linear system.
777+
alias_candidate::Union{Int, Pair{Int, Int}} = 0
776778

777779
# N.B.: Assumes that the non-zeros iterator is robust to modification
778780
# of the underlying array datastructure.
@@ -823,8 +825,10 @@ function locally_structure_simplify!(adj_row, pivot_var, ag)
823825
# v * p + c * a = 0
824826
# v * p = -c * a
825827
# p = -(c / v) * a
826-
d, r = divrem(alias_val, pivot_val)
827-
if r == 0 && (d == 1 || d == -1)
828+
if iszero(alias_val)
829+
alias_candidate = 0
830+
elseif r == 0 && (d == 1 || d == -1)
831+
d, r = divrem(alias_val, pivot_val)
828832
alias_candidate = -d => alias_var
829833
else
830834
return false

0 commit comments

Comments
 (0)