Skip to content

Commit f71e3b3

Browse files
committed
Updated map, pw_map tests
1 parent f17b50a commit f71e3b3

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

sbg/pw_map.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,12 @@ PWMap<Set> PWMap<Set>::minMap(const PWMap &other) const
514514
if (isEmpty() || other.isEmpty())
515515
return PWMap();
516516

517+
PWMap aux1 = restrict(other.dom()), aux2 = other.restrict(dom());
517518
Set zero(SetPiece(arity(), Interval(0, 1, 0)));
518-
Set to_zero = (*this-other).preImage(zero);
519-
Set not_zero = other.dom().difference(to_zero);
520-
PWMap aux1 = restrict(to_zero), aux2 = other.restrict(not_zero);
519+
Set to_zero = (aux1-aux2).preImage(zero);
520+
Set not_zero = aux2.dom().difference(to_zero);
521+
aux1 = aux1.restrict(to_zero);
522+
aux2 = aux2.restrict(not_zero);
521523

522524
return aux1.combine(aux2);
523525
}

test/eval/eval_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TEST_P(EvalTests, Eval)
4747

4848
// @todo Restore both tests when fixed:
4949
// "map", "pw_map". See #iss-27
50-
const char* eval_program[] = {"arithmetic", "interval", "set", "lexp"};
50+
const char* eval_program[] = {"arithmetic", "interval", "set", "lexp", "map", "pw_map"};
5151

5252
INSTANTIATE_TEST_SUITE_P(EvalInst, EvalTests, testing::ValuesIn(eval_program));
5353

test/eval/gt_data/map/SBG.log

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Parsing succeeded
55
-------------------------
66

77
{[1:1:10]} ↦ (1)x+0
8-
--> {[1:10]} x
8+
--> {[1:10]} -> x
99

1010
{[1:2:10]} ↦ ((1/2))x+(1/2)
11-
--> {[1:2:9]} x/2+1/2
11+
--> {[1:2:9]} -> x/2+1/2
1212

1313
image({[1:1:10]} ↦ (1)x+0)
1414
--> {[1:10]}
@@ -26,5 +26,8 @@ preImage({[1:2:50]} ↦ (2)x+1)
2626
--> {[1:2:49]}
2727

2828
preImage({[20:5:100], [200:2:300]} ↦ (2)x+1)
29-
--> {[20:5:100], [200:2:300]}
29+
--> {[200:2:300], [20:5:100]}
30+
31+
preImage({[3:1:3]}, {[50:1:100], [200:1:300]} ↦ (0)x+3)
32+
--> {[50:100], [200:300]}
3033

test/eval/gt_data/pw_map/SBG.log

+16-13
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ Parsing succeeded
88
--> <<>>
99

1010
<<{[1:1:10], [100:10:200]} ↦ (1)x+-3>>
11-
--> <<{[1:10], [100:10:200]} x-3>>
11+
--> <<{[100:10:200], [1:10]} -> x-3>>
1212

1313
<<{[1:1:10], [100:10:200]} ↦ (1)x+-3, {[500:1:600]} ↦ (1)x+5>>
14-
--> <<{[1:10], [100:10:200]} x-3, {[500:600]} x+5>>
14+
--> <<{[100:10:200], [1:10]} -> x-3, {[500:600]} -> x+5>>
1515

1616
minMap(<<{[1:1:10], [15:3:30]} ↦ (1)x+0, {[12:3:12], [50:5:100]} ↦ (1)x+1>>, <<{[1:2:20], [30:5:60]} ↦ (0)x+100, {[75:5:90], [95:1:100]} ↦ (1)x+0>>)
17-
--> <<{[100:100]} ↦ x, {[95:95]} ↦ x, {[75:5:90]} x, {[50:5:60]} x+1, {[30:30]} ↦ x, {[15:15]} ↦ x, {[1:2:9]} x>>
17+
--> <<{[15:15], [30:30], [1:2:9]} -> x, {[50:5:60]} -> x+1, {[95:5:100], [75:5:90]} -> x>>
1818

