1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) ????-2008 - INRIA
//
// This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- JVM NOT MANDATORY -->
[v,ka,kb] = intersect([],[]);
if v <> [] then bugmes();quit;end
if ka <> [] then bugmes();quit;end
if kb <> [] then bugmes();quit;end
[v,ka,kb] = intersect([1 2],[3 4]);
if v <> [] then bugmes();quit;end
if ka <> [] then bugmes();quit;end
if kb <> [] then bugmes();quit;end
A = [ 1 8 4 5 2 1];
B = [ 9 7 4 2 1 4];
[v,ka,kb] = intersect(A,B);
if or(A(ka) <> B(kb)) then bugmes();quit;end
if or(A(ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B)) then bugmes();quit;end
if (or(v<>[1,2,4])) then bugmes();quit;end
A = 'a'+string(A);
B = 'b'+string(B);
[v,ka,kb] = intersect(A,B);
if or(A(ka) <> B(kb)) then bugmes();quit;end
if or(A(ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B)) then bugmes();quit;end
if v <> [] then bugmes();quit;end
A = [ "elt1" "elt3" "elt4"];
B = [ "elt5" "elt1" "elt3"];
[v, ka, kb] = intersect(A,B);
if or(A(ka) <> B(kb)) then bugmes();quit;end
if or(A(ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B)) then bugmes();quit;end
if (or(v<>["elt1","elt3"])) then bugmes();quit;end
A = [ "elt1" "elt3" "elt4"];
B = [ "elt5" "elt6" "elt2" "elt1" "elt3"];
[v, ka, kb] = intersect(A,B);
if or(A(ka) <> B(kb)) then bugmes();quit;end
if or(A(ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B)) then bugmes();quit;end
if (or(v<>["elt1","elt3"])) then bugmes();quit;end
//with integers
A = int16([ 1 8 4 5 2 1]);
B = int16([ 9 7 4 2 1 4]);
[v, ka, kb]=intersect(A,B);
if or(A(ka) <> B(kb)) then bugmes();quit;end
if or(A(ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B)) then bugmes();quit;end
if (or(v<>int16([1,2,4]))) then bugmes();quit;end
A = uint8([ 1 8 4 5 2 1]);
B = uint8([ 9 7 4 2 1 4]);
[v, ka, kb]=intersect(A,B);
if or(A(ka) <> B(kb)) then bugmes();quit;end
if or(A(ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B)) then bugmes();quit;end
if (or(v<>uint8([1,2,4]))) then bugmes();quit;end
//with matrices
A = [0,0,1,1 1;
0,1,1,1,1;
2,0,1,1,1;
0,2,2,2,2;
2,0,1,1,1;
0,0,1,1,3];
B = [1,0,1;
1,0,2;
1,2,3;
2,0,4;
1,2,5;
3,0,6];
[v,ka,kb] = intersect(A,B,'c');
if or(A(:,ka) <> B(:,kb)) then bugmes();quit;end
if or(A(:,ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B,'c')) then bugmes();quit;end
if (or(v<>[0,1;0,1;2,1;0,2;2,1;0,3])) then bugmes();quit;end
A=A';B=B';
[v,ka,kb] = intersect(A,B,'r');
if or(A(ka,:) <> B(kb,:)) then bugmes();quit;end
if or(A(ka,:) <> v) then bugmes();quit;end
if or(v<>intersect(A,B,'r')) then bugmes();quit;end
if (or(v<>[0,0,2,0,2,0;1,1,1,2,1,3])) then bugmes();quit;end
A=uint32(A);B=uint32(B);
[v,ka,kb] = intersect(A,B,'r');
if or(A(ka,:) <> B(kb,:)) then bugmes();quit;end
if or(A(ka,:) <> v) then bugmes();quit;end
if or(v<>intersect(A,B,'r')) then bugmes();quit;end
if (or(v<>uint32([0,0,2,0,2,0;1,1,1,2,1,3]))) then bugmes();quit;end
//with Nan
A = [0,0,1,1 1;
0,1,1,1,1;
2,0,1,1,1;
0,2,2,2,2;
2,0,1,1,1;
0,0,1,1,%nan];
B = [1,0,1;
1,0,2;
1,2,3;
2,0,4;
1,2,5;
%nan,0,6];
[v,ka,kb] = intersect(A,B,'c');
if or(A(:,ka) <> B(:,kb)) then bugmes();quit;end
if or(A(:,ka) <> v) then bugmes();quit;end
if or(v<>intersect(A,B,'c')) then bugmes();quit;end
if (or(v<>[0;0;2;0;2;0])) then bugmes();quit;end
// =============================================================================
|