comparison scripts/set/union.m @ 29192:547fc7f033da

maint: merge stable to default.
author Rik <rik@octave.org>
date Thu, 17 Dec 2020 14:24:15 -0800
parents b73a54c31152 7f11d59e3af8
children 7854d5752dd2
comparison
equal deleted inserted replaced
29188:ed1a8af4242f 29192:547fc7f033da
165 %! [c, ia, ib] = union (a,b, "legacy"); 165 %! [c, ia, ib] = union (a,b, "legacy");
166 %! assert (c, [1, 3, 5, 7]); 166 %! assert (c, [1, 3, 5, 7]);
167 %! assert (ia, [1, 2]); 167 %! assert (ia, [1, 2]);
168 %! assert (ib, [3, 1]); 168 %! assert (ib, [3, 1]);
169 169
170 %!test # "legacy" + "rows"
171 %! A = [1 2; 3 4; 5 6; 3 4; 7 8];
172 %! B = [3 4; 7 8; 9 10];
173 %! [c, ia, ib] = union (A, B, "rows");
174 %! assert (c, [1, 2; 3, 4; 5, 6; 7, 8; 9, 10]);
175 %! assert (ia, [1; 2; 3; 5]);
176 %! assert (ib, [3]);
177 %! [c, ia, ib] = union (A, B, "rows", "legacy");
178 %! assert (c, [1, 2; 3, 4; 5, 6; 7, 8; 9, 10]);
179 %! assert (ia, [1; 3]);
180 %! assert (ib, [1; 2; 3]);
181
170 ## Test orientation of output 182 ## Test orientation of output
171 %!shared x,y 183 %!shared x,y
172 %! x = 1:3; 184 %! x = 1:3;
173 %! y = 2:5; 185 %! y = 2:5;
174 186
175 %!assert (size (union (x, y)), [1 5]) 187 %!assert (size (union (x, y)), [1 5])
176 %!assert (size (union (x', y)), [5 1]) 188 %!assert (size (union (x', y)), [5 1])
177 %!assert (size (union (x, y')), [5 1]) 189 %!assert (size (union (x, y')), [5 1])
178 %!assert (size (union (x', y')), [5 1]) 190 %!assert (size (union (x', y')), [5 1])
191 %!assert (size (union (x, y, "legacy")), [1, 5])
192 %!assert (size (union (x', y, "legacy")), [1, 5])
193 %!assert (size (union (x, y', "legacy")), [1, 5])
194 %!assert (size (union (x', y', "legacy")), [5, 1])
179 195
180 ## Clear shared variables 196 ## Clear shared variables
181 %!shared 197 %!shared
182 198
183 ## Test empty cell string array unions 199 ## Test empty cell string array unions