1919
reduce(<<{[100:1:200]} ↦ (1)x+-1>>)
20-
--> <<{[100:200]} 99>>
20+
--> <<{[100:200]} -> 99>>
2121

2222
firstInv(<<{[1:1:10]} ↦ (0)x+10>>)
23-
--> <<{[10:10]} ↦ 1>>
23+
--> <<{[10:10]} -> 1>>
24+
25+
mapInf(<<{[50:1:50]} ↦ (1)x+-49, {[49:1:49]} ↦ (1)x+-48, {[3:1:48]} ↦ (1)x+1>>)
26+
--> <<>>
2427

2528
-------------------------
2629
Parsing succeeded
@@ -32,22 +35,22 @@ Parsing succeeded
3235
--> <<>>
3336

3437
<<{[1:1:10] x [1:1:10], [100:10:1000] x [100:10:1000]} ↦ (1)x+0|(2)x+1, {[100:3:199] x [300:5:400]} ↦ (1)x+0|(1)x+0>>
35-
--> <<{[1:10]x[1:10], [100:10:1000]x[100:10:1000]} x|2x+1, {[100:3:199]x[300:5:400]} x|x>>
38+
--> <<{[100:10:1000]x[100:10:1000], [1:10]x[1:10]} -> x|2x+1, {[100:3:199]x[300:5:400]} -> x|x>>
3639

3740
<<{[1:1:5] x [1:1:5], [10:1:15] x [10:1:15]} ↦ (1)x+0|(1)x+0, {[20:3:30] x [20:3:30], [45:5:50] x [45:5:50]} ↦ (2)x+0|(2)x+0>>
38-
--> <<{[1:5]x[1:5], [10:15]x[10:15]} x|x, {[20:3:29]x[20:3:29], [45:5:50]x[45:5:50]} 2x|2x>>
41+
--> <<{[10:15]x[10:15], [1:5]x[1:5]} -> x|x, {[45:5:50]x[45:5:50], [20:3:29]x[20:3:29]} -> 2x|2x>>
3942

4043
image({[1:1:5] x [1:1:5], [10:1:15] x [10:1:15], [20:3:30] x [35:5:100], [45:5:50] x [45:5:50]}, <<{[1:1:5] x [1:1:5], [10:1:15] x [10:1:15]} ↦ (1)x+0|(1)x+0, {[20:3:30] x [20:3:30], [45:5:50] x [45:5:50]} ↦ (2)x+0|(2)x+0>>)
41-
--> {[1:5]x[1:5], [90:10:100]x[90:10:100], [10:15]x[10:15]}
44+
--> {[90:10:100]x[90:10:100], [1:5]x[1:5], [10:15]x[10:15]}
4245

4346
preImage({[0:1:25] x [0:1:25]}, <<{[1:1:10] x [1:1:10], [20:5:30] x [20:5:30]} ↦ (0)x+3|(0)x+4, {[11:1:14] x [11:1:14], [1:1:10] x [50:5:70]} ↦ (2)x+0|(2)x+1>>)
44-
--> {[1:10]x[1:10], [20:5:30]x[20:5:30], [11:12]x[11:12]}
47+
--> {[11:12]x[11:12], [20:5:30]x[20:5:30], [1:10]x[1:10]}
4548

4649
compose(<<{[1:1:10] x [1:1:5], [20:2:30] x [20:2:30]} ↦ (2)x+1|(3)x+0, {[15:3:18] x [12:3:18]} ↦ (0)x+0|(0)x+0>>, <<{[1:1:30] x [1:1:30]} ↦ (1)x+1|(1)x+2>>)
47-
--> <<{[1:9]x[1:3], [19:2:29]x[18:2:28]} 2x+3|3x+6, {[14:3:17]x[10:3:16]} 0|0>>
50+
--> <<{[1:9]x[1:3], [19:2:29]x[18:2:28]} -> 2x+3|3x+6, {[14:3:17]x[10:3:16]} -> 0|0>>
4851

