rbmatlab  1.13.10
 All Classes Namespaces Files Functions Variables Groups Pages
test_xpart_map.m
Go to the documentation of this file.
1 function ok = test_xpart_map
2  % test for the XPartMap class
3  %
4  % This test checks especially the methods
5  % - XPartMap.refine() and
6  % - XPartMap.sub_xpart_map()
7 
8 oned = XPartMap;
9 
10 oned.refine(0);
11 ok = all(oned.intervals == [1 0 1 0 0 0.5 0 0.5 1]);
12 ok = ok & all(oned.leaf_ids == [1 2]);
13 ok = ok & all(oned.leaf_enum == [1 2]);
14 oned.refine([1,2]);
15 ok = ok & all(oned.intervals == [1 0 1 3 0 0.5 5 0.5 1 0 0 0.25 0 0.25 0.5 0 0.5 0.75 0 0.75 1]);
16 ok = ok & all(oned.leaf_ids == [3 5 4 6]);
17 ok = ok & all(oned.leaf_enum == [3 4 5 6]);
18 oned.refine([3,5]);
19 ok = ok & all(oned.intervals == [1 0 1 3 0 0.5 5 0.5 1 7 0 0.25 0 0.25 0.5 9 0.5 0.75 0 0.75 1 0 0 0.125 0 0.125 0.25 0 0.5 0.625 0 0.625 0.75]);
20 ok = ok & all(oned.leaf_ids == [7 9 4 6 8 10]);
21 ok = ok & all(oned.leaf_enum == [7 8 4 9 10 6]);
22 
23 [sxm, old_leaf_enum] = sub_xpart_map(oned, [0.125 0.4]');
24 ok = ok & all(sxm.intervals == [1 0.1250 0.4000 2 0.1250 0.4000 4 0.1250 0.2500 0 0.2500 0.4000 0 0.1250 0.2500]);
25 ok = ok & all(sxm.leaf_ids == [3 4]);
26 ok = ok & all(sxm.leaf_enum == [4 3]);
27 ok = ok & all(sxm.refine_levels == [0 1 2 2 3]);
28 
29 ok = ok & all(old_leaf_enum == [2 3]);
30 
31 end