Skip to content

Commit 861b987

Browse files
committed
Fix multiplication with empty monomial
1 parent 48ca654 commit 861b987

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ncmult.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ function multiplyvar(v::Vector{PolyVar{false}}, z::Vector{Int}, x::PolyVar{false
1111
while i > 0 && z[i] == 0
1212
i -= 1
1313
end
14-
if v[i] == x
14+
if i > 0 && v[i] == x
1515
multiplyexistingvar(v, x, i)
1616
else
1717
# ---->
1818
# \ |\ |\
1919
# \ | \ | \
2020
# \| \| \
21-
# If z[i] > x, we wait either for a rise (v[i] > v[i-1]) or v[i] < x
21+
# If v[i] > x, we wait either for a rise (v[i] > v[i-1]) or v[i] < x
2222
# Otherwise, we first wait for a drop and then wait for the same thing
2323
ndrop = 0
24-
if v[i] > x
24+
if i > 0 && v[i] > x
2525
droplim1 = 0
2626
droplim2 = 1
2727
else
@@ -51,7 +51,7 @@ function multiplyvar(x::PolyVar{false}, v::Vector{PolyVar{false}}, z::Vector{Int
5151
while i <= length(v) && z[i] == 0
5252
i += 1
5353
end
54-
if v[i] == x
54+
if i <= length(v) && v[i] == x
5555
multiplyexistingvar(v, x, i)
5656
else
5757
# <----
@@ -61,7 +61,7 @@ function multiplyvar(x::PolyVar{false}, v::Vector{PolyVar{false}}, z::Vector{Int
6161
# If z[i] < x, we wait either for a drop (v[i] < v[i+1]) or v[i] > x
6262
# Otherwise, we first wait for a drop and then wait for the same thing
6363
ndrop = 0
64-
if v[i] < x
64+
if i <= length(v) && v[i] < x
6565
droplim1 = 0
6666
droplim2 = 1
6767
else

0 commit comments

Comments
 (0)