4952
minAdj(<<{[10:1:100] x [10:1:100], [101:2:200] x [101:2:200]} ↦ (1)x+0|(1)x+0, {[10:1:100] x [101:2:200]} ↦ (2)x+0|(2)x+0>>, <<{[5:5:50] x [5:5:50]} ↦ (0)x+1|(1)x+0, {[51:3:80] x [51:3:80], [90:1:150] x [95:1:150]} ↦ (2)x+3|(2)x+1>>)
50-
--> <<{[101:2:149]x[101:2:149]} ↦ 2x+3|2x+1, {[90:100]x[95:100]} 2x+3|2x+1, {[180:2:200]x[202:4:298]} x+3|x+1, {[10:5:50]x[10:5:50]} ↦ 1|x, {[51:3:78]x[51:3:78]} ↦ 2x+3|2x+1>>
53+
--> <<{[10:5:50]x[10:5:50]} -> 1|x, {[101:2:149]x[101:2:149], [51:3:78]x[51:3:78], [90:100]x[95:100]} -> 2x+3|2x+1, {[180:2:200]x[202:4:298]} -> x+3|x+1>>
5154

5255
-------------------------
5356
Parsing succeeded
@@ -59,8 +62,8 @@ Parsing succeeded
5962
--> <<>>
6063

6164
combine(<<{[1:1:10] x [1:1:10] x [1:1:10], [1:1:10] x [20:3:30] x [20:3:30]} ↦ (1)x+0|(1)x+0|(1)x+0, {[1:1:10] x [20:3:30] x [35:5:50], [35:5:50] x [35:5:50] x [20:3:30]} ↦ (3)x+0|(3)x+0|(1)x+1>>, <<{[1:1:20] x [1:1:20] x [1:1:20]} ↦ (1)x+1|(1)x+0|(1)x+0>>)
62-
--> <<{[1:10]x[1:10]x[1:10], [1:10]x[20:3:29]x[20:3:29]} x|x|x, {[1:10]x[20:3:29]x[35:5:50], [35:5:50]x[35:5:50]x[20:3:29]} 3x|3x|x+1, {[1:10]x[1:10]x[11:20], [1:10]x[20:20]x[1:19], [11:20]x[1:20]x[1:20], [1:10]x[11:19]x[1:20]} x+1|x|x>>
65+
--> <<{[1:10]x[20:3:29]x[20:3:29], [1:10]x[1:10]x[1:10]} -> x|x|x, {[35:5:50]x[35:5:50]x[20:3:29], [1:10]x[20:3:29]x[35:5:50]} -> 3x|3x|x+1, {[1:10]x[11:19]x[1:20], [1:10]x[20:20]x[1:19], [1:10]x[1:10]x[11:20], [11:20]x[1:20]x[1:20]} -> x+1|x|x>>
6366

6467
reduce(<<{[4:1:15] x [4:1:15] x [4:1:15], [4:1:15] x [20:2:25] x [4:1:15]} ↦ (1)x+0|(1)x+-3|(3)x+0, {[4:1:15] x [15:5:50] x [20:2:25], [20:2:25] x [40:5:45] x [40:5:45]} ↦ (2)x+0|(1)x+0|(4)x+4>>)
65-
--> <<{[4:15]x[4:15]x[4:15], [4:15]x[20:2:24]x[4:15]} x|x-3|3x, {[4:15]x[15:5:50]x[20:2:24], [20:2:24]x[40:5:45]x[40:5:45]} 2x|x|4x+4>>
68+
--> <<{[4:15]x[4:15]x[4:15], [4:15]x[20:2:24]x[4:15]} -> x|x-3|3x, {[4:15]x[15:5:50]x[20:2:24], [20:2:24]x[40:5:45]x[40:5:45]} -> 2x|x|4x+4>>
6669

0 commit comments

Comments
 (0)