From 7e7a092fbbdc687322981123e944ca403884c3b5 Mon Sep 17 00:00:00 2001 From: Adeline CARNIS Date: Fri, 26 Apr 2013 12:09:47 +0200 Subject: [PATCH] Fix test win64b: test_run('integer', intops') Change-Id: I2dcf30e8a36e6366b68912eee1b16189d4514b02 --- scilab/modules/integer/macros/%i_p_i.sci | 37 +- scilab/modules/integer/macros/%i_p_s.sci | 35 +- .../integer/tests/unit_tests/intops.dia.ref | 864 ++++++++++---------- scilab/modules/integer/tests/unit_tests/intops.tst | 832 ++++++++++--------- 4 files changed, 946 insertions(+), 822 deletions(-) diff --git a/scilab/modules/integer/macros/%i_p_i.sci b/scilab/modules/integer/macros/%i_p_i.sci index c52f66f..ccd0a47 100644 --- a/scilab/modules/integer/macros/%i_p_i.sci +++ b/scilab/modules/integer/macros/%i_p_i.sci @@ -9,23 +9,24 @@ function r=%i_p_i(a,n) -if or(n<0) then - r=double(a)^n -else - if size(a,'*')==1 then - r=iconvert(double(a)^double(n),inttype(a)) - else - if size(n,'*')<>1 then - error(43) + if or(n<0) then + r=double(a)^n else - n=double(n) - r=a - if size(a,1)==size(a,2) then - for i=2:n,r=r*a,end - else - for i=2:n,r=r.*a,end - end - end - end -end + if size(a,'*')==1 then + r=iconvert(double(a)^double(n),inttype(a)) + else + if size(n,'*')<>1 then + error(43) + else + n=double(n) + r=a + if size(a,1)==size(a,2) then + for i=2:n,r=r*a,end + else + mprintf(gettext("Warning: Syntax \""vector ^ scalar\"" is obsolete. It will be removed in Scilab 6.0.\n Use \""vector .^ scalar\"" instead.\n")); + for i=2:n,r=r.*a,end + end + end + end + end endfunction diff --git a/scilab/modules/integer/macros/%i_p_s.sci b/scilab/modules/integer/macros/%i_p_s.sci index 4333b2a..e3f2810 100644 --- a/scilab/modules/integer/macros/%i_p_s.sci +++ b/scilab/modules/integer/macros/%i_p_s.sci @@ -9,22 +9,23 @@ function r=%i_p_s(a,n) -if or(int(n)<>n)|or(n<0) then - r=double(a)^n -else - if size(a,'*')==1 then - r=iconvert(double(a)^n,inttype(a)) - else - if size(n,'*')<>1 then - error(43) + if or(int(n)<>n)|or(n<0) then + r=double(a)^n else - r=a - if size(a,1)==size(a,2) then - for i=2:n,r=r*a,end - else - for i=2:n,r=r.*a,end - end - end - end -end + if size(a,'*')==1 then + r=iconvert(double(a)^n,inttype(a)) + else + if size(n,'*')<>1 then + error(43) + else + r=a + if size(a,1)==size(a,2) then + for i=2:n,r=r*a,end + else + mprintf(gettext("Warning: Syntax \""vector ^ scalar\"" is obsolete. It will be removed in Scilab 6.0.\n Use \""vector .^ scalar\"" instead.\n")); + for i=2:n,r=r.*a,end + end + end + end + end endfunction diff --git a/scilab/modules/integer/tests/unit_tests/intops.dia.ref b/scilab/modules/integer/tests/unit_tests/intops.dia.ref index a368a87..400ff30 100644 --- a/scilab/modules/integer/tests/unit_tests/intops.dia.ref +++ b/scilab/modules/integer/tests/unit_tests/intops.dia.ref @@ -7,408 +7,490 @@ funcprot(0); //extractions v=int8([1 2 3]); -if v(2)<>int8(2) then bugmes();quit;end -if or(v([1 3])<>int8([1 3])) then bugmes();quit;end -if or(v([3 3])<>int8([3 3])) then bugmes();quit;end -if or(v(:)<>int8([1 2 3]')) then bugmes();quit;end -if v([])<>[] then bugmes();quit;end +assert_checkequal(v(2), int8(2)); +assert_checkequal(v([1 3]), int8([1 3])); +assert_checkequal(v([3 3]), int8([3 3])); +assert_checkequal(v(:), int8([1 2 3]')); +assert_checkequal(v([]), []); v=int32([1 2 3;4 5 6]); -if v(2)<>int8(4) then bugmes();quit;end -if or(v([1 3])<>int8([1;2])) then bugmes();quit;end -if or(v([3 3])<>int8([2;2])) then bugmes();quit;end -if or(v(:)<>int8([1;4;2;5;3;6])) then bugmes();quit;end -if v([])<>[] then bugmes();quit;end -if v(2,1)<>int8(4) then bugmes();quit;end -if or(v(1,[1 3])<>int8([1 3])) then bugmes();quit;end -if or(v(1,[3 3])<>int8([3 3])) then bugmes();quit;end -if or(v(1,:)<>int8([1 2 3])) then bugmes();quit;end -if or(v(:,2)<>int8([2;5])) then bugmes();quit;end -if or(v([1 1],:)<>int8([1 2 3;1 2 3])) then bugmes();quit;end -if or(v(:,[2 1])<>int8([2 1;5 4])) then bugmes();quit;end -if or(v(1,1:$)<>int8([1 2 3])) then bugmes();quit;end -if or(v(1:$,2)<>int8([2;5])) then bugmes();quit;end -if or(v([1 1],1:$)<>int8([1 2 3;1 2 3])) then bugmes();quit;end -if or(v(1:$,[2 1])<>int8([2 1;5 4])) then bugmes();quit;end +assert_checktrue(v(2) == int8(4)); +assert_checktrue(v([1 3]) == int8([1;2])); +assert_checktrue(v([3 3]) == int8([2;2])); +assert_checktrue(v(:) == int8([1;4;2;5;3;6])); +assert_checktrue(v([]) == []); +assert_checktrue(v(2,1) == int8(4)); +assert_checktrue(v(1,[1 3]) == int8([1 3])); +assert_checktrue(v(1,[3 3]) == int8([3 3])); +assert_checktrue(v(1,:) == int8([1 2 3])); +assert_checktrue(v(:,2) == int8([2;5])); +assert_checktrue(v([1 1],:) == int8([1 2 3;1 2 3])); +assert_checktrue(v(:,[2 1]) == int8([2 1;5 4])); +assert_checktrue(v(1,1:$) == int8([1 2 3])); +assert_checktrue(v(1:$,2) == int8([2;5])); +assert_checktrue(v([1 1],1:$) == int8([1 2 3;1 2 3])); +assert_checktrue(v(1:$,[2 1]) == int8([2 1;5 4])); //insertion -v=int8([1 2 3]); -v(2)=int8(3);if or(v<>int8([1 3 3])) then bugmes();quit;end -v(4)=int8(-5);if or(v<>int8([1 3 3 -5])) then bugmes();quit;end -v([1 4])=int8([2 5]);if or(v<>int8([2 3 3 5])) then bugmes();quit;end -v([1 1])=int8([2 5]);if or(v<>int8([5 3 3 5])) then bugmes();quit;end -v([1 1 1 1 1 1])=int8([2 5 6 7 8 9]);if or(v<>int8([9 3 3 5])) then bugmes();quit;end -v([4 2])=int8([8 5]);if or(v<>int8([9 5 3 8])) then bugmes();quit;end -v=uint16([1 2 3]); -v(2)=uint16(3);if or(v<>uint16([1 3 3])) then bugmes();quit;end -v(4)=uint16(-5);if or(v<>uint16([1 3 3 -5])) then bugmes();quit;end -v([1 4])=uint16([2 5]);if or(v<>uint16([2 3 3 5])) then bugmes();quit;end -v([1 1])=uint16([2 5]);if or(v<>uint16([5 3 3 5])) then bugmes();quit;end -v([1 1 1 1 1 1])=uint16([2 5 6 7 8 9]);if or(v<>uint16([9 3 3 5])) then bugmes();quit;end -v([4 2])=uint16([8 5]);if or(v<>uint16([9 5 3 8])) then bugmes();quit;end -v=uint8([1 2 3]); -v(2,4)=uint8(10);if or(v<>uint8([1 2 3 0;0 0 0 10])) then bugmes();quit;end -v([2 2],4)=uint8([10;20]);if or(v<>uint8([1 2 3 0;0 0 0 20])) then bugmes();quit;end -v([2 1],4)=uint8([10;20]);if or(v<>uint8([1 2 3 20;0 0 0 10])) then bugmes();quit;end -v([2 2 2],4)=uint8([10;20;30]);if or(v<>uint8([1 2 3 20;0 0 0 30])) then bugmes();quit;end -v=int32([1 2 3]); -v(2,4)=int32(10);if or(v<>int32([1 2 3 0;0 0 0 10])) then bugmes();quit;end -v([2 2],4)=int32([10;20]);if or(v<>int32([1 2 3 0;0 0 0 20])) then bugmes();quit;end -v([2 1],4)=int32([10;20]);if or(v<>int32([1 2 3 20;0 0 0 10])) then bugmes();quit;end -v([2 2 2],4)=int32([10;20;30]);if or(v<>int32([1 2 3 20;0 0 0 30])) then bugmes();quit;end -v=int16([1 2 3;0 0 10]); -v(1,[1 1 1 1])=int16(1:4);;if or(v<>int16([4 2 3;0 0 10])) then bugmes();quit;end -v([2 2],[1 1 1 1])=int16([1:4;2:5]);if or(v<>int16([4 2 3;5 0 10])) then bugmes();quit;end -v(3,4)=int16(7);if or(v<>int16([4 2 3 0;5 0 10 0;0 0 0 7])) then bugmes();quit;end -v=uint32([1 2 3;0 0 10]); -v(1,[1 1 1 1])=uint32(1:4);;if or(v<>uint32([4 2 3;0 0 10])) then bugmes();quit;end -v([2 2],[1 1 1 1])=uint32([1:4;2:5]);if or(v<>uint32([4 2 3;5 0 10])) then bugmes();quit;end -v(3,4)=uint32(7);if or(v<>uint32([4 2 3 0;5 0 10 0;0 0 0 7])) then bugmes();quit;end -v=[]; -v(5)=int8(1);if or(v<>int8([0;0;0;0;1])) then bugmes();quit;end -v(2)=int8(4);if or(v<>int8([0;4;0;0;1])) then bugmes();quit;end -v=uint16([1 2 3;4 5 6]); -v(:,1)=uint16([4;1]);if or(v<>uint16([4 2 3;1 5 6])) then bugmes();quit;end -v(:,[1 1])=uint16([4 5;1 2]);if or(v<>uint16([5 2 3;2 5 6])) then bugmes();quit;end -v(:,[3 1])=uint16([4 5;1 2]);if or(v<>uint16([5 2 4;2 5 1])) then bugmes();quit;end -v(:,[3 3 3 3])=uint16([4 5 6 7;1 2 3 4]);if or(v<>uint16([5 2 7;2 5 4])) then bugmes();quit;end -v=int8([1 2 3;4 5 6]); -v(1,:)=int8([2 3 4]);if or(v<>int8([2 3 4;4 5 6])) then bugmes();quit;end -v([1 1],:)=int8([2 3 4;4 5 6]);if or(v<>int8([4 5 6;4 5 6])) then bugmes();quit;end -v([2 2 2 2],:)=int8([2 3 4;4 5 6;7 8 9;10 11 12]); -if or(v<>int8([4 5 6;10 11 12])) then bugmes();quit;end -v=uint8([1 2 3]); -v(2)=[];if or(v<>uint8([1 3])) then bugmes();quit;end -v=uint8([1 2 3]); -v([3 2])=[];if v<>uint8(1) then bugmes();quit;end -v=int8([1 2 3]'); -v(2)=[];if or(v<>int8([1 3]')) then bugmes();quit;end -v=int8([1 2 3]'); -v([3 2])=[];if v<>int8(1) then bugmes();quit;end -v=int32([1 2 3;4 5 6]); -v(1,:)=[];if or(v<>int32([4 5 6])) then bugmes();quit;end -v=int32([1 2 3;4 5 6]); -v(:,[3 2])=[];if or(v<>int32([1;4])) then bugmes();quit;end +v = int8([1 2 3]); +v(2) = int8(3); +assert_checkequal(v, int8([1 3 3])); +v(4) = int8(-5); +assert_checkequal(v, int8([1 3 3 -5])); +v([1 4]) = int8([2 5]); +assert_checkequal(v, int8([2 3 3 5])); +v([1 1]) = int8([2 5]); +assert_checkequal(v, int8([5 3 3 5])); +v([1 1 1 1 1 1]) = int8([2 5 6 7 8 9]); +assert_checkequal(v, int8([9 3 3 5])); +v([4 2]) = int8([8 5]); +assert_checkequal(v, int8([9 5 3 8])); +v = uint16([1 2 3]); +v(2) = uint16(3); +assert_checkequal(v, uint16([1 3 3])); +v(4) = uint16(-5); +assert_checkequal(v, uint16([1 3 3 -5])); +v([1 4]) = uint16([2 5]); +assert_checkequal(v, uint16([2 3 3 5])); +v([1 1]) = uint16([2 5]); +assert_checkequal(v, uint16([5 3 3 5])); +v([1 1 1 1 1 1]) = uint16([2 5 6 7 8 9]); +assert_checkequal(v, uint16([9 3 3 5])); +v([4 2]) = uint16([8 5]); +assert_checkequal(v, uint16([9 5 3 8])); +v = uint8([1 2 3]); +v(2,4) = uint8(10); +assert_checkequal(v, uint8([1 2 3 0;0 0 0 10])); +v([2 2],4) = uint8([10;20]); +assert_checkequal(v, uint8([1 2 3 0;0 0 0 20])); +v([2 1],4) = uint8([10;20]); +assert_checkequal(v, uint8([1 2 3 20;0 0 0 10])); +v([2 2 2],4) = uint8([10;20;30]); +assert_checkequal(v, uint8([1 2 3 20;0 0 0 30])); +v = int32([1 2 3]); +v(2,4) = int32(10); +assert_checkequal(v, int32([1 2 3 0;0 0 0 10])); +v([2 2],4) = int32([10;20]); +assert_checkequal(v, int32([1 2 3 0;0 0 0 20])); +v([2 1],4) = int32([10;20]); +assert_checkequal(v, int32([1 2 3 20;0 0 0 10])); +v([2 2 2],4) = int32([10;20;30]); +assert_checkequal(v, int32([1 2 3 20;0 0 0 30])); +v = int16([1 2 3;0 0 10]); +v(1,[1 1 1 1]) = int16(1:4); +assert_checkequal(v, int16([4 2 3;0 0 10])); +v([2 2],[1 1 1 1]) = int16([1:4;2:5]); +assert_checkequal(v, int16([4 2 3;5 0 10])) + ans = + + T +v(3,4) = int16(7); +assert_checkequal(v, int16([4 2 3 0;5 0 10 0;0 0 0 7])) + ans = + + T +v = uint32([1 2 3;0 0 10]); +v(1,[1 1 1 1]) = uint32(1:4); +assert_checkequal(v, uint32([4 2 3;0 0 10])) + ans = + + T +v([2 2],[1 1 1 1]) = uint32([1:4;2:5]); +assert_checkequal(v, uint32([4 2 3;5 0 10])) + ans = + + T +v(3,4) = uint32(7); +assert_checkequal(v, uint32([4 2 3 0;5 0 10 0;0 0 0 7])) + ans = + + T +v = []; +v(5) = int8(1); +assert_checkequal(v, int8([0;0;0;0;1])); +v(2) = int8(4); +assert_checkequal(v, int8([0;4;0;0;1])) + ans = + + T +v = uint16([1 2 3;4 5 6]); +v(:,1) = uint16([4;1]); +assert_checkequal(v, uint16([4 2 3;1 5 6])); +v(:,[1 1]) = uint16([4 5;1 2]); +assert_checkequal(v, uint16([5 2 3;2 5 6])); +v(:,[3 1]) = uint16([4 5;1 2]); +assert_checkequal(v, uint16([5 2 4;2 5 1])) + ans = + + T +v(:,[3 3 3 3]) = uint16([4 5 6 7;1 2 3 4]); +assert_checkequal(v, uint16([5 2 7;2 5 4])) + ans = + + T +v = int8([1 2 3;4 5 6]); +v(1,:) = int8([2 3 4]); +assert_checkequal(v, int8([2 3 4;4 5 6])) + ans = + + T +v([1 1],:) = int8([2 3 4;4 5 6]); +assert_checkequal(v, int8([4 5 6;4 5 6])) + ans = + + T +v([2 2 2 2],:) = int8([2 3 4;4 5 6;7 8 9;10 11 12]); +assert_checkequal(v, int8([4 5 6;10 11 12])) + ans = + + T +v = uint8([1 2 3]); +v(2) = []; +assert_checkequal(v, uint8([1 3])); +v = uint8([1 2 3]); +v([3 2]) = []; +assert_checkequal(v, uint8(1)); +v = int8([1 2 3]'); +v(2) = []; +assert_checkequal(v, int8([1 3]')); +v = int8([1 2 3]'); +v([3 2]) = []; +assert_checkequal(v, int8(1)) + ans = + + T +v = int32([1 2 3;4 5 6]); +v(1,:) = []; +assert_checkequal(v, int32([4 5 6])); +v = int32([1 2 3;4 5 6]); +v(:,[3 2]) = []; +assert_checkequal(v, int32([1;4])); //hidden empty index in insertion -a=int32([1 2;3 4]);a_ref=a; -a(1,[%f %f])=[]; -if or(a<>a_ref) then bugmes();quit;end -a([%f %f],1)=[]; -if or(a<>a_ref) then bugmes();quit;end -a([%f %f],[%f %f])=[]; -if or(a<>a_ref) then bugmes();quit;end -a=int8([1 2;3 4]);a_ref=a; -a(1,[%f %f])=[]; -if or(a<>a_ref) then bugmes();quit;end -a([%f %f],1)=[]; -if or(a<>a_ref) then bugmes();quit;end -a([%f %f],[%f %f])=[]; -if or(a<>a_ref) then bugmes();quit;end +a = int32([1 2;3 4]); +a_ref = a; +a(1,[%f %f]) = []; +assert_checkequal(a, a_ref); +a([%f %f],1) = []; +assert_checkequal(a, a_ref); +a([%f %f],[%f %f]) = []; +assert_checkequal(a, a_ref); +a = int8([1 2;3 4]); +a_ref = a; +a(1,[%f %f]) = []; +assert_checkequal(a, a_ref); +a([%f %f],1) = []; +assert_checkequal(a, a_ref); +a([%f %f],[%f %f]) = []; +assert_checkequal(a, a_ref); //concatenations -x1=int8(1);x2=int8(7); -if or([x1 x2]<>int8([1 7])) then bugmes();quit;end -if or([x1;x2]<>int8([1;7])) then bugmes();quit;end -if or([x1 []]<>int8([1])) then bugmes();quit;end -if or([x1;[]]<>int8([1])) then bugmes();quit;end -if or([[] x2]<>int8([7])) then bugmes();quit;end -if or([[];x2]<>int8([7])) then bugmes();quit;end -[x1,x2]=([x1 x2 x1 x2],[x2 x2 x1 x1]); -if or([x1 x2]<>int8([1 7 1 7 7 7 1 1])) then bugmes();quit;end -if or([x1;x2]<>int8([1 7 1 7;7 7 1 1])) then bugmes();quit;end -if or([x1 []]<>int8([1 7 1 7])) then bugmes();quit;end -if or([x1;[]]<>int8([1 7 1 7])) then bugmes();quit;end -if or([[] x2]<>int8([7 7 1 1])) then bugmes();quit;end -if or([[];x2]<>int8([7 7 1 1])) then bugmes();quit;end -n=300;x1=uint16(1:n); -if or([x1 x1]<>uint16([1:n 1:n])) then bugmes();quit;end -if or([x1;x1]<>uint16([1:n;1:n])) then bugmes();quit;end +x1 = int8(1); +x2 = int8(7); +assert_checkequal([x1 x2], int8([1 7])); +assert_checkequal([x1; x2], int8([1; 7])); +assert_checkequal([x1 []], int8(1)); +assert_checkequal([x1; []], int8(1)); +assert_checkequal([[], x2], int8(7)); +assert_checkequal([[]; x2], int8(7)); +[x1, x2] = ([x1 x2 x1 x2],[x2 x2 x1 x1]); +assert_checkequal([x1 x2], int8([1 7 1 7 7 7 1 1])); +assert_checkequal([x1; x2], int8([1 7 1 7; 7 7 1 1])); +assert_checkequal([x1 []], int8([1 7 1 7])); +assert_checkequal([x1; []], int8([1 7 1 7])); +assert_checkequal([[] x2], int8([7 7 1 1])); +assert_checkequal([[]; x2], int8([7 7 1 1])); +n = 300; +x1 = uint16(1:n); +assert_checkequal([x1 x1], uint16([1:n 1:n])); +assert_checkequal([x1; x1], uint16([1:n; 1:n])); //additions soustractions -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or(x1+x2<>int8(X1+X2)) then bugmes();quit;end -if or(x1-x2<>int8(X1-X2)) then bugmes();quit;end -X1=1:10;x1=int8(X1); -if or(x1+x2<>int8(X1+X2)) then bugmes();quit;end -if or(x1-x2<>int8(X1-X2)) then bugmes();quit;end -X2=2:11;x2=int8(X2); -if or(x1+x2<>int8(X1+X2)) then bugmes();quit;end -if or(x1-x2<>int8(X1-X2)) then bugmes();quit;end -if or(-x1<>int8(-(1:10))) then bugmes();quit;end -X2=[];x2=[] - x2 = - - [] -if or(x1+x2<>int8(X1+X2)) then bugmes();quit;end -if or(x1-x2<>int8(X1-X2)) then bugmes();quit;end -if or(x2+x1<>int8(X2+X1)) then bugmes();quit;end -if or(x2-x1<>int8(X2-X1)) then bugmes();quit;end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); +X2 = 2:11; x2 = int8(X2); +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); +assert_checkequal(-x1, int8(-X1)); +X2 = []; x2 = []; +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); +assert_checkequal(x2+x1, int8(X2+X1)); +assert_checkequal(x2-x1, int8(X2-X1)); //multiplication -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or(x1*x2<>int8(X1*X2)) then bugmes();quit;end -if or(x1.*x2<>int8(X1.*X2)) then bugmes();quit;end -X1=1:10;x1=int8(X1); -if or(x1*x2<>int8(X1*X2)) then bugmes();quit;end -if or(x2*x1<>int8(X2*X1)) then bugmes();quit;end -if or(x1.*x2<>int8(X1.*X2)) then bugmes();quit;end -if or(x2.*x1<>int8(X2.*X1)) then bugmes();quit;end -X2=-(1:10);x2=int8(X2); -if or(x1.*x2<>int8(X1.*X2)) then bugmes();quit;end -if or(x1'*x2<>int8(X1'*X2)) then bugmes();quit;end -if or(x1*x2'<>int8(X1*X2')) then bugmes();quit;end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1 * x2, int8(X1 * X2)); +assert_checkequal(x1 .* x2, int8(X1 .* X2)); +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1 * x2, int8(X1 * X2)); +assert_checkequal(x1 .* x2, int8(X1 .* X2)); +assert_checkequal(x2 * x1, int8(X2 * X1)); +assert_checkequal(x2 .* x1, int8(X2 .* X1)); +X2 = -(1:10); x2 = int8(X2); +assert_checkequal(x1 .* x2, int8(X1 .* X2)); +assert_checkequal(x1' * x2, int8(X1' * X2)); +assert_checkequal(x1 * x2', int8(X1 * X2')); // comparaisons -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or((x1>x2)<>(X1>X2)) then bugmes();quit;end -if or((x1>=x2)<>(X1>=X2)) then bugmes();quit;end -if or((x1(X1(X1<=X2)) then bugmes();quit;end -if or((x1<>x2)<>(X1<>X2)) then bugmes();quit;end -X1=1:10;x1=int8(X1); -if or((x1>x2)<>(X1>X2)) then bugmes();quit;end -if or((x1>=x2)<>(X1>=X2)) then bugmes();quit;end -if or((x1(X1(X1<=X2)) then bugmes();quit;end -if or((x1<>x2)<>(X1<>X2)) then bugmes();quit;end -X2=2:11;x2=int8(X2); -if or((x1>x2)<>(X1>X2)) then bugmes();quit;end -if or((x1>=x2)<>(X1>=X2)) then bugmes();quit;end -if or((x1(X1(X1<=X2)) then bugmes();quit;end -if or((x1<>x2)<>(X1<>X2)) then bugmes();quit;end -X1=1;x1=int8(X1); -if or((x1>x2)<>(X1>X2)) then bugmes();quit;end -if or((x1>=x2)<>(X1>=X2)) then bugmes();quit;end -if or((x1(X1(X1<=X2)) then bugmes();quit;end -if or((x1<>x2)<>(X1<>X2)) then bugmes();quit;end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); +X2 = 2:11;x2 = int8(X2); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); +X1 = 1;x1 = int8(X1); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); //division -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or(x1/x2<>int8(0)) then bugmes();quit;end -if or(x2/x1<>int8(7)) then bugmes();quit;end -if or(x1\x2<>int8(7)) then bugmes();quit;end -if or(x2\x1<>int8(0)) then bugmes();quit;end -if or(x1./x2<>int8(0)) then bugmes();quit;end -if or(x2./x1<>int8(7)) then bugmes();quit;end -if or(x1.\x2<>int8(7)) then bugmes();quit;end -if or(x2.\x1<>int8(0)) then bugmes();quit;end -X1=1:10;x1=int8(X1); -if or(x1/x2<>int8([0 0 0 0 0 0 1 1 1 1])) then bugmes();quit;end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1/x2, int8(0)); +assert_checkequal(x2/x1, int8(7)); +assert_checkequal(x1\x2, int8(7)); +assert_checkequal(x2\x1, int8(0)); +assert_checkequal(x1./x2, int8(0)); +assert_checkequal(x2./x1, int8(7)); +assert_checkequal(x1.\x2, int8(7)); +assert_checkequal(x2.\x1, int8(0)); +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1/x2, int8([0 0 0 0 0 0 1 1 1 1])); //if or(x2/x1<>int8([7 3 2 1 1 1 1 0 0 0])) then bugmes();quit;end -if or(x1./x2<>int8([0 0 0 0 0 0 1 1 1 1])) then bugmes();quit;end -if or(x2./x1<>int8([7 3 2 1 1 1 1 0 0 0])) then bugmes();quit;end +assert_checkequal(x1./x2, int8([0 0 0 0 0 0 1 1 1 1])); +assert_checkequal(x2./x1, int8([7 3 2 1 1 1 1 0 0 0])); //if or(x1\x2<>int8([0 0 0 0 0 0 1 1 1 1])) then bugmes();quit;end -if or(x1.\x2<>int8([7 3 2 1 1 1 1 0 0 0])) then bugmes();quit;end -if or(x2\x1<> int8([0 0 0 0 0 0 1 1 1 1])) then bugmes();quit;end -if or(x2.\x1<>int8([0 0 0 0 0 0 1 1 1 1])) then bugmes();quit;end -X2=-(1:10);x2=int8(X2); -if or(x1./x2<>int8(-ones(1,10))) then bugmes();quit;end -if or(x1.\x2<>int8(-ones(1,10))) then bugmes();quit;end +assert_checkequal(x1.\x2, int8([7 3 2 1 1 1 1 0 0 0])); +assert_checkequal(x2\x1, int8([0 0 0 0 0 0 1 1 1 1])); +assert_checkequal(x2.\x1, int8([0 0 0 0 0 0 1 1 1 1])); +X2 = -(1:10); x2 = int8(X2); +assert_checkequal(x1./x2, int8(-ones(1,10))); +assert_checkequal(x1.\x2, int8(-ones(1,10))); // puissance -X1=2;X2=3;x1=int8(X1);x2=int8(X2); -if or(x1^x2<>int8(X1^X2)) then bugmes();quit;end -if or(x1.^x2<>int8(X1.^X2)) then bugmes();quit;end -X1=1:5;x1=int8(X1); -if or(x1^x2<>int8(X1^X2)) then bugmes();quit;end -if or(x1.^x2<>int8(X1.^X2)) then bugmes();quit;end -X1=2;x1=int8(X1);X2=(1:3);x2=int8(X2); -if or(x1^x2<>int8(X1^X2)) then bugmes();quit;end -if or(x1.^x2<>int8(X1.^X2)) then bugmes();quit;end -X1=2:4;x1=int8(X1); +X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1^x2, int8(X1^X2)); +assert_checkequal(x1.^x2, int8(X1.^X2)); +X1 = 1:5; x1 = int8(X1); +assert_checkequal(x1.^x2, int8(X1.^X2)); +//if or(x1^x2<>int8(X1^X2)) then bugmes();quit;end +X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2); +assert_checkequal(x1^x2, int8(X1^X2)); +assert_checkequal(x1.^x2, int8(X1.^X2)); +//X1=2:4;x1=int8(X1); //if or(x1.^x2<>int8(X1.^X2)) then bugmes();quit;end //kronecker -X1=2;X2=3;x1=int8(X1);x2=int8(X2); -if or(x1.*.x2<>int8(X1.*.X2)) then bugmes();quit;end -X1=1:5;x1=int8(X1); -if or(x1.*.x2<>int8(X1.*.X2)) then bugmes();quit;end -X1=2;x1=int8(X1);X2=(1:3);x2=int8(X2); -if or(x1.*.x2<>int8(X1.*.X2)) then bugmes();quit;end -X1=(1:5)';x1=int8(X1); -if or(x1.*.x2<>int8(X1.*.X2)) then bugmes();quit;end +X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); +X1 = 1:5;x1 = int8(X1); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); +X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); +X1 = (1:5)';x1 = int8(X1); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); //sum -X=round(10*rand(1,30)); +X = round(10 * rand(1,30)); deff('y=INT(x)','y=int16(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then bugmes();quit;end -if or(sum(x')<>INT(sum(X'))) then bugmes();quit;end -if or(cumsum(x)<>INT(cumsum(X))) then bugmes();quit;end -if or(cumsum(x')<>INT(cumsum(X'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); deff('y=INT(x)','y=uint16(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then bugmes();quit;end -if or(sum(x')<>INT(sum(X'))) then bugmes();quit;end -if or(cumsum(x)<>INT(cumsum(X))) then bugmes();quit;end -if or(cumsum(x')<>INT(cumsum(X'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); deff('y=INT(x)','y=uint8(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then bugmes();quit;end -if or(sum(x')<>INT(sum(X'))) then bugmes();quit;end -if or(cumsum(x)<>INT(cumsum(X))) then bugmes();quit;end -if or(cumsum(x')<>INT(cumsum(X'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); deff('y=INT(x)','y=int8(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then bugmes();quit;end -if or(sum(x')<>INT(sum(X'))) then bugmes();quit;end -if or(cumsum(x)<>INT(cumsum(X))) then bugmes();quit;end -if or(cumsum(x')<>INT(cumsum(X'))) then bugmes();quit;end -X=round(10*rand(20,30)); -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then bugmes();quit;end -if or(sum(x',1)<>INT(sum(X',1))) then bugmes();quit;end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then bugmes();quit;end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); +X = round(10*rand(20,30)); +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); deff('y=INT(x)','y=uint16(x)') -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then bugmes();quit;end -if or(sum(x',1)<>INT(sum(X',1))) then bugmes();quit;end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then bugmes();quit;end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); deff('y=INT(x)','y=uint8(x)') -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then bugmes();quit;end -if or(sum(x',1)<>INT(sum(X',1))) then bugmes();quit;end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then bugmes();quit;end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); deff('y=INT(x)','y=int8(x)') -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then bugmes();quit;end -if or(sum(x',1)<>INT(sum(X',1))) then bugmes();quit;end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then bugmes();quit;end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then bugmes();quit;end -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then bugmes();quit;end -if or(sum(x','c')<>INT(sum(X','c'))) then bugmes();quit;end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then bugmes();quit;end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); deff('y=INT(x)','y=uint16(x)') -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then bugmes();quit;end -if or(sum(x','c')<>INT(sum(X','c'))) then bugmes();quit;end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then bugmes();quit;end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); deff('y=INT(x)','y=uint8(x)') -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then bugmes();quit;end -if or(sum(x','c')<>INT(sum(X','c'))) then bugmes();quit;end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then bugmes();quit;end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); deff('y=INT(x)','y=int8(x)') -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then bugmes();quit;end -if or(sum(x','c')<>INT(sum(X','c'))) then bugmes();quit;end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then bugmes();quit;end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then bugmes();quit;end +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); //diag triu tril deff('y=INT(x)','y=int16(x)') -X=round(10*rand(1,30)); -x=INT(X); -if or(diag(x)<>diag(X)) then bugmes();quit;end -if or(diag(x,2)<>diag(X,2)) then bugmes();quit;end -if or(diag(x,-2)<>diag(X,-2)) then bugmes();quit;end -if or(triu(x)<>triu(X)) then bugmes();quit;end -if or(triu(x,2)<>triu(X,2)) then bugmes();quit;end -if or(triu(x,-2)<>triu(X,-2)) then bugmes();quit;end -if or(tril(x)<>tril(X)) then bugmes();quit;end -if or(tril(x,2)<>tril(X,2)) then bugmes();quit;end -if or(tril(x,-2)<>tril(X,-2)) then bugmes();quit;end -X=round(10*rand(2,30)); -x=INT(X); -if or(diag(x)<>diag(X)) then bugmes();quit;end -if or(diag(x,2)<>diag(X,2)) then bugmes();quit;end -if or(diag(x,-2)<>diag(X,-2)) then bugmes();quit;end -if or(triu(x)<>triu(X)) then bugmes();quit;end -if or(triu(x,2)<>triu(X,2)) then bugmes();quit;end -if or(triu(x,-2)<>triu(X,-2)) then bugmes();quit;end -if or(tril(x)<>tril(X)) then bugmes();quit;end -if or(tril(x,2)<>tril(X,2)) then bugmes();quit;end -if or(tril(x,-2)<>tril(X,-2)) then bugmes();quit;end +X = round(10*rand(1,30)); +x = INT(X); +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); +X = round(10*rand(2,30)); +x = INT(X); +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); deff('y=INT(x)','y=uint8(x)') -X=round(10*rand(1,30)); -x=INT(X); -if or(diag(x)<>diag(X)) then bugmes();quit;end -if or(diag(x,2)<>diag(X,2)) then bugmes();quit;end -if or(diag(x,-2)<>diag(X,-2)) then bugmes();quit;end -if or(triu(x)<>triu(X)) then bugmes();quit;end -if or(triu(x,2)<>triu(X,2)) then bugmes();quit;end -if or(triu(x,-2)<>triu(X,-2)) then bugmes();quit;end -if or(tril(x)<>tril(X)) then bugmes();quit;end -if or(tril(x,2)<>tril(X,2)) then bugmes();quit;end -if or(tril(x,-2)<>tril(X,-2)) then bugmes();quit;end -X=round(10*rand(2,30)); -x=INT(X); -if or(diag(x)<>diag(X)) then bugmes();quit;end -if or(diag(x,2)<>diag(X,2)) then bugmes();quit;end -if or(diag(x,-2)<>diag(X,-2)) then bugmes();quit;end -if or(triu(x)<>triu(X)) then bugmes();quit;end -if or(triu(x,2)<>triu(X,2)) then bugmes();quit;end -if or(triu(x,-2)<>triu(X,-2)) then bugmes();quit;end -if or(tril(x)<>tril(X)) then bugmes();quit;end -if or(tril(x,2)<>tril(X,2)) then bugmes();quit;end -if or(tril(x,-2)<>tril(X,-2)) then bugmes();quit;end +X = round(10*rand(1,30)); +x = INT(X); +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); +X = round(10*rand(2,30)); +x = INT(X); +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); // save load deff('y=INT(x)','y=uint8(x)') -X=round(10*rand(1,30)); -x=INT(X); +X = round(10*rand(1,30)); +x = INT(X); save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>INT(X)) then bugmes();quit;end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, INT(X)); x=list(1,x,2);save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>list(1,INT(X),2)) then bugmes();quit;end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, list(1, INT(X), 2)); deff('y=INT(x)','y=int32(x)') -X=round(10*rand(1,30)); -x=INT(X); +X = round(10*rand(1,30)); +x = INT(X); save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>INT(X)) then bugmes();quit;end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, INT(X)); x=list(1,x,2);save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>list(1,INT(X),2)) then bugmes();quit;end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, list(1, INT(X), 2)); //abs deff('y=INT(x)','y=int8(x)') -X=round(10*rand(1,30))-5; -x=INT(X); -if or(abs(x)<>INT(abs(X))) then bugmes();quit;end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(abs(x), INT(abs(X))); deff('y=INT(x)','y=int16(x)') -X=round(10*rand(1,30))-5; -x=INT(X); -if or(abs(x)<>INT(abs(X))) then bugmes();quit;end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(abs(x), INT(abs(X))); //matrix deff('y=INT(x)','y=int8(x)') -X=round(10*rand(1,30))-5; -x=INT(X); -if or(matrix(x,10,-1)<>INT(matrix(X,10,-1))) then bugmes();quit;end -if or(matrix(x,10,3)<>INT(matrix(X,10,3))) then bugmes();quit;end -if or(matrix(x,-1,3)<>INT(matrix(X,-1,3))) then bugmes();quit;end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1))); +assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3))); +assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3))); deff('y=INT(x)','y=uint8(x)') -X=round(10*rand(1,30))-5; -x=INT(X); -if or(matrix(x,10,-1)<>INT(matrix(X,10,-1))) then bugmes();quit;end -if or(matrix(x,10,3)<>INT(matrix(X,10,3))) then bugmes();quit;end -if or(matrix(x,-1,3)<>INT(matrix(X,-1,3))) then bugmes();quit;end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1))); +assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3))); +assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3))); //max min deff('y=INT(x)','y=int8(x)') -X=round(10*rand(2,30))-5; -Y=ones(2,30); -x=INT(X); -y=INT(Y); -if or(max(x)<>INT(max(X))) then bugmes();quit;end -if or(max(x,'r')<>INT(max(X,'r'))) then bugmes();quit;end -if or(max(x,'c')<>INT(max(X,'c'))) then bugmes();quit;end -if or(max(x,INT(2))<>INT(max(X,2))) then bugmes();quit;end -if or(max(x,y)<>INT(max(X,Y))) then bugmes();quit;end -if or(min(x)<>INT(min(X))) then bugmes();quit;end -if or(min(x,'r')<>INT(min(X,'r'))) then bugmes();quit;end -if or(min(x,'c')<>INT(min(X,'c'))) then bugmes();quit;end -if or(min(x,INT(2))<>INT(min(X,2))) then bugmes();quit;end -if or(min(x,y)<>INT(min(X,Y))) then bugmes();quit;end -a=[0 3 7]; -b=[1 2 7]; -A=[0 3 7 5; +X = round(10*rand(2,30))-5; +Y = ones(2,30); +x = INT(X); +y = INT(Y); +assert_checkequal(max(x), INT(max(X))); +assert_checkequal(max(x, "r"), INT(max(X, "r"))); +assert_checkequal(max(x, "c"), INT(max(X, "c"))); +assert_checkequal(max(x, INT(2)), INT(max(X, 2))); +assert_checkequal(max(x, y), INT(max(X, Y))); +assert_checkequal(min(x), INT(min(X))); +assert_checkequal(min(x, "r"), INT(min(X, "r"))); +assert_checkequal(min(x, "c"), INT(min(X, "c"))); +assert_checkequal(min(x, INT(2)), INT(min(X, 2))); +assert_checkequal(min(x, y), INT(min(X, Y))); +a = [0 3 7]; +b = [1 2 7]; +A = [0 3 7 5; 1 2 0 2 8 9 3 1]; -types=['double','int32','uint32','int16','uint16','int8','uint8'] - types = - -!double int32 uint32 int16 uint16 int8 uint8 ! +types=['double','int32','uint32','int16','uint16','int8','uint8']; // checking max(a,b) -[mx,kx]=max(a,b); -for t1=types - for t2=types +[mx, kx] = max(a, b); +for t1 = types + for t2 = types execstr('at='+t1+'(a); bt='+t2+'(b);') - [mt,kt]=max(at,bt); - if or(kt<>kx)|or(mx<>double(mt)) then + [mt, kt] = max(at, bt); + if or(kt<>kx)|or(mx<>double(mt)) then disp('max('+t1+','+t2+')'),pause end end @@ -419,106 +501,62 @@ for t1=types for t2=types execstr('at='+t1+'(a); bt='+t2+'(b);') [mt,kt]=min(at,bt); - if or(kt<>kn)|or(mn<>double(mt)) then + if or(kt<>kn)|or(mn<>double(mt)) then disp('min('+t1+','+t2+')'),pause end end end // checking max(A) -[mx,kx]=max(A) - kx = - - 3. 2. - mx = - - 9. +[mx,kx]=max(A); for t1=types execstr('At='+t1+'(A);') [mt,kt]=max(At); - if or(kt<>kx)|or(mx<>double(mt)) then + if or(kt<>kx)|or(mx<>double(mt)) then disp('max('+t1+')'),pause end end // checking min(A) -[mx,kx]=min(A) - kx = - - 1. 1. - mx = - - 0. +[mx,kx]=min(A); for t1=types execstr('At='+t1+'(A);') [mt,kt]=min(At); - if or(kt<>kx)|or(mx<>double(mt)) then + if or(kt<>kx)|or(mx<>double(mt)) then disp('min('+t1+')'),pause end end // checking max(A,'r') -[mx,kx]=max(A,'r') - kx = - - 3. 3. 1. 1. - mx = - - 8. 9. 7. 5. +[mx,kx]=max(A,'r'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=max(At,'r'); - if or(kt<>kx)|or(mx<>double(mt)) then + if or(kt<>kx)|or(mx<>double(mt)) then disp('max('+t1+',''r'')'),pause end end // checking min(A,'r') -[mx,kx]=min(A,'r') - kx = - - 1. 2. 2. 3. - mx = - - 0. 2. 0. 1. +[mx,kx]=min(A,'r'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=min(At,'r'); - if or(kt<>kx)|or(mx<>double(mt)) then + if or(kt<>kx)|or(mx<>double(mt)) then disp('min('+t1+',''r'')'),pause end end // checking max(A,'c') -[mx,kx]=max(A,'c') - kx = - - 3. - 2. - 2. - mx = - - 7. - 2. - 9. +[mx,kx]=max(A,'c'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=max(At,'c'); - if or(kt<>kx)|or(mx<>double(mt)) then + if or(kt<>kx)|or(mx<>double(mt)) then disp('max('+t1+',''c'')'),pause end end // checking min(A,'c') -[mx,kx]=min(A,'c') - kx = - - 1. - 3. - 4. - mx = - - 0. - 0. - 1. +[mx,kx]=min(A,'c'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=min(At,'c'); - if or(kt<>kx)|or(mx<>double(mt)) then + if or(kt<>kx)|or(mx<>double(mt)) then disp('min('+t1+',''c'')'),pause end end diff --git a/scilab/modules/integer/tests/unit_tests/intops.tst b/scilab/modules/integer/tests/unit_tests/intops.tst index cd2cf08..7b9b3fe 100644 --- a/scilab/modules/integer/tests/unit_tests/intops.tst +++ b/scilab/modules/integer/tests/unit_tests/intops.tst @@ -10,489 +10,573 @@ funcprot(0); //extractions v=int8([1 2 3]); -if v(2)<>int8(2) then pause,end -if or(v([1 3])<>int8([1 3])) then pause,end -if or(v([3 3])<>int8([3 3])) then pause,end -if or(v(:)<>int8([1 2 3]')) then pause,end -if v([])<>[] then pause,end +assert_checkequal(v(2), int8(2)); +assert_checkequal(v([1 3]), int8([1 3])); +assert_checkequal(v([3 3]), int8([3 3])); +assert_checkequal(v(:), int8([1 2 3]')); +assert_checkequal(v([]), []); + v=int32([1 2 3;4 5 6]); -if v(2)<>int8(4) then pause,end -if or(v([1 3])<>int8([1;2])) then pause,end -if or(v([3 3])<>int8([2;2])) then pause,end -if or(v(:)<>int8([1;4;2;5;3;6])) then pause,end -if v([])<>[] then pause,end +assert_checktrue(v(2) == int8(4)); +assert_checktrue(v([1 3]) == int8([1;2])); +assert_checktrue(v([3 3]) == int8([2;2])); +assert_checktrue(v(:) == int8([1;4;2;5;3;6])); +assert_checktrue(v([]) == []); + +assert_checktrue(v(2,1) == int8(4)); +assert_checktrue(v(1,[1 3]) == int8([1 3])); +assert_checktrue(v(1,[3 3]) == int8([3 3])); +assert_checktrue(v(1,:) == int8([1 2 3])); +assert_checktrue(v(:,2) == int8([2;5])); +assert_checktrue(v([1 1],:) == int8([1 2 3;1 2 3])); +assert_checktrue(v(:,[2 1]) == int8([2 1;5 4])); + +assert_checktrue(v(1,1:$) == int8([1 2 3])); +assert_checktrue(v(1:$,2) == int8([2;5])); +assert_checktrue(v([1 1],1:$) == int8([1 2 3;1 2 3])); +assert_checktrue(v(1:$,[2 1]) == int8([2 1;5 4])); -if v(2,1)<>int8(4) then pause,end -if or(v(1,[1 3])<>int8([1 3])) then pause,end -if or(v(1,[3 3])<>int8([3 3])) then pause,end -if or(v(1,:)<>int8([1 2 3])) then pause,end -if or(v(:,2)<>int8([2;5])) then pause,end -if or(v([1 1],:)<>int8([1 2 3;1 2 3])) then pause,end -if or(v(:,[2 1])<>int8([2 1;5 4])) then pause,end +//insertion +v = int8([1 2 3]); +v(2) = int8(3); +assert_checkequal(v, int8([1 3 3])); +v(4) = int8(-5); +assert_checkequal(v, int8([1 3 3 -5])); -if or(v(1,1:$)<>int8([1 2 3])) then pause,end -if or(v(1:$,2)<>int8([2;5])) then pause,end -if or(v([1 1],1:$)<>int8([1 2 3;1 2 3])) then pause,end -if or(v(1:$,[2 1])<>int8([2 1;5 4])) then pause,end +v([1 4]) = int8([2 5]); +assert_checkequal(v, int8([2 3 3 5])); +v([1 1]) = int8([2 5]); +assert_checkequal(v, int8([5 3 3 5])); +v([1 1 1 1 1 1]) = int8([2 5 6 7 8 9]); +assert_checkequal(v, int8([9 3 3 5])); +v([4 2]) = int8([8 5]); +assert_checkequal(v, int8([9 5 3 8])); -//insertion -v=int8([1 2 3]); -v(2)=int8(3);if or(v<>int8([1 3 3])) then pause,end +v = uint16([1 2 3]); +v(2) = uint16(3); +assert_checkequal(v, uint16([1 3 3])); -v(4)=int8(-5);if or(v<>int8([1 3 3 -5])) then pause,end +v(4) = uint16(-5); +assert_checkequal(v, uint16([1 3 3 -5])); -v([1 4])=int8([2 5]);if or(v<>int8([2 3 3 5])) then pause,end -v([1 1])=int8([2 5]);if or(v<>int8([5 3 3 5])) then pause,end -v([1 1 1 1 1 1])=int8([2 5 6 7 8 9]);if or(v<>int8([9 3 3 5])) then pause,end -v([4 2])=int8([8 5]);if or(v<>int8([9 5 3 8])) then pause,end +v([1 4]) = uint16([2 5]); +assert_checkequal(v, uint16([2 3 3 5])); -v=uint16([1 2 3]); -v(2)=uint16(3);if or(v<>uint16([1 3 3])) then pause,end +v([1 1]) = uint16([2 5]); +assert_checkequal(v, uint16([5 3 3 5])); -v(4)=uint16(-5);if or(v<>uint16([1 3 3 -5])) then pause,end +v([1 1 1 1 1 1]) = uint16([2 5 6 7 8 9]); +assert_checkequal(v, uint16([9 3 3 5])); -v([1 4])=uint16([2 5]);if or(v<>uint16([2 3 3 5])) then pause,end -v([1 1])=uint16([2 5]);if or(v<>uint16([5 3 3 5])) then pause,end -v([1 1 1 1 1 1])=uint16([2 5 6 7 8 9]);if or(v<>uint16([9 3 3 5])) then pause,end -v([4 2])=uint16([8 5]);if or(v<>uint16([9 5 3 8])) then pause,end +v([4 2]) = uint16([8 5]); +assert_checkequal(v, uint16([9 5 3 8])); +v = uint8([1 2 3]); +v(2,4) = uint8(10); +assert_checkequal(v, uint8([1 2 3 0;0 0 0 10])); +v([2 2],4) = uint8([10;20]); +assert_checkequal(v, uint8([1 2 3 0;0 0 0 20])); -v=uint8([1 2 3]); -v(2,4)=uint8(10);if or(v<>uint8([1 2 3 0;0 0 0 10])) then pause,end -v([2 2],4)=uint8([10;20]);if or(v<>uint8([1 2 3 0;0 0 0 20])) then pause,end -v([2 1],4)=uint8([10;20]);if or(v<>uint8([1 2 3 20;0 0 0 10])) then pause,end -v([2 2 2],4)=uint8([10;20;30]);if or(v<>uint8([1 2 3 20;0 0 0 30])) then pause,end +v([2 1],4) = uint8([10;20]); +assert_checkequal(v, uint8([1 2 3 20;0 0 0 10])); -v=int32([1 2 3]); -v(2,4)=int32(10);if or(v<>int32([1 2 3 0;0 0 0 10])) then pause,end -v([2 2],4)=int32([10;20]);if or(v<>int32([1 2 3 0;0 0 0 20])) then pause,end -v([2 1],4)=int32([10;20]);if or(v<>int32([1 2 3 20;0 0 0 10])) then pause,end -v([2 2 2],4)=int32([10;20;30]);if or(v<>int32([1 2 3 20;0 0 0 30])) then pause,end +v([2 2 2],4) = uint8([10;20;30]); +assert_checkequal(v, uint8([1 2 3 20;0 0 0 30])); +v = int32([1 2 3]); +v(2,4) = int32(10); +assert_checkequal(v, int32([1 2 3 0;0 0 0 10])); +v([2 2],4) = int32([10;20]); +assert_checkequal(v, int32([1 2 3 0;0 0 0 20])); -v=int16([1 2 3;0 0 10]); -v(1,[1 1 1 1])=int16(1:4);;if or(v<>int16([4 2 3;0 0 10])) then pause,end -v([2 2],[1 1 1 1])=int16([1:4;2:5]);if or(v<>int16([4 2 3;5 0 10])) then pause,end -v(3,4)=int16(7);if or(v<>int16([4 2 3 0;5 0 10 0;0 0 0 7])) then pause,end +v([2 1],4) = int32([10;20]); +assert_checkequal(v, int32([1 2 3 20;0 0 0 10])); -v=uint32([1 2 3;0 0 10]); -v(1,[1 1 1 1])=uint32(1:4);;if or(v<>uint32([4 2 3;0 0 10])) then pause,end -v([2 2],[1 1 1 1])=uint32([1:4;2:5]);if or(v<>uint32([4 2 3;5 0 10])) then pause,end -v(3,4)=uint32(7);if or(v<>uint32([4 2 3 0;5 0 10 0;0 0 0 7])) then pause,end +v([2 2 2],4) = int32([10;20;30]); +assert_checkequal(v, int32([1 2 3 20;0 0 0 30])); +v = int16([1 2 3;0 0 10]); +v(1,[1 1 1 1]) = int16(1:4); +assert_checkequal(v, int16([4 2 3;0 0 10])); +v([2 2],[1 1 1 1]) = int16([1:4;2:5]); +assert_checkequal(v, int16([4 2 3;5 0 10])) -v=[]; -v(5)=int8(1);if or(v<>int8([0;0;0;0;1])) then pause,end -v(2)=int8(4);if or(v<>int8([0;4;0;0;1])) then pause,end +v(3,4) = int16(7); +assert_checkequal(v, int16([4 2 3 0;5 0 10 0;0 0 0 7])) -v=uint16([1 2 3;4 5 6]); -v(:,1)=uint16([4;1]);if or(v<>uint16([4 2 3;1 5 6])) then pause,end -v(:,[1 1])=uint16([4 5;1 2]);if or(v<>uint16([5 2 3;2 5 6])) then pause,end -v(:,[3 1])=uint16([4 5;1 2]);if or(v<>uint16([5 2 4;2 5 1])) then pause,end -v(:,[3 3 3 3])=uint16([4 5 6 7;1 2 3 4]);if or(v<>uint16([5 2 7;2 5 4])) then pause,end +v = uint32([1 2 3;0 0 10]); +v(1,[1 1 1 1]) = uint32(1:4); +assert_checkequal(v, uint32([4 2 3;0 0 10])) -v=int8([1 2 3;4 5 6]); -v(1,:)=int8([2 3 4]);if or(v<>int8([2 3 4;4 5 6])) then pause,end -v([1 1],:)=int8([2 3 4;4 5 6]);if or(v<>int8([4 5 6;4 5 6])) then pause,end -v([2 2 2 2],:)=int8([2 3 4;4 5 6;7 8 9;10 11 12]); -if or(v<>int8([4 5 6;10 11 12])) then pause,end +v([2 2],[1 1 1 1]) = uint32([1:4;2:5]); +assert_checkequal(v, uint32([4 2 3;5 0 10])) -v=uint8([1 2 3]); -v(2)=[];if or(v<>uint8([1 3])) then pause,end -v=uint8([1 2 3]); -v([3 2])=[];if v<>uint8(1) then pause,end +v(3,4) = uint32(7); +assert_checkequal(v, uint32([4 2 3 0;5 0 10 0;0 0 0 7])) -v=int8([1 2 3]'); -v(2)=[];if or(v<>int8([1 3]')) then pause,end -v=int8([1 2 3]'); -v([3 2])=[];if v<>int8(1) then pause,end +v = []; +v(5) = int8(1); +assert_checkequal(v, int8([0;0;0;0;1])); -v=int32([1 2 3;4 5 6]); -v(1,:)=[];if or(v<>int32([4 5 6])) then pause,end -v=int32([1 2 3;4 5 6]); -v(:,[3 2])=[];if or(v<>int32([1;4])) then pause,end +v(2) = int8(4); +assert_checkequal(v, int8([0;4;0;0;1])) + +v = uint16([1 2 3;4 5 6]); +v(:,1) = uint16([4;1]); +assert_checkequal(v, uint16([4 2 3;1 5 6])); + +v(:,[1 1]) = uint16([4 5;1 2]); +assert_checkequal(v, uint16([5 2 3;2 5 6])); + +v(:,[3 1]) = uint16([4 5;1 2]); +assert_checkequal(v, uint16([5 2 4;2 5 1])) + +v(:,[3 3 3 3]) = uint16([4 5 6 7;1 2 3 4]); +assert_checkequal(v, uint16([5 2 7;2 5 4])) + +v = int8([1 2 3;4 5 6]); +v(1,:) = int8([2 3 4]); +assert_checkequal(v, int8([2 3 4;4 5 6])) + +v([1 1],:) = int8([2 3 4;4 5 6]); +assert_checkequal(v, int8([4 5 6;4 5 6])) + +v([2 2 2 2],:) = int8([2 3 4;4 5 6;7 8 9;10 11 12]); +assert_checkequal(v, int8([4 5 6;10 11 12])) + +v = uint8([1 2 3]); +v(2) = []; +assert_checkequal(v, uint8([1 3])); + +v = uint8([1 2 3]); +v([3 2]) = []; +assert_checkequal(v, uint8(1)); + +v = int8([1 2 3]'); +v(2) = []; +assert_checkequal(v, int8([1 3]')); + +v = int8([1 2 3]'); +v([3 2]) = []; +assert_checkequal(v, int8(1)) + +v = int32([1 2 3;4 5 6]); +v(1,:) = []; +assert_checkequal(v, int32([4 5 6])); + +v = int32([1 2 3;4 5 6]); +v(:,[3 2]) = []; +assert_checkequal(v, int32([1;4])); //hidden empty index in insertion -a=int32([1 2;3 4]);a_ref=a; +a = int32([1 2;3 4]); +a_ref = a; -a(1,[%f %f])=[]; -if or(a<>a_ref) then pause,end -a([%f %f],1)=[]; -if or(a<>a_ref) then pause,end -a([%f %f],[%f %f])=[]; -if or(a<>a_ref) then pause,end +a(1,[%f %f]) = []; +assert_checkequal(a, a_ref); -a=int8([1 2;3 4]);a_ref=a; +a([%f %f],1) = []; +assert_checkequal(a, a_ref); -a(1,[%f %f])=[]; -if or(a<>a_ref) then pause,end -a([%f %f],1)=[]; -if or(a<>a_ref) then pause,end -a([%f %f],[%f %f])=[]; -if or(a<>a_ref) then pause,end +a([%f %f],[%f %f]) = []; +assert_checkequal(a, a_ref); +a = int8([1 2;3 4]); +a_ref = a; -//concatenations +a(1,[%f %f]) = []; +assert_checkequal(a, a_ref); -x1=int8(1);x2=int8(7); -if or([x1 x2]<>int8([1 7])) then pause,end -if or([x1;x2]<>int8([1;7])) then pause,end -if or([x1 []]<>int8([1])) then pause,end -if or([x1;[]]<>int8([1])) then pause,end -if or([[] x2]<>int8([7])) then pause,end -if or([[];x2]<>int8([7])) then pause,end -[x1,x2]=([x1 x2 x1 x2],[x2 x2 x1 x1]); - -if or([x1 x2]<>int8([1 7 1 7 7 7 1 1])) then pause,end -if or([x1;x2]<>int8([1 7 1 7;7 7 1 1])) then pause,end -if or([x1 []]<>int8([1 7 1 7])) then pause,end -if or([x1;[]]<>int8([1 7 1 7])) then pause,end -if or([[] x2]<>int8([7 7 1 1])) then pause,end -if or([[];x2]<>int8([7 7 1 1])) then pause,end - -n=300;x1=uint16(1:n); -if or([x1 x1]<>uint16([1:n 1:n])) then pause,end -if or([x1;x1]<>uint16([1:n;1:n])) then pause,end +a([%f %f],1) = []; +assert_checkequal(a, a_ref); + +a([%f %f],[%f %f]) = []; +assert_checkequal(a, a_ref); + + +//concatenations +x1 = int8(1); +x2 = int8(7); +assert_checkequal([x1 x2], int8([1 7])); +assert_checkequal([x1; x2], int8([1; 7])); +assert_checkequal([x1 []], int8(1)); +assert_checkequal([x1; []], int8(1)); +assert_checkequal([[], x2], int8(7)); +assert_checkequal([[]; x2], int8(7)); + +[x1, x2] = ([x1 x2 x1 x2],[x2 x2 x1 x1]); +assert_checkequal([x1 x2], int8([1 7 1 7 7 7 1 1])); +assert_checkequal([x1; x2], int8([1 7 1 7; 7 7 1 1])); +assert_checkequal([x1 []], int8([1 7 1 7])); +assert_checkequal([x1; []], int8([1 7 1 7])); +assert_checkequal([[] x2], int8([7 7 1 1])); +assert_checkequal([[]; x2], int8([7 7 1 1])); + +n = 300; +x1 = uint16(1:n); +assert_checkequal([x1 x1], uint16([1:n 1:n])); +assert_checkequal([x1; x1], uint16([1:n; 1:n])); //additions soustractions -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or(x1+x2<>int8(X1+X2)) then pause,end -if or(x1-x2<>int8(X1-X2)) then pause,end -X1=1:10;x1=int8(X1); -if or(x1+x2<>int8(X1+X2)) then pause,end -if or(x1-x2<>int8(X1-X2)) then pause,end -X2=2:11;x2=int8(X2); -if or(x1+x2<>int8(X1+X2)) then pause,end -if or(x1-x2<>int8(X1-X2)) then pause,end -if or(-x1<>int8(-(1:10))) then pause,end - -X2=[];x2=[] -if or(x1+x2<>int8(X1+X2)) then pause,end -if or(x1-x2<>int8(X1-X2)) then pause,end -if or(x2+x1<>int8(X2+X1)) then pause,end -if or(x2-x1<>int8(X2-X1)) then pause,end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); + +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); + +X2 = 2:11; x2 = int8(X2); +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); +assert_checkequal(-x1, int8(-X1)); + +X2 = []; x2 = []; +assert_checkequal(x1+x2, int8(X1+X2)); +assert_checkequal(x1-x2, int8(X1-X2)); +assert_checkequal(x2+x1, int8(X2+X1)); +assert_checkequal(x2-x1, int8(X2-X1)); + //multiplication -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or(x1*x2<>int8(X1*X2)) then pause,end -if or(x1.*x2<>int8(X1.*X2)) then pause,end -X1=1:10;x1=int8(X1); -if or(x1*x2<>int8(X1*X2)) then pause,end -if or(x2*x1<>int8(X2*X1)) then pause,end - -if or(x1.*x2<>int8(X1.*X2)) then pause,end -if or(x2.*x1<>int8(X2.*X1)) then pause,end -X2=-(1:10);x2=int8(X2); -if or(x1.*x2<>int8(X1.*X2)) then pause,end -if or(x1'*x2<>int8(X1'*X2)) then pause,end -if or(x1*x2'<>int8(X1*X2')) then pause,end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1 * x2, int8(X1 * X2)); +assert_checkequal(x1 .* x2, int8(X1 .* X2)); + +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1 * x2, int8(X1 * X2)); +assert_checkequal(x1 .* x2, int8(X1 .* X2)); +assert_checkequal(x2 * x1, int8(X2 * X1)); +assert_checkequal(x2 .* x1, int8(X2 .* X1)); + +X2 = -(1:10); x2 = int8(X2); +assert_checkequal(x1 .* x2, int8(X1 .* X2)); +assert_checkequal(x1' * x2, int8(X1' * X2)); +assert_checkequal(x1 * x2', int8(X1 * X2')); // comparaisons -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or((x1>x2)<>(X1>X2)) then pause,end -if or((x1>=x2)<>(X1>=X2)) then pause,end -if or((x1(X1(X1<=X2)) then pause,end -if or((x1<>x2)<>(X1<>X2)) then pause,end -X1=1:10;x1=int8(X1); -if or((x1>x2)<>(X1>X2)) then pause,end -if or((x1>=x2)<>(X1>=X2)) then pause,end -if or((x1(X1(X1<=X2)) then pause,end -if or((x1<>x2)<>(X1<>X2)) then pause,end - -X2=2:11;x2=int8(X2); -if or((x1>x2)<>(X1>X2)) then pause,end -if or((x1>=x2)<>(X1>=X2)) then pause,end -if or((x1(X1(X1<=X2)) then pause,end -if or((x1<>x2)<>(X1<>X2)) then pause,end - -X1=1;x1=int8(X1); -if or((x1>x2)<>(X1>X2)) then pause,end -if or((x1>=x2)<>(X1>=X2)) then pause,end -if or((x1(X1(X1<=X2)) then pause,end -if or((x1<>x2)<>(X1<>X2)) then pause,end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); + +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); + +X2 = 2:11;x2 = int8(X2); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); + +X1 = 1;x1 = int8(X1); +assert_checkequal(x1>x2, X1>X2); +assert_checkequal(x1>=x2, X1>=X2); +assert_checkequal(x1x2, X1<>X2); //division -X1=1;X2=7;x1=int8(X1);x2=int8(X2); -if or(x1/x2<>int8(0)) then pause,end -if or(x2/x1<>int8(7)) then pause,end -if or(x1\x2<>int8(7)) then pause,end -if or(x2\x1<>int8(0)) then pause,end -if or(x1./x2<>int8(0)) then pause,end -if or(x2./x1<>int8(7)) then pause,end -if or(x1.\x2<>int8(7)) then pause,end -if or(x2.\x1<>int8(0)) then pause,end - -X1=1:10;x1=int8(X1); -if or(x1/x2<>int8([0 0 0 0 0 0 1 1 1 1])) then pause,end +X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1/x2, int8(0)); +assert_checkequal(x2/x1, int8(7)); +assert_checkequal(x1\x2, int8(7)); +assert_checkequal(x2\x1, int8(0)); +assert_checkequal(x1./x2, int8(0)); +assert_checkequal(x2./x1, int8(7)); +assert_checkequal(x1.\x2, int8(7)); +assert_checkequal(x2.\x1, int8(0)); + +X1 = 1:10; x1 = int8(X1); +assert_checkequal(x1/x2, int8([0 0 0 0 0 0 1 1 1 1])); //if or(x2/x1<>int8([7 3 2 1 1 1 1 0 0 0])) then pause,end -if or(x1./x2<>int8([0 0 0 0 0 0 1 1 1 1])) then pause,end -if or(x2./x1<>int8([7 3 2 1 1 1 1 0 0 0])) then pause,end +assert_checkequal(x1./x2, int8([0 0 0 0 0 0 1 1 1 1])); +assert_checkequal(x2./x1, int8([7 3 2 1 1 1 1 0 0 0])); //if or(x1\x2<>int8([0 0 0 0 0 0 1 1 1 1])) then pause,end -if or(x1.\x2<>int8([7 3 2 1 1 1 1 0 0 0])) then pause,end -if or(x2\x1<> int8([0 0 0 0 0 0 1 1 1 1])) then pause,end -if or(x2.\x1<>int8([0 0 0 0 0 0 1 1 1 1])) then pause,end +assert_checkequal(x1.\x2, int8([7 3 2 1 1 1 1 0 0 0])); +assert_checkequal(x2\x1, int8([0 0 0 0 0 0 1 1 1 1])); +assert_checkequal(x2.\x1, int8([0 0 0 0 0 0 1 1 1 1])); + +X2 = -(1:10); x2 = int8(X2); +assert_checkequal(x1./x2, int8(-ones(1,10))); +assert_checkequal(x1.\x2, int8(-ones(1,10))); -X2=-(1:10);x2=int8(X2); -if or(x1./x2<>int8(-ones(1,10))) then pause,end -if or(x1.\x2<>int8(-ones(1,10))) then pause,end // puissance +X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1^x2, int8(X1^X2)); +assert_checkequal(x1.^x2, int8(X1.^X2)); + +X1 = 1:5; x1 = int8(X1); +assert_checkequal(x1.^x2, int8(X1.^X2)); +//if or(x1^x2<>int8(X1^X2)) then pause,end +X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2); +assert_checkequal(x1^x2, int8(X1^X2)); +assert_checkequal(x1.^x2, int8(X1.^X2)); -X1=2;X2=3;x1=int8(X1);x2=int8(X2); -if or(x1^x2<>int8(X1^X2)) then pause,end -if or(x1.^x2<>int8(X1.^X2)) then pause,end -X1=1:5;x1=int8(X1); -if or(x1^x2<>int8(X1^X2)) then pause,end -if or(x1.^x2<>int8(X1.^X2)) then pause,end -X1=2;x1=int8(X1);X2=(1:3);x2=int8(X2); -if or(x1^x2<>int8(X1^X2)) then pause,end -if or(x1.^x2<>int8(X1.^X2)) then pause,end -X1=2:4;x1=int8(X1); +//X1=2:4;x1=int8(X1); //if or(x1.^x2<>int8(X1.^X2)) then pause,end //kronecker -X1=2;X2=3;x1=int8(X1);x2=int8(X2); -if or(x1.*.x2<>int8(X1.*.X2)) then pause,end -X1=1:5;x1=int8(X1); -if or(x1.*.x2<>int8(X1.*.X2)) then pause,end -X1=2;x1=int8(X1);X2=(1:3);x2=int8(X2); -if or(x1.*.x2<>int8(X1.*.X2)) then pause,end -X1=(1:5)';x1=int8(X1); -if or(x1.*.x2<>int8(X1.*.X2)) then pause,end +X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); + +X1 = 1:5;x1 = int8(X1); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); + +X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); + +X1 = (1:5)';x1 = int8(X1); +assert_checkequal(x1.*.x2, int8(X1.*.X2)); //sum -X=round(10*rand(1,30)); +X = round(10 * rand(1,30)); deff('y=INT(x)','y=int16(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then pause,end -if or(sum(x')<>INT(sum(X'))) then pause,end -if or(cumsum(x)<>INT(cumsum(X))) then pause,end -if or(cumsum(x')<>INT(cumsum(X'))) then pause,end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); + deff('y=INT(x)','y=uint16(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then pause,end -if or(sum(x')<>INT(sum(X'))) then pause,end -if or(cumsum(x)<>INT(cumsum(X))) then pause,end -if or(cumsum(x')<>INT(cumsum(X'))) then pause,end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); + deff('y=INT(x)','y=uint8(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then pause,end -if or(sum(x')<>INT(sum(X'))) then pause,end -if or(cumsum(x)<>INT(cumsum(X))) then pause,end -if or(cumsum(x')<>INT(cumsum(X'))) then pause,end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); + deff('y=INT(x)','y=int8(x)') -x=INT(X); -if or(sum(x)<>INT(sum(X))) then pause,end -if or(sum(x')<>INT(sum(X'))) then pause,end -if or(cumsum(x)<>INT(cumsum(X))) then pause,end -if or(cumsum(x')<>INT(cumsum(X'))) then pause,end -X=round(10*rand(20,30)); -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then pause,end -if or(sum(x',1)<>INT(sum(X',1))) then pause,end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then pause,end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then pause,end +x = INT(X); +assert_checkequal(sum(x), INT(sum(X))); +assert_checkequal(sum(x'), INT(sum(X'))); +assert_checkequal(cumsum(x), INT(cumsum(X))); +assert_checkequal(cumsum(x'), INT(cumsum(X'))); + +X = round(10*rand(20,30)); +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); + deff('y=INT(x)','y=uint16(x)') -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then pause,end -if or(sum(x',1)<>INT(sum(X',1))) then pause,end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then pause,end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then pause,end +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); + deff('y=INT(x)','y=uint8(x)') -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then pause,end -if or(sum(x',1)<>INT(sum(X',1))) then pause,end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then pause,end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then pause,end +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); + deff('y=INT(x)','y=int8(x)') -x=INT(X); -if or(sum(x,1)<>INT(sum(X,1))) then pause,end -if or(sum(x',1)<>INT(sum(X',1))) then pause,end -if or(cumsum(x,1)<>INT(cumsum(X,1))) then pause,end -if or(cumsum(x',1)<>INT(cumsum(X',1))) then pause,end - -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then pause,end -if or(sum(x','c')<>INT(sum(X','c'))) then pause,end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then pause,end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then pause,end +x = INT(X); +assert_checkequal(sum(x, 1), INT(sum(X, 1))); +assert_checkequal(sum(x', 1), INT(sum(X', 1))); +assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); +assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); + +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); + deff('y=INT(x)','y=uint16(x)') -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then pause,end -if or(sum(x','c')<>INT(sum(X','c'))) then pause,end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then pause,end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then pause,end +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); + deff('y=INT(x)','y=uint8(x)') -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then pause,end -if or(sum(x','c')<>INT(sum(X','c'))) then pause,end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then pause,end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then pause,end +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); + deff('y=INT(x)','y=int8(x)') -x=INT(X); -if or(sum(x,'c')<>INT(sum(X,'c'))) then pause,end -if or(sum(x','c')<>INT(sum(X','c'))) then pause,end -if or(cumsum(x,'c')<>INT(cumsum(X,'c'))) then pause,end -if or(cumsum(x','c')<>INT(cumsum(X','c'))) then pause,end +x = INT(X); +assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); +assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); +assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); +assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); //diag triu tril deff('y=INT(x)','y=int16(x)') +X = round(10*rand(1,30)); +x = INT(X); -X=round(10*rand(1,30)); -x=INT(X); - -if or(diag(x)<>diag(X)) then pause,end -if or(diag(x,2)<>diag(X,2)) then pause,end -if or(diag(x,-2)<>diag(X,-2)) then pause,end +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); -if or(triu(x)<>triu(X)) then pause,end -if or(triu(x,2)<>triu(X,2)) then pause,end -if or(triu(x,-2)<>triu(X,-2)) then pause,end +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); -if or(tril(x)<>tril(X)) then pause,end -if or(tril(x,2)<>tril(X,2)) then pause,end -if or(tril(x,-2)<>tril(X,-2)) then pause,end +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); -X=round(10*rand(2,30)); -x=INT(X); +X = round(10*rand(2,30)); +x = INT(X); -if or(diag(x)<>diag(X)) then pause,end -if or(diag(x,2)<>diag(X,2)) then pause,end -if or(diag(x,-2)<>diag(X,-2)) then pause,end +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); -if or(triu(x)<>triu(X)) then pause,end -if or(triu(x,2)<>triu(X,2)) then pause,end -if or(triu(x,-2)<>triu(X,-2)) then pause,end +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); -if or(tril(x)<>tril(X)) then pause,end -if or(tril(x,2)<>tril(X,2)) then pause,end -if or(tril(x,-2)<>tril(X,-2)) then pause,end +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); deff('y=INT(x)','y=uint8(x)') -X=round(10*rand(1,30)); -x=INT(X); +X = round(10*rand(1,30)); +x = INT(X); -if or(diag(x)<>diag(X)) then pause,end -if or(diag(x,2)<>diag(X,2)) then pause,end -if or(diag(x,-2)<>diag(X,-2)) then pause,end +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); -if or(triu(x)<>triu(X)) then pause,end -if or(triu(x,2)<>triu(X,2)) then pause,end -if or(triu(x,-2)<>triu(X,-2)) then pause,end +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); -if or(tril(x)<>tril(X)) then pause,end -if or(tril(x,2)<>tril(X,2)) then pause,end -if or(tril(x,-2)<>tril(X,-2)) then pause,end +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); -X=round(10*rand(2,30)); -x=INT(X); +X = round(10*rand(2,30)); +x = INT(X); -if or(diag(x)<>diag(X)) then pause,end -if or(diag(x,2)<>diag(X,2)) then pause,end -if or(diag(x,-2)<>diag(X,-2)) then pause,end +assert_checktrue(diag(x) == diag(X)); +assert_checktrue(diag(x, 2) == diag(X, 2)); +assert_checktrue(diag(x, -2) == diag(X, -2)); -if or(triu(x)<>triu(X)) then pause,end -if or(triu(x,2)<>triu(X,2)) then pause,end -if or(triu(x,-2)<>triu(X,-2)) then pause,end +assert_checktrue(triu(x) == triu(X)); +assert_checktrue(triu(x, 2) == triu(X, 2)); +assert_checktrue(triu(x, -2) == triu(X, -2)); -if or(tril(x)<>tril(X)) then pause,end -if or(tril(x,2)<>tril(X,2)) then pause,end -if or(tril(x,-2)<>tril(X,-2)) then pause,end +assert_checktrue(tril(x) == tril(X)); +assert_checktrue(tril(x, 2) == tril(X, 2)); +assert_checktrue(tril(x, -2) == tril(X, -2)); // save load deff('y=INT(x)','y=uint8(x)') -X=round(10*rand(1,30)); -x=INT(X); +X = round(10*rand(1,30)); +x = INT(X); save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>INT(X)) then pause,end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, INT(X)); x=list(1,x,2);save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>list(1,INT(X),2)) then pause,end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, list(1, INT(X), 2)); deff('y=INT(x)','y=int32(x)') -X=round(10*rand(1,30)); -x=INT(X); +X = round(10*rand(1,30)); +x = INT(X); save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>INT(X)) then pause,end +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, INT(X)); x=list(1,x,2);save(TMPDIR+'/foo','x') -clear x;load(TMPDIR+'/foo');if or(x<>list(1,INT(X),2)) then pause,end - +clear x; +load(TMPDIR+'/foo'); +assert_checkequal(x, list(1, INT(X), 2)); //abs deff('y=INT(x)','y=int8(x)') -X=round(10*rand(1,30))-5; -x=INT(X); - -if or(abs(x)<>INT(abs(X))) then pause,end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(abs(x), INT(abs(X))); deff('y=INT(x)','y=int16(x)') -X=round(10*rand(1,30))-5; -x=INT(X); - -if or(abs(x)<>INT(abs(X))) then pause,end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(abs(x), INT(abs(X))); //matrix deff('y=INT(x)','y=int8(x)') -X=round(10*rand(1,30))-5; -x=INT(X); - -if or(matrix(x,10,-1)<>INT(matrix(X,10,-1))) then pause,end -if or(matrix(x,10,3)<>INT(matrix(X,10,3))) then pause,end -if or(matrix(x,-1,3)<>INT(matrix(X,-1,3))) then pause,end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1))); +assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3))); +assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3))); deff('y=INT(x)','y=uint8(x)') -X=round(10*rand(1,30))-5; -x=INT(X); - -if or(matrix(x,10,-1)<>INT(matrix(X,10,-1))) then pause,end -if or(matrix(x,10,3)<>INT(matrix(X,10,3))) then pause,end -if or(matrix(x,-1,3)<>INT(matrix(X,-1,3))) then pause,end +X = round(10*rand(1,30))-5; +x = INT(X); +assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1))); +assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3))); +assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3))); //max min deff('y=INT(x)','y=int8(x)') -X=round(10*rand(2,30))-5; -Y=ones(2,30); -x=INT(X); -y=INT(Y); -if or(max(x)<>INT(max(X))) then pause,end -if or(max(x,'r')<>INT(max(X,'r'))) then pause,end -if or(max(x,'c')<>INT(max(X,'c'))) then pause,end -if or(max(x,INT(2))<>INT(max(X,2))) then pause,end -if or(max(x,y)<>INT(max(X,Y))) then pause,end - -if or(min(x)<>INT(min(X))) then pause,end -if or(min(x,'r')<>INT(min(X,'r'))) then pause,end -if or(min(x,'c')<>INT(min(X,'c'))) then pause,end -if or(min(x,INT(2))<>INT(min(X,2))) then pause,end -if or(min(x,y)<>INT(min(X,Y))) then pause,end - - -a=[0 3 7]; -b=[1 2 7]; -A=[0 3 7 5; +X = round(10*rand(2,30))-5; +Y = ones(2,30); +x = INT(X); +y = INT(Y); +assert_checkequal(max(x), INT(max(X))); +assert_checkequal(max(x, "r"), INT(max(X, "r"))); +assert_checkequal(max(x, "c"), INT(max(X, "c"))); +assert_checkequal(max(x, INT(2)), INT(max(X, 2))); +assert_checkequal(max(x, y), INT(max(X, Y))); + +assert_checkequal(min(x), INT(min(X))); +assert_checkequal(min(x, "r"), INT(min(X, "r"))); +assert_checkequal(min(x, "c"), INT(min(X, "c"))); +assert_checkequal(min(x, INT(2)), INT(min(X, 2))); +assert_checkequal(min(x, y), INT(min(X, Y))); + +a = [0 3 7]; +b = [1 2 7]; +A = [0 3 7 5; 1 2 0 2 8 9 3 1]; -types=['double','int32','uint32','int16','uint16','int8','uint8'] +types=['double','int32','uint32','int16','uint16','int8','uint8']; // checking max(a,b) -[mx,kx]=max(a,b); -for t1=types - for t2=types +[mx, kx] = max(a, b); +for t1 = types + for t2 = types execstr('at='+t1+'(a); bt='+t2+'(b);') - [mt,kt]=max(at,bt); + [mt, kt] = max(at, bt); if or(kt<>kx)|or(mx<>double(mt)) then disp('max('+t1+','+t2+')'),pause end @@ -512,7 +596,7 @@ for t1=types end // checking max(A) -[mx,kx]=max(A) +[mx,kx]=max(A); for t1=types execstr('At='+t1+'(A);') [mt,kt]=max(At); @@ -522,7 +606,7 @@ for t1=types end // checking min(A) -[mx,kx]=min(A) +[mx,kx]=min(A); for t1=types execstr('At='+t1+'(A);') [mt,kt]=min(At); @@ -533,7 +617,7 @@ end // checking max(A,'r') -[mx,kx]=max(A,'r') +[mx,kx]=max(A,'r'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=max(At,'r'); @@ -543,7 +627,7 @@ for t1=types end // checking min(A,'r') -[mx,kx]=min(A,'r') +[mx,kx]=min(A,'r'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=min(At,'r'); @@ -553,7 +637,7 @@ for t1=types end // checking max(A,'c') -[mx,kx]=max(A,'c') +[mx,kx]=max(A,'c'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=max(At,'c'); @@ -563,7 +647,7 @@ for t1=types end // checking min(A,'c') -[mx,kx]=min(A,'c') +[mx,kx]=min(A,'c'); for t1=types execstr('At='+t1+'(A);') [mt,kt]=min(At,'c'); -- 1.7.9.5