Skip to content

Commit e5eae15

Browse files
test: test get_new_mm
1 parent 078a26c commit e5eae15

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/runtests.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
11
using StateSelection
2+
import StateSelection as SSel
3+
using SparseArrays
24
using Test
35

46
include("bareiss.jl")
7+
8+
@testset "`get_new_mm`" begin
9+
mm = SSel.CLIL.SparseMatrixCLIL(
10+
[
11+
-1 0 2 0
12+
2 1 2 0
13+
0 0 1 2
14+
]
15+
)
16+
# We're using the first equation to solve for the first variable,
17+
# and removing the last variable (assuming it's torn via some other
18+
# equation)
19+
old_to_new_eq = [0, 2, 3]
20+
old_to_new_var = [0, 1, 2, 0]
21+
aliases = Dict(1 => sparse([0, 0, 2, 0]))
22+
mm2 = SSel.get_new_mm(aliases, old_to_new_eq, old_to_new_var, mm)
23+
# Eq#3 can't be retained, because it depends on variable 4 which isn't an
24+
# integer coefficient linear combination
25+
@test mm2.nzrows == [2]
26+
@test mm2.row_cols == [[1, 2]]
27+
@test mm2.row_vals == [[1, 6]]
28+
@test mm2.ncols == 2
29+
aliases = Dict(1 => sparse([0, 0, 2, 1]))
30+
@test_throws SSel.BadMMAliasError SSel.get_new_mm(aliases, old_to_new_eq, old_to_new_var, mm)
31+
end

0 commit comments

Comments
 (0)