Skip to content

Commit 0dcf892

Browse files
authored
Merge pull request #3952 from JuliaReach/schillic/sspz_tests
Revise tests for `SimpleSparsePolynomialZonotope`
2 parents 3a062c7 + d88963c commit 0dcf892

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

test/Sets/SimpleSparsePolynomialZonotope.jl

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ for N in @tN([Float64, Float32, Rational{Int}])
4646
@test genmat(LMS) == N[5 6; 11 14]
4747
@test expmat(LMS) == expmat(S)
4848

49-
LMS2 = linear_map(N[1//2 0; 0 1//2], S)
50-
@test center(LMS2) == N[1, 0]
51-
@test genmat(LMS2) == N[0.5 1; 1 1]
52-
@test expmat(LMS2) == expmat(LMS2)
53-
5449
MSS = minkowski_sum(S, S)
5550
@test center(MSS) == N[4, 0]
5651
@test genmat(MSS) == N[1 2 1 2; 2 2 2 2.0]
@@ -61,33 +56,30 @@ for N in @tN([Float64, Float32, Rational{Int}])
6156
@test genmat(CPS) == N[1 2 0 0; 2 2 0 0; 0 0 1 2; 0 0 2 2.0]
6257
@test expmat(CPS) == [1 4 0 0; 1 2 0 0; 0 0 1 4; 0 0 1 2]
6358
Z = overapproximate(S, Zonotope)
64-
PZZ = cartesian_product(S, Z)
65-
@test center(PZZ) == vcat(center(S), center(Z))
66-
@test genmat_dep(PZZ) == vcat(genmat_dep(S), zeros(N, 2, 2))
67-
@test genmat_indep(PZZ) == vcat(zeros(N, 2, 2), genmat(Z))
68-
@test expmat(PZZ) == expmat(S)
69-
70-
_c = N[2, 0]
71-
_g = N[0 0.5 1 0.5 1 0.5 1 -0.5 -1
72-
0 1 1 1 1 1 1 -1 -1]
73-
74-
_e = [0 1 4 1 4 0 0 0 0
75-
0 1 2 1 2 0 0 0 0
76-
0 0 0 0 0 1 4 1 4
77-
0 0 0 0 0 1 2 1 2
78-
1 0 0 1 1 0 0 1 1]
59+
CPS = cartesian_product(S, Z)
60+
@test center(CPS) == vcat(center(S), center(Z))
61+
@test genmat_dep(CPS) == vcat(genmat_dep(S), zeros(N, 2, 2))
62+
@test genmat_indep(CPS) == vcat(zeros(N, 2, 2), genmat(Z))
63+
@test expmat(CPS) == expmat(S)
7964

80-
LCS = linear_combination(S, S)
65+
c = N[2, 0]
66+
G = N[0 0.5 1 0.5 1 0.5 1 -0.5 -1
67+
0 1 1 1 1 1 1 -1 -1]
68+
E = [0 1 4 1 4 0 0 0 0
69+
0 1 2 1 2 0 0 0 0
70+
0 0 0 0 0 1 4 1 4
71+
0 0 0 0 0 1 2 1 2
72+
1 0 0 1 1 0 0 1 1]
8173

82-
@test center(LCS) == _c
83-
@test genmat(LCS) == _g
84-
@test expmat(LCS) == _e
74+
LCS = linear_combination(S, S)
75+
@test center(LCS) == c
76+
@test genmat(LCS) == G
77+
@test expmat(LCS) == E
8578

8679
CH1 = convex_hull(S)
87-
88-
@test center(CH1) == _c
89-
@test genmat(CH1) == _g
90-
@test expmat(CH1) == _e
80+
@test center(CH1) == c
81+
@test genmat(CH1) == G
82+
@test expmat(CH1) == E
9183

9284
# convex hull with itself
9385
CH2 = convex_hull(S, S)
@@ -102,20 +94,16 @@ for N in @tN([Float64, Float32, Rational{Int}])
10294
q1 = quadratic_map(Q, S2)
10395
@test concretize(QuadraticMap(Q, S2)) == q1
10496
q2 = quadratic_map(Q, S2, S2)
105-
10697
@test center(q1) == center(q2) N[-6 // 25, -52 // 125]
10798
@test genmat(q1) genmat(q2) N[-6//5 4//25 0 4//5;
10899
-272//100 192//1000 -16//5 96//100]
109-
110100
@test expmat(q1) == expmat(q2) == [1 0 2 1;
111101
0 1 0 1]
112102

113103
c = N[1, 2, 3]
114-
115104
G = N[0 1 4 7 10 13 16
116105
0 2 5 8 11 14 17
117106
0 3 6 9 12 15 18]
118-
119107
E = [1 4 1 3 0 3 7
120108
2 5 2 4 0 4 8
121109
3 6 3 5 0 5 9]

0 commit comments

Comments
 (0)