summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel GOUGEON <sgougeon@free.fr>2016-06-30 15:26:22 +0200
committerAntoine ELIAS <antoine.elias@scilab-enterprises.com>2016-11-04 16:41:10 +0100
commit75d8021cfc5be101837dea0011a49ca00df57051 (patch)
treebeb97d80d747fa454d52f2d5abfe58881e00527e
parent8fb47ec75806d33a2e3a510c451fa4e002007fa0 (diff)
downloadscilab-75d8021cfc5be101837dea0011a49ca00df57051.zip
scilab-75d8021cfc5be101837dea0011a49ca00df57051.tar.gz
* Bug #14306 fixed: > and >= were not implemented between mismatching inttypes
http://bugzilla.scilab.org/14306 Change-Id: I82821d751ca1201771c35e624c3278060b6ddc5a
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/integer/tests/nonreg_tests/bug_14306.dia.ref18
-rw-r--r--scilab/modules/integer/tests/nonreg_tests/bug_14306.tst19
-rw-r--r--scilab/modules/integer/tests/unit_tests/intops.dia.ref248
-rw-r--r--scilab/modules/integer/tests/unit_tests/intops.tst113
-rw-r--r--scilab/modules/overloading/macros/%i_2_i.sci16
-rw-r--r--scilab/modules/overloading/macros/%i_4_i.sci16
7 files changed, 374 insertions, 57 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index b4c8e4a..124129e 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -349,6 +349,7 @@ Bug Fixes
349* [#13895](http://bugzilla.scilab.org/show_bug.cgi?id=13895): p.a.h = 1; p.b.h = 3; p(:).h CRASH 349* [#13895](http://bugzilla.scilab.org/show_bug.cgi?id=13895): p.a.h = 1; p.b.h = 3; p(:).h CRASH
350* [#13990](http://bugzilla.scilab.org/show_bug.cgi?id=13990): `warning` with localization enabled some memory corruption 350* [#13990](http://bugzilla.scilab.org/show_bug.cgi?id=13990): `warning` with localization enabled some memory corruption
351* [#14192](http://bugzilla.scilab.org/show_bug.cgi?id=14192): `g_margin` error-ed for double integrator. 351* [#14192](http://bugzilla.scilab.org/show_bug.cgi?id=14192): `g_margin` error-ed for double integrator.
352* [#14306](http://bugzilla.scilab.org/show_bug.cgi?id=14306): Comparisons `>` and `>=` between integers of mismatching inttypes were not implemented.
352* [#14367](http://bugzilla.scilab.org/show_bug.cgi?id=14367): `edit_curv` failed opening due to a `[]+1` operation. 353* [#14367](http://bugzilla.scilab.org/show_bug.cgi?id=14367): `edit_curv` failed opening due to a `[]+1` operation.
353* [#14379](http://bugzilla.scilab.org/show_bug.cgi?id=14379): Problem with lists of functions having 2 arguments. 354* [#14379](http://bugzilla.scilab.org/show_bug.cgi?id=14379): Problem with lists of functions having 2 arguments.
354* [#14395](http://bugzilla.scilab.org/show_bug.cgi?id=14395): `dir` displayed a []+".." warning when no subdirectory exists. 355* [#14395](http://bugzilla.scilab.org/show_bug.cgi?id=14395): `dir` displayed a []+".." warning when no subdirectory exists.
diff --git a/scilab/modules/integer/tests/nonreg_tests/bug_14306.dia.ref b/scilab/modules/integer/tests/nonreg_tests/bug_14306.dia.ref
new file mode 100644
index 0000000..8de3d65
--- /dev/null
+++ b/scilab/modules/integer/tests/nonreg_tests/bug_14306.dia.ref
@@ -0,0 +1,18 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Antoine ELIAS
4//
5// This file is distributed under the same license as the Scilab package.
6// ===========================================================================
7//
8// <-- Non-regression test for bug 14306 -->
9//
10// <-- CLI SHELL MODE -->
11//
12// <-- Bugzilla URL -->
13// http://bugzilla.scilab.org/14306
14//
15// <-- Short Description -->
16// Comparisons `>` and `>=` between integers of mismatching inttypes were not
17// implemented.
18assert_checktrue(int8(3) > int16(1));
diff --git a/scilab/modules/integer/tests/nonreg_tests/bug_14306.tst b/scilab/modules/integer/tests/nonreg_tests/bug_14306.tst
new file mode 100644
index 0000000..bd0fab6
--- /dev/null
+++ b/scilab/modules/integer/tests/nonreg_tests/bug_14306.tst
@@ -0,0 +1,19 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Antoine ELIAS
4//
5// This file is distributed under the same license as the Scilab package.
6// ===========================================================================
7//
8// <-- Non-regression test for bug 14306 -->
9//
10// <-- CLI SHELL MODE -->
11//
12// <-- Bugzilla URL -->
13// http://bugzilla.scilab.org/14306
14//
15// <-- Short Description -->
16// Comparisons `>` and `>=` between integers of mismatching inttypes were not
17// implemented.
18
19assert_checktrue(int8(3) > int16(1));
diff --git a/scilab/modules/integer/tests/unit_tests/intops.dia.ref b/scilab/modules/integer/tests/unit_tests/intops.dia.ref
index 6eb8451..1938aaf 100644
--- a/scilab/modules/integer/tests/unit_tests/intops.dia.ref
+++ b/scilab/modules/integer/tests/unit_tests/intops.dia.ref
@@ -2,10 +2,13 @@
2// ============================================================================= 2// =============================================================================
3// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4// Copyright (C) ????-2008 - INRIA 4// Copyright (C) ????-2008 - INRIA
5// Copyright (C) 2016 - Samuel GOUGEON
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
9
8funcprot(0); 10funcprot(0);
11
9//extractions 12//extractions
10warning("off"); //WARNING_EMPTY_OPS 13warning("off"); //WARNING_EMPTY_OPS
11v=int8([1 2 3]); 14v=int8([1 2 3]);
@@ -14,12 +17,14 @@ assert_checkequal(v([1 3]), int8([1 3]));
14assert_checkequal(v([3 3]), int8([3 3])); 17assert_checkequal(v([3 3]), int8([3 3]));
15assert_checkequal(v(:), int8([1 2 3]')); 18assert_checkequal(v(:), int8([1 2 3]'));
16assert_checkequal(v([]), []); 19assert_checkequal(v([]), []);
20
17v=int32([1 2 3;4 5 6]); 21v=int32([1 2 3;4 5 6]);
18assert_checktrue(v(2) == int8(4)); 22assert_checktrue(v(2) == int8(4));
19assert_checktrue(v([1 3]) == int8([1;2])); 23assert_checktrue(v([1 3]) == int8([1;2]));
20assert_checktrue(v([3 3]) == int8([2;2])); 24assert_checktrue(v([3 3]) == int8([2;2]));
21assert_checktrue(v(:) == int8([1;4;2;5;3;6])); 25assert_checktrue(v(:) == int8([1;4;2;5;3;6]));
22assert_checktrue(v([]) == []); 26assert_checktrue(v([]) == []);
27
23assert_checktrue(v(2,1) == int8(4)); 28assert_checktrue(v(2,1) == int8(4));
24assert_checktrue(v(1,[1 3]) == int8([1 3])); 29assert_checktrue(v(1,[1 3]) == int8([1 3]));
25assert_checktrue(v(1,[3 3]) == int8([3 3])); 30assert_checktrue(v(1,[3 3]) == int8([3 3]));
@@ -27,125 +32,177 @@ assert_checktrue(v(1,:) == int8([1 2 3]));
27assert_checktrue(v(:,2) == int8([2;5])); 32assert_checktrue(v(:,2) == int8([2;5]));
28assert_checktrue(v([1 1],:) == int8([1 2 3;1 2 3])); 33assert_checktrue(v([1 1],:) == int8([1 2 3;1 2 3]));
29assert_checktrue(v(:,[2 1]) == int8([2 1;5 4])); 34assert_checktrue(v(:,[2 1]) == int8([2 1;5 4]));
35
30assert_checktrue(v(1,1:$) == int8([1 2 3])); 36assert_checktrue(v(1,1:$) == int8([1 2 3]));
31assert_checktrue(v(1:$,2) == int8([2;5])); 37assert_checktrue(v(1:$,2) == int8([2;5]));
32assert_checktrue(v([1 1],1:$) == int8([1 2 3;1 2 3])); 38assert_checktrue(v([1 1],1:$) == int8([1 2 3;1 2 3]));
33assert_checktrue(v(1:$,[2 1]) == int8([2 1;5 4])); 39assert_checktrue(v(1:$,[2 1]) == int8([2 1;5 4]));
40
34//insertion 41//insertion
35v = int8([1 2 3]); 42v = int8([1 2 3]);
36v(2) = int8(3); 43v(2) = int8(3);
37assert_checkequal(v, int8([1 3 3])); 44assert_checkequal(v, int8([1 3 3]));
45
38v(4) = int8(-5); 46v(4) = int8(-5);
39assert_checkequal(v, int8([1 3 3 -5])); 47assert_checkequal(v, int8([1 3 3 -5]));
48
40v([1 4]) = int8([2 5]); 49v([1 4]) = int8([2 5]);
41assert_checkequal(v, int8([2 3 3 5])); 50assert_checkequal(v, int8([2 3 3 5]));
51
42v([1 1]) = int8([2 5]); 52v([1 1]) = int8([2 5]);
43assert_checkequal(v, int8([5 3 3 5])); 53assert_checkequal(v, int8([5 3 3 5]));
54
44v([1 1 1 1 1 1]) = int8([2 5 6 7 8 9]); 55v([1 1 1 1 1 1]) = int8([2 5 6 7 8 9]);
45assert_checkequal(v, int8([9 3 3 5])); 56assert_checkequal(v, int8([9 3 3 5]));
57
46v([4 2]) = int8([8 5]); 58v([4 2]) = int8([8 5]);
47assert_checkequal(v, int8([9 5 3 8])); 59assert_checkequal(v, int8([9 5 3 8]));
60
48v = uint16([1 2 3]); 61v = uint16([1 2 3]);
49v(2) = uint16(3); 62v(2) = uint16(3);
50assert_checkequal(v, uint16([1 3 3])); 63assert_checkequal(v, uint16([1 3 3]));
64
51v(4) = uint16(-5); 65v(4) = uint16(-5);
52assert_checkequal(v, uint16([1 3 3 -5])); 66assert_checkequal(v, uint16([1 3 3 -5]));
67
53v([1 4]) = uint16([2 5]); 68v([1 4]) = uint16([2 5]);
54assert_checkequal(v, uint16([2 3 3 5])); 69assert_checkequal(v, uint16([2 3 3 5]));
70
55v([1 1]) = uint16([2 5]); 71v([1 1]) = uint16([2 5]);
56assert_checkequal(v, uint16([5 3 3 5])); 72assert_checkequal(v, uint16([5 3 3 5]));
73
57v([1 1 1 1 1 1]) = uint16([2 5 6 7 8 9]); 74v([1 1 1 1 1 1]) = uint16([2 5 6 7 8 9]);
58assert_checkequal(v, uint16([9 3 3 5])); 75assert_checkequal(v, uint16([9 3 3 5]));
76
59v([4 2]) = uint16([8 5]); 77v([4 2]) = uint16([8 5]);
60assert_checkequal(v, uint16([9 5 3 8])); 78assert_checkequal(v, uint16([9 5 3 8]));
79
61v = uint8([1 2 3]); 80v = uint8([1 2 3]);
62v(2,4) = uint8(10); 81v(2,4) = uint8(10);
63assert_checkequal(v, uint8([1 2 3 0;0 0 0 10])); 82assert_checkequal(v, uint8([1 2 3 0;0 0 0 10]));
83
64v([2 2],4) = uint8([10;20]); 84v([2 2],4) = uint8([10;20]);
65assert_checkequal(v, uint8([1 2 3 0;0 0 0 20])); 85assert_checkequal(v, uint8([1 2 3 0;0 0 0 20]));
86
66v([2 1],4) = uint8([10;20]); 87v([2 1],4) = uint8([10;20]);
67assert_checkequal(v, uint8([1 2 3 20;0 0 0 10])); 88assert_checkequal(v, uint8([1 2 3 20;0 0 0 10]));
89
68v([2 2 2],4) = uint8([10;20;30]); 90v([2 2 2],4) = uint8([10;20;30]);
69assert_checkequal(v, uint8([1 2 3 20;0 0 0 30])); 91assert_checkequal(v, uint8([1 2 3 20;0 0 0 30]));
92
70v = int32([1 2 3]); 93v = int32([1 2 3]);
71v(2,4) = int32(10); 94v(2,4) = int32(10);
72assert_checkequal(v, int32([1 2 3 0;0 0 0 10])); 95assert_checkequal(v, int32([1 2 3 0;0 0 0 10]));
96
73v([2 2],4) = int32([10;20]); 97v([2 2],4) = int32([10;20]);
74assert_checkequal(v, int32([1 2 3 0;0 0 0 20])); 98assert_checkequal(v, int32([1 2 3 0;0 0 0 20]));
99
75v([2 1],4) = int32([10;20]); 100v([2 1],4) = int32([10;20]);
76assert_checkequal(v, int32([1 2 3 20;0 0 0 10])); 101assert_checkequal(v, int32([1 2 3 20;0 0 0 10]));
102
77v([2 2 2],4) = int32([10;20;30]); 103v([2 2 2],4) = int32([10;20;30]);
78assert_checkequal(v, int32([1 2 3 20;0 0 0 30])); 104assert_checkequal(v, int32([1 2 3 20;0 0 0 30]));
105
79v = int16([1 2 3;0 0 10]); 106v = int16([1 2 3;0 0 10]);
80v(1,[1 1 1 1]) = int16(1:4); 107v(1,[1 1 1 1]) = int16(1:4);
81assert_checkequal(v, int16([4 2 3;0 0 10])); 108assert_checkequal(v, int16([4 2 3;0 0 10]));
109
82v([2 2],[1 1 1 1]) = int16([1:4;2:5]); 110v([2 2],[1 1 1 1]) = int16([1:4;2:5]);
83assert_checkequal(v, int16([4 2 3;5 0 10])); 111assert_checkequal(v, int16([4 2 3;5 0 10]));
112
84v(3,4) = int16(7); 113v(3,4) = int16(7);
85assert_checkequal(v, int16([4 2 3 0;5 0 10 0;0 0 0 7])); 114assert_checkequal(v, int16([4 2 3 0;5 0 10 0;0 0 0 7]));
115
86v = uint32([1 2 3;0 0 10]); 116v = uint32([1 2 3;0 0 10]);
87v(1,[1 1 1 1]) = uint32(1:4); 117v(1,[1 1 1 1]) = uint32(1:4);
88assert_checkequal(v, uint32([4 2 3;0 0 10])); 118assert_checkequal(v, uint32([4 2 3;0 0 10]));
119
89v([2 2],[1 1 1 1]) = uint32([1:4;2:5]); 120v([2 2],[1 1 1 1]) = uint32([1:4;2:5]);
90assert_checkequal(v, uint32([4 2 3;5 0 10])); 121assert_checkequal(v, uint32([4 2 3;5 0 10]));
122
91v(3,4) = uint32(7); 123v(3,4) = uint32(7);
92assert_checkequal(v, uint32([4 2 3 0;5 0 10 0;0 0 0 7])); 124assert_checkequal(v, uint32([4 2 3 0;5 0 10 0;0 0 0 7]));
125
93v = []; 126v = [];
94v(5) = int8(1); 127v(5) = int8(1);
95assert_checkequal(v, int8([0;0;0;0;1])); 128assert_checkequal(v, int8([0;0;0;0;1]));
129
96v(2) = int8(4); 130v(2) = int8(4);
97assert_checkequal(v, int8([0;4;0;0;1])); 131assert_checkequal(v, int8([0;4;0;0;1]));
132
98v = uint16([1 2 3;4 5 6]); 133v = uint16([1 2 3;4 5 6]);
99v(:,1) = uint16([4;1]); 134v(:,1) = uint16([4;1]);
100assert_checkequal(v, uint16([4 2 3;1 5 6])); 135assert_checkequal(v, uint16([4 2 3;1 5 6]));
136
101v(:,[1 1]) = uint16([4 5;1 2]); 137v(:,[1 1]) = uint16([4 5;1 2]);
102assert_checkequal(v, uint16([5 2 3;2 5 6])); 138assert_checkequal(v, uint16([5 2 3;2 5 6]));
139
103v(:,[3 1]) = uint16([4 5;1 2]); 140v(:,[3 1]) = uint16([4 5;1 2]);
104assert_checkequal(v, uint16([5 2 4;2 5 1])); 141assert_checkequal(v, uint16([5 2 4;2 5 1]));
142
105v(:,[3 3 3 3]) = uint16([4 5 6 7;1 2 3 4]); 143v(:,[3 3 3 3]) = uint16([4 5 6 7;1 2 3 4]);
106assert_checkequal(v, uint16([5 2 7;2 5 4])); 144assert_checkequal(v, uint16([5 2 7;2 5 4]));
145
107v = int8([1 2 3;4 5 6]); 146v = int8([1 2 3;4 5 6]);
108v(1,:) = int8([2 3 4]); 147v(1,:) = int8([2 3 4]);
109assert_checkequal(v, int8([2 3 4;4 5 6])); 148assert_checkequal(v, int8([2 3 4;4 5 6]));
149
110v([1 1],:) = int8([2 3 4;4 5 6]); 150v([1 1],:) = int8([2 3 4;4 5 6]);
111assert_checkequal(v, int8([4 5 6;4 5 6])); 151assert_checkequal(v, int8([4 5 6;4 5 6]));
152
112v([2 2 2 2],:) = int8([2 3 4;4 5 6;7 8 9;10 11 12]); 153v([2 2 2 2],:) = int8([2 3 4;4 5 6;7 8 9;10 11 12]);
113assert_checkequal(v, int8([4 5 6;10 11 12])); 154assert_checkequal(v, int8([4 5 6;10 11 12]));
155
114v = uint8([1 2 3]); 156v = uint8([1 2 3]);
115v(2) = []; 157v(2) = [];
116assert_checkequal(v, uint8([1 3])); 158assert_checkequal(v, uint8([1 3]));
159
117v = uint8([1 2 3]); 160v = uint8([1 2 3]);
118v([3 2]) = []; 161v([3 2]) = [];
119assert_checkequal(v, uint8(1)); 162assert_checkequal(v, uint8(1));
163
120v = int8([1 2 3]'); 164v = int8([1 2 3]');
121v(2) = []; 165v(2) = [];
122assert_checkequal(v, int8([1 3]')); 166assert_checkequal(v, int8([1 3]'));
167
123v = int8([1 2 3]'); 168v = int8([1 2 3]');
124v([3 2]) = []; 169v([3 2]) = [];
125assert_checkequal(v, int8(1)); 170assert_checkequal(v, int8(1));
171
126v = int32([1 2 3;4 5 6]); 172v = int32([1 2 3;4 5 6]);
127v(1,:) = []; 173v(1,:) = [];
128assert_checkequal(v, int32([4 5 6])); 174assert_checkequal(v, int32([4 5 6]));
175
129v = int32([1 2 3;4 5 6]); 176v = int32([1 2 3;4 5 6]);
130v(:,[3 2]) = []; 177v(:,[3 2]) = [];
131assert_checkequal(v, int32([1;4])); 178assert_checkequal(v, int32([1;4]));
179
132//hidden empty index in insertion 180//hidden empty index in insertion
133a = int32([1 2;3 4]); 181a = int32([1 2;3 4]);
134a_ref = a; 182a_ref = a;
183
135a(1,[%f %f]) = []; 184a(1,[%f %f]) = [];
136assert_checkequal(a, a_ref); 185assert_checkequal(a, a_ref);
186
137a([%f %f],1) = []; 187a([%f %f],1) = [];
138assert_checkequal(a, a_ref); 188assert_checkequal(a, a_ref);
189
139a([%f %f],[%f %f]) = []; 190a([%f %f],[%f %f]) = [];
140assert_checkequal(a, a_ref); 191assert_checkequal(a, a_ref);
192
141a = int8([1 2;3 4]); 193a = int8([1 2;3 4]);
142a_ref = a; 194a_ref = a;
195
143a(1,[%f %f]) = []; 196a(1,[%f %f]) = [];
144assert_checkequal(a, a_ref); 197assert_checkequal(a, a_ref);
198
145a([%f %f],1) = []; 199a([%f %f],1) = [];
146assert_checkequal(a, a_ref); 200assert_checkequal(a, a_ref);
201
147a([%f %f],[%f %f]) = []; 202a([%f %f],[%f %f]) = [];
148assert_checkequal(a, a_ref); 203assert_checkequal(a, a_ref);
204
205
149//concatenations 206//concatenations
150x1 = int8(1); 207x1 = int8(1);
151x2 = int8(7); 208x2 = int8(7);
@@ -155,6 +212,7 @@ assert_checkequal([x1 []], int8(1));
155assert_checkequal([x1; []], int8(1)); 212assert_checkequal([x1; []], int8(1));
156assert_checkequal([[], x2], int8(7)); 213assert_checkequal([[], x2], int8(7));
157assert_checkequal([[]; x2], int8(7)); 214assert_checkequal([[]; x2], int8(7));
215
158[x1, x2] = ([x1 x2 x1 x2],[x2 x2 x1 x1]); 216[x1, x2] = ([x1 x2 x1 x2],[x2 x2 x1 x1]);
159assert_checkequal([x1 x2], int8([1 7 1 7 7 7 1 1])); 217assert_checkequal([x1 x2], int8([1 7 1 7 7 7 1 1]));
160assert_checkequal([x1; x2], int8([1 7 1 7; 7 7 1 1])); 218assert_checkequal([x1; x2], int8([1 7 1 7; 7 7 1 1]));
@@ -162,64 +220,134 @@ assert_checkequal([x1 []], int8([1 7 1 7]));
162assert_checkequal([x1; []], int8([1 7 1 7])); 220assert_checkequal([x1; []], int8([1 7 1 7]));
163assert_checkequal([[] x2], int8([7 7 1 1])); 221assert_checkequal([[] x2], int8([7 7 1 1]));
164assert_checkequal([[]; x2], int8([7 7 1 1])); 222assert_checkequal([[]; x2], int8([7 7 1 1]));
223
165n = 300; 224n = 300;
166x1 = uint16(1:n); 225x1 = uint16(1:n);
167assert_checkequal([x1 x1], uint16([1:n 1:n])); 226assert_checkequal([x1 x1], uint16([1:n 1:n]));
168assert_checkequal([x1; x1], uint16([1:n; 1:n])); 227assert_checkequal([x1; x1], uint16([1:n; 1:n]));
228
169//additions soustractions 229//additions soustractions
170X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); 230X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2);
171assert_checkequal(x1+x2, int8(X1+X2)); 231assert_checkequal(x1+x2, int8(X1+X2));
172assert_checkequal(x1-x2, int8(X1-X2)); 232assert_checkequal(x1-x2, int8(X1-X2));
233
173X1 = 1:10; x1 = int8(X1); 234X1 = 1:10; x1 = int8(X1);
174assert_checkequal(x1+x2, int8(X1+X2)); 235assert_checkequal(x1+x2, int8(X1+X2));
175assert_checkequal(x1-x2, int8(X1-X2)); 236assert_checkequal(x1-x2, int8(X1-X2));
237
176X2 = 2:11; x2 = int8(X2); 238X2 = 2:11; x2 = int8(X2);
177assert_checkequal(x1+x2, int8(X1+X2)); 239assert_checkequal(x1+x2, int8(X1+X2));
178assert_checkequal(x1-x2, int8(X1-X2)); 240assert_checkequal(x1-x2, int8(X1-X2));
179assert_checkequal(-x1, int8(-X1)); 241assert_checkequal(-x1, int8(-X1));
242
180X2 = []; x2 = []; 243X2 = []; x2 = [];
181assert_checkequal(x1+x2, int8(X1+X2)); 244assert_checkequal(x1+x2, int8(X1+X2));
182assert_checkequal(x1-x2, int8(X1-X2)); 245assert_checkequal(x1-x2, int8(X1-X2));
183assert_checkequal(x2+x1, int8(X2+X1)); 246assert_checkequal(x2+x1, int8(X2+X1));
184assert_checkequal(x2-x1, int8(X2-X1)); 247assert_checkequal(x2-x1, int8(X2-X1));
248
185//multiplication 249//multiplication
186X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); 250X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2);
187assert_checkequal(x1 * x2, int8(X1 * X2)); 251assert_checkequal(x1 * x2, int8(X1 * X2));
188assert_checkequal(x1 .* x2, int8(X1 .* X2)); 252assert_checkequal(x1 .* x2, int8(X1 .* X2));
253
189X1 = 1:10; x1 = int8(X1); 254X1 = 1:10; x1 = int8(X1);
190assert_checkequal(x1 * x2, int8(X1 * X2)); 255assert_checkequal(x1 * x2, int8(X1 * X2));
191assert_checkequal(x1 .* x2, int8(X1 .* X2)); 256assert_checkequal(x1 .* x2, int8(X1 .* X2));
192assert_checkequal(x2 * x1, int8(X2 * X1)); 257assert_checkequal(x2 * x1, int8(X2 * X1));
193assert_checkequal(x2 .* x1, int8(X2 .* X1)); 258assert_checkequal(x2 .* x1, int8(X2 .* X1));
259
194X2 = -(1:10); x2 = int8(X2); 260X2 = -(1:10); x2 = int8(X2);
195assert_checkequal(x1 .* x2, int8(X1 .* X2)); 261assert_checkequal(x1 .* x2, int8(X1 .* X2));
196assert_checkequal(x1' * x2, int8(X1' * X2)); 262assert_checkequal(x1' * x2, int8(X1' * X2));
197assert_checkequal(x1 * x2', int8(X1 * X2')); 263assert_checkequal(x1 * x2', int8(X1 * X2'));
198// comparaisons 264
199X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); 265// Implicit conversions by a*b, a/b, a+b, a-b
200assert_checkequal(x1>x2, X1>X2); 266icodes = [ 1 2 4 8 11 12 14 18];
201assert_checkequal(x1>=x2, X1>=X2); 267for i = 1:8
202assert_checkequal(x1<x2, X1<X2); 268 for j = i:8
203assert_checkequal(x1<=x2, X1<=X2); 269 ic = icodes(i);
204assert_checkequal(x1<>x2, X1<>X2); 270 jc = icodes(j);
205X1 = 1:10; x1 = int8(X1); 271 if ic<10 & jc<10 | ic>10 & jc>10
206assert_checkequal(x1>x2, X1>X2); 272 expected = max(ic,jc);
207assert_checkequal(x1>=x2, X1>=X2); 273 else
208assert_checkequal(x1<x2, X1<X2); 274 expected = 10 + max(modulo([ic jc],10));
209assert_checkequal(x1<=x2, X1<=X2); 275 end
210assert_checkequal(x1<>x2, X1<>X2); 276 ap = iconvert(120,ic);
211X2 = 2:11;x2 = int8(X2); 277 am = iconvert(-125,ic);
212assert_checkequal(x1>x2, X1>X2); 278 bp = iconvert(120,jc);
213assert_checkequal(x1>=x2, X1>=X2); 279 bm = iconvert(-125,jc);
214assert_checkequal(x1<x2, X1<X2); 280 // *
215assert_checkequal(x1<=x2, X1<=X2); 281 assert_checkequal(inttype(ap*bp), expected);
216assert_checkequal(x1<>x2, X1<>X2); 282 assert_checkequal(inttype(am*bp), expected);
217X1 = 1;x1 = int8(X1); 283 assert_checkequal(inttype(ap*bm), expected);
218assert_checkequal(x1>x2, X1>X2); 284 assert_checkequal(inttype(am*bm), expected);
219assert_checkequal(x1>=x2, X1>=X2); 285 // +
220assert_checkequal(x1<x2, X1<X2); 286 assert_checkequal(inttype(ap+bp), expected);
221assert_checkequal(x1<=x2, X1<=X2); 287 assert_checkequal(inttype(am+bp), expected);
222assert_checkequal(x1<>x2, X1<>X2); 288 assert_checkequal(inttype(ap+bm), expected);
289 assert_checkequal(inttype(am+bm), expected);
290 // -
291 assert_checkequal(inttype(ap-bp), expected);
292 assert_checkequal(inttype(am-bp), expected);
293 assert_checkequal(inttype(ap-bm), expected);
294 assert_checkequal(inttype(am-bm), expected);
295 // /
296 assert_checkequal(inttype(ap/bp), expected);
297 assert_checkequal(inttype(am/bp), expected);
298 assert_checkequal(inttype(ap/bm), expected);
299 assert_checkequal(inttype(am/bm), expected);
300 // ^
301// assert_checkequal(inttype(ap^bp), expected);
302// assert_checkequal(inttype(am^bp), expected);
303// assert_checkequal(inttype(ap^bm), expected);
304// assert_checkequal(inttype(am^bm), expected);
305 end
306end
307
308// Comparisons
309// -----------
310icodes = [0 1 2 4 8 11 12 14 18];
311for i = icodes
312 for j = icodes
313 a = iconvert(2,i);
314 b = iconvert(1,j);
315 assert_checktrue(a>b);
316 assert_checktrue(a>=b);
317 assert_checktrue(b<a);
318 assert_checktrue(b<=a);
319 assert_checktrue(a~=b);
320 assert_checkfalse(a==b);
321
322 a = iconvert(2:10,i);
323 b = iconvert(1,j);
324 assert_checktrue(and(a>b));
325 assert_checktrue(and(a>=b));
326 assert_checktrue(and(b<a));
327 assert_checktrue(and(b<=a));
328 assert_checktrue(and(a~=b));
329 assert_checkfalse(or(a==b));
330
331 a = iconvert(10,i);
332 b = iconvert(1:9,j);
333 assert_checktrue(and(a>b));
334 assert_checktrue(and(a>=b));
335 assert_checktrue(and(b<a));
336 assert_checktrue(and(b<=a));
337 assert_checktrue(and(a~=b));
338 assert_checkfalse(or(a==b));
339
340 a = iconvert(2:10,i);
341 b = iconvert(1:9,j);
342 assert_checktrue(and(a>b));
343 assert_checktrue(and(a>=b));
344 assert_checktrue(and(b<a));
345 assert_checktrue(and(b<=a));
346 assert_checktrue(and(a~=b));
347 assert_checkfalse(or(a==b));
348 end
349end
350
223//division 351//division
224X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); 352X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2);
225assert_checkequal(x1/x2, int8(0)); 353assert_checkequal(x1/x2, int8(0));
@@ -230,39 +358,50 @@ assert_checkequal(x1./x2, int8(0));
230assert_checkequal(x2./x1, int8(7)); 358assert_checkequal(x2./x1, int8(7));
231assert_checkequal(x1.\x2, int8(7)); 359assert_checkequal(x1.\x2, int8(7));
232assert_checkequal(x2.\x1, int8(0)); 360assert_checkequal(x2.\x1, int8(0));
361
233X1 = 1:10; x1 = int8(X1); 362X1 = 1:10; x1 = int8(X1);
234assert_checkequal(x1/x2, int8([0 0 0 0 0 0 1 1 1 1])); 363assert_checkequal(x1/x2, int8([0 0 0 0 0 0 1 1 1 1]));
235//if or(x2/x1<>int8([7 3 2 1 1 1 1 0 0 0])) then bugmes();quit;end 364//if or(x2/x1<>int8([7 3 2 1 1 1 1 0 0 0])) then pause,end
236assert_checkequal(x1./x2, int8([0 0 0 0 0 0 1 1 1 1])); 365assert_checkequal(x1./x2, int8([0 0 0 0 0 0 1 1 1 1]));
237assert_checkequal(x2./x1, int8([7 3 2 1 1 1 1 0 0 0])); 366assert_checkequal(x2./x1, int8([7 3 2 1 1 1 1 0 0 0]));
238//if or(x1\x2<>int8([0 0 0 0 0 0 1 1 1 1])) then bugmes();quit;end 367//if or(x1\x2<>int8([0 0 0 0 0 0 1 1 1 1])) then pause,end
239assert_checkequal(x1.\x2, int8([7 3 2 1 1 1 1 0 0 0])); 368assert_checkequal(x1.\x2, int8([7 3 2 1 1 1 1 0 0 0]));
240assert_checkequal(x2\x1, int8([0 0 0 0 0 0 1 1 1 1])); 369assert_checkequal(x2\x1, int8([0 0 0 0 0 0 1 1 1 1]));
241assert_checkequal(x2.\x1, int8([0 0 0 0 0 0 1 1 1 1])); 370assert_checkequal(x2.\x1, int8([0 0 0 0 0 0 1 1 1 1]));
371
242X2 = -(1:10); x2 = int8(X2); 372X2 = -(1:10); x2 = int8(X2);
243assert_checkequal(x1./x2, int8(-ones(1,10))); 373assert_checkequal(x1./x2, int8(-ones(1,10)));
244assert_checkequal(x1.\x2, int8(-ones(1,10))); 374assert_checkequal(x1.\x2, int8(-ones(1,10)));
375
245// puissance 376// puissance
246X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2); 377X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2);
247assert_checkequal(x1^x2, int8(X1^X2)); 378assert_checkequal(x1^x2, int8(X1^X2));
248assert_checkequal(x1.^x2, int8(X1.^X2)); 379assert_checkequal(x1.^x2, int8(X1.^X2));
380
249X1 = 1:5; x1 = int8(X1); 381X1 = 1:5; x1 = int8(X1);
250assert_checkequal(x1.^x2, int8(X1.^X2)); 382assert_checkequal(x1.^x2, int8(X1.^X2));
251//if or(x1^x2<>int8(X1^X2)) then bugmes();quit;end 383//if or(x1^x2<>int8(X1^X2)) then pause,end
384
252X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2); 385X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2);
253assert_checkequal(x1^x2, int8(X1^X2)); 386assert_checkequal(x1^x2, int8(X1^X2));
254assert_checkequal(x1.^x2, int8(X1.^X2)); 387assert_checkequal(x1.^x2, int8(X1.^X2));
388
255//X1=2:4;x1=int8(X1); 389//X1=2:4;x1=int8(X1);
256//if or(x1.^x2<>int8(X1.^X2)) then bugmes();quit;end 390//if or(x1.^x2<>int8(X1.^X2)) then pause,end
391
257//kronecker 392//kronecker
258X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2); 393X1 = 2;X2 = 3;x1 = int8(X1);x2 = int8(X2);
259assert_checkequal(x1.*.x2, int8(X1.*.X2)); 394assert_checkequal(x1.*.x2, int8(X1.*.X2));
395
260X1 = 1:5;x1 = int8(X1); 396X1 = 1:5;x1 = int8(X1);
261assert_checkequal(x1.*.x2, int8(X1.*.X2)); 397assert_checkequal(x1.*.x2, int8(X1.*.X2));
398
262X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2); 399X1 = 2;x1 = int8(X1);X2 = (1:3);x2 = int8(X2);
263assert_checkequal(x1.*.x2, int8(X1.*.X2)); 400assert_checkequal(x1.*.x2, int8(X1.*.X2));
401
264X1 = (1:5)';x1 = int8(X1); 402X1 = (1:5)';x1 = int8(X1);
265assert_checkequal(x1.*.x2, int8(X1.*.X2)); 403assert_checkequal(x1.*.x2, int8(X1.*.X2));
404
266//sum 405//sum
267X = round(10 * rand(1,30)); 406X = round(10 * rand(1,30));
268deff("y=INT(x)","y=int16(x)") 407deff("y=INT(x)","y=int16(x)")
@@ -271,150 +410,186 @@ assert_checkequal(sum(x), INT(sum(X)));
271assert_checkequal(sum(x'), INT(sum(X'))); 410assert_checkequal(sum(x'), INT(sum(X')));
272assert_checkequal(cumsum(x), INT(cumsum(X))); 411assert_checkequal(cumsum(x), INT(cumsum(X)));
273assert_checkequal(cumsum(x'), INT(cumsum(X'))); 412assert_checkequal(cumsum(x'), INT(cumsum(X')));
413
274deff("y=INT(x)","y=uint16(x)") 414deff("y=INT(x)","y=uint16(x)")
275x = INT(X); 415x = INT(X);
276assert_checkequal(sum(x), INT(sum(X))); 416assert_checkequal(sum(x), INT(sum(X)));
277assert_checkequal(sum(x'), INT(sum(X'))); 417assert_checkequal(sum(x'), INT(sum(X')));
278assert_checkequal(cumsum(x), INT(cumsum(X))); 418assert_checkequal(cumsum(x), INT(cumsum(X)));
279assert_checkequal(cumsum(x'), INT(cumsum(X'))); 419assert_checkequal(cumsum(x'), INT(cumsum(X')));
420
280deff("y=INT(x)","y=uint8(x)") 421deff("y=INT(x)","y=uint8(x)")
281x = INT(X); 422x = INT(X);
282assert_checkequal(sum(x), INT(sum(X))); 423assert_checkequal(sum(x), INT(sum(X)));
283assert_checkequal(sum(x'), INT(sum(X'))); 424assert_checkequal(sum(x'), INT(sum(X')));
284assert_checkequal(cumsum(x), INT(cumsum(X))); 425assert_checkequal(cumsum(x), INT(cumsum(X)));
285assert_checkequal(cumsum(x'), INT(cumsum(X'))); 426assert_checkequal(cumsum(x'), INT(cumsum(X')));
427
286deff("y=INT(x)","y=int8(x)") 428deff("y=INT(x)","y=int8(x)")
287x = INT(X); 429x = INT(X);
288assert_checkequal(sum(x), INT(sum(X))); 430assert_checkequal(sum(x), INT(sum(X)));
289assert_checkequal(sum(x'), INT(sum(X'))); 431assert_checkequal(sum(x'), INT(sum(X')));
290assert_checkequal(cumsum(x), INT(cumsum(X))); 432assert_checkequal(cumsum(x), INT(cumsum(X)));
291assert_checkequal(cumsum(x'), INT(cumsum(X'))); 433assert_checkequal(cumsum(x'), INT(cumsum(X')));
434
292X = round(10*rand(20,30)); 435X = round(10*rand(20,30));
293x = INT(X); 436x = INT(X);
294assert_checkequal(sum(x, 1), INT(sum(X, 1))); 437assert_checkequal(sum(x, 1), INT(sum(X, 1)));
295assert_checkequal(sum(x', 1), INT(sum(X', 1))); 438assert_checkequal(sum(x', 1), INT(sum(X', 1)));
296assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); 439assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1)));
297assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); 440assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1)));
441
298deff("y=INT(x)","y=uint16(x)") 442deff("y=INT(x)","y=uint16(x)")
299x = INT(X); 443x = INT(X);
300assert_checkequal(sum(x, 1), INT(sum(X, 1))); 444assert_checkequal(sum(x, 1), INT(sum(X, 1)));
301assert_checkequal(sum(x', 1), INT(sum(X', 1))); 445assert_checkequal(sum(x', 1), INT(sum(X', 1)));
302assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); 446assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1)));
303assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); 447assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1)));
448
304deff("y=INT(x)","y=uint8(x)") 449deff("y=INT(x)","y=uint8(x)")
305x = INT(X); 450x = INT(X);
306assert_checkequal(sum(x, 1), INT(sum(X, 1))); 451assert_checkequal(sum(x, 1), INT(sum(X, 1)));
307assert_checkequal(sum(x', 1), INT(sum(X', 1))); 452assert_checkequal(sum(x', 1), INT(sum(X', 1)));
308assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); 453assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1)));
309assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); 454assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1)));
455
310deff("y=INT(x)","y=int8(x)") 456deff("y=INT(x)","y=int8(x)")
311x = INT(X); 457x = INT(X);
312assert_checkequal(sum(x, 1), INT(sum(X, 1))); 458assert_checkequal(sum(x, 1), INT(sum(X, 1)));
313assert_checkequal(sum(x', 1), INT(sum(X', 1))); 459assert_checkequal(sum(x', 1), INT(sum(X', 1)));
314assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1))); 460assert_checkequal(cumsum(x, 1), INT(cumsum(X, 1)));
315assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1))); 461assert_checkequal(cumsum(x', 1), INT(cumsum(X', 1)));
462
316x = INT(X); 463x = INT(X);
317assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); 464assert_checkequal(sum(x, "c"), INT(sum(X, "c")));
318assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); 465assert_checkequal(sum(x', "c"), INT(sum(X', "c")));
319assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); 466assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c")));
320assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); 467assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c")));
468
321deff("y=INT(x)","y=uint16(x)") 469deff("y=INT(x)","y=uint16(x)")
322x = INT(X); 470x = INT(X);
323assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); 471assert_checkequal(sum(x, "c"), INT(sum(X, "c")));
324assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); 472assert_checkequal(sum(x', "c"), INT(sum(X', "c")));
325assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); 473assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c")));
326assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); 474assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c")));
475
327deff("y=INT(x)","y=uint8(x)") 476deff("y=INT(x)","y=uint8(x)")
328x = INT(X); 477x = INT(X);
329assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); 478assert_checkequal(sum(x, "c"), INT(sum(X, "c")));
330assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); 479assert_checkequal(sum(x', "c"), INT(sum(X', "c")));
331assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); 480assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c")));
332assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); 481assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c")));
482
333deff("y=INT(x)","y=int8(x)") 483deff("y=INT(x)","y=int8(x)")
334x = INT(X); 484x = INT(X);
335assert_checkequal(sum(x, "c"), INT(sum(X, "c"))); 485assert_checkequal(sum(x, "c"), INT(sum(X, "c")));
336assert_checkequal(sum(x', "c"), INT(sum(X', "c"))); 486assert_checkequal(sum(x', "c"), INT(sum(X', "c")));
337assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c"))); 487assert_checkequal(cumsum(x, "c"), INT(cumsum(X, "c")));
338assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c"))); 488assert_checkequal(cumsum(x', "c"), INT(cumsum(X', "c")));
489
339//diag triu tril 490//diag triu tril
340deff("y=INT(x)","y=int16(x)") 491deff("y=INT(x)","y=int16(x)")
341X = round(10*rand(1,30)); 492X = round(10*rand(1,30));
342x = INT(X); 493x = INT(X);
494
343assert_checktrue(diag(x) == diag(X)); 495assert_checktrue(diag(x) == diag(X));
344assert_checktrue(diag(x, 2) == diag(X, 2)); 496assert_checktrue(diag(x, 2) == diag(X, 2));
345assert_checktrue(diag(x, -2) == diag(X, -2)); 497assert_checktrue(diag(x, -2) == diag(X, -2));
498
346assert_checktrue(triu(x) == triu(X)); 499assert_checktrue(triu(x) == triu(X));
347assert_checktrue(triu(x, 2) == triu(X, 2)); 500assert_checktrue(triu(x, 2) == triu(X, 2));
348assert_checktrue(triu(x, -2) == triu(X, -2)); 501assert_checktrue(triu(x, -2) == triu(X, -2));
502
349assert_checktrue(tril(x) == tril(X)); 503assert_checktrue(tril(x) == tril(X));
350assert_checktrue(tril(x, 2) == tril(X, 2)); 504assert_checktrue(tril(x, 2) == tril(X, 2));
351assert_checktrue(tril(x, -2) == tril(X, -2)); 505assert_checktrue(tril(x, -2) == tril(X, -2));
506
352X = round(10*rand(2,30)); 507X = round(10*rand(2,30));
353x = INT(X); 508x = INT(X);
509
354assert_checktrue(diag(x) == diag(X)); 510assert_checktrue(diag(x) == diag(X));
355assert_checktrue(diag(x, 2) == diag(X, 2)); 511assert_checktrue(diag(x, 2) == diag(X, 2));
356assert_checktrue(diag(x, -2) == diag(X, -2)); 512assert_checktrue(diag(x, -2) == diag(X, -2));
513
357assert_checktrue(triu(x) == triu(X)); 514assert_checktrue(triu(x) == triu(X));
358assert_checktrue(triu(x, 2) == triu(X, 2)); 515assert_checktrue(triu(x, 2) == triu(X, 2));
359assert_checktrue(triu(x, -2) == triu(X, -2)); 516assert_checktrue(triu(x, -2) == triu(X, -2));
517
360assert_checktrue(tril(x) == tril(X)); 518assert_checktrue(tril(x) == tril(X));
361assert_checktrue(tril(x, 2) == tril(X, 2)); 519assert_checktrue(tril(x, 2) == tril(X, 2));
362assert_checktrue(tril(x, -2) == tril(X, -2)); 520assert_checktrue(tril(x, -2) == tril(X, -2));
521
363deff("y=INT(x)","y=uint8(x)") 522deff("y=INT(x)","y=uint8(x)")
364X = round(10*rand(1,30)); 523X = round(10*rand(1,30));
365x = INT(X); 524x = INT(X);
525
366assert_checktrue(diag(x) == diag(X)); 526assert_checktrue(diag(x) == diag(X));
367assert_checktrue(diag(x, 2) == diag(X, 2)); 527assert_checktrue(diag(x, 2) == diag(X, 2));
368assert_checktrue(diag(x, -2) == diag(X, -2)); 528assert_checktrue(diag(x, -2) == diag(X, -2));
529
369assert_checktrue(triu(x) == triu(X)); 530assert_checktrue(triu(x) == triu(X));
370assert_checktrue(triu(x, 2) == triu(X, 2)); 531assert_checktrue(triu(x, 2) == triu(X, 2));
371assert_checktrue(triu(x, -2) == triu(X, -2)); 532assert_checktrue(triu(x, -2) == triu(X, -2));
533
372assert_checktrue(tril(x) == tril(X)); 534assert_checktrue(tril(x) == tril(X));
373assert_checktrue(tril(x, 2) == tril(X, 2)); 535assert_checktrue(tril(x, 2) == tril(X, 2));
374assert_checktrue(tril(x, -2) == tril(X, -2)); 536assert_checktrue(tril(x, -2) == tril(X, -2));
537
375X = round(10*rand(2,30)); 538X = round(10*rand(2,30));
376x = INT(X); 539x = INT(X);
540
377assert_checktrue(diag(x) == diag(X)); 541assert_checktrue(diag(x) == diag(X));
378assert_checktrue(diag(x, 2) == diag(X, 2)); 542assert_checktrue(diag(x, 2) == diag(X, 2));
379assert_checktrue(diag(x, -2) == diag(X, -2)); 543assert_checktrue(diag(x, -2) == diag(X, -2));
544
380assert_checktrue(triu(x) == triu(X)); 545assert_checktrue(triu(x) == triu(X));
381assert_checktrue(triu(x, 2) == triu(X, 2)); 546assert_checktrue(triu(x, 2) == triu(X, 2));
382assert_checktrue(triu(x, -2) == triu(X, -2)); 547assert_checktrue(triu(x, -2) == triu(X, -2));
548
383assert_checktrue(tril(x) == tril(X)); 549assert_checktrue(tril(x) == tril(X));
384assert_checktrue(tril(x, 2) == tril(X, 2)); 550assert_checktrue(tril(x, 2) == tril(X, 2));
385assert_checktrue(tril(x, -2) == tril(X, -2)); 551assert_checktrue(tril(x, -2) == tril(X, -2));
552
386// save load 553// save load
387deff("y=INT(x)","y=uint8(x)") 554deff("y=INT(x)","y=uint8(x)")
388X = round(10*rand(1,30)); 555X = round(10*rand(1,30));
389x = INT(X); 556x = INT(X);
557
390save(TMPDIR+"/foo","x"); 558save(TMPDIR+"/foo","x");
391clear x; 559clear x;
392load(TMPDIR+"/foo"); 560load(TMPDIR+"/foo");
393assert_checkequal(x, INT(X)); 561assert_checkequal(x, INT(X));
562
394x=list(1,x,2);save(TMPDIR+"/foo","x"); 563x=list(1,x,2);save(TMPDIR+"/foo","x");
395clear x; 564clear x;
396load(TMPDIR+"/foo"); 565load(TMPDIR+"/foo");
397assert_checkequal(x, list(1, INT(X), 2)); 566assert_checkequal(x, list(1, INT(X), 2));
567
398deff("y=INT(x)","y=int32(x)") 568deff("y=INT(x)","y=int32(x)")
399X = round(10*rand(1,30)); 569X = round(10*rand(1,30));
400x = INT(X); 570x = INT(X);
571
401save(TMPDIR+"/foo","x"); 572save(TMPDIR+"/foo","x");
402clear x; 573clear x;
403load(TMPDIR+"/foo"); 574load(TMPDIR+"/foo");
404assert_checkequal(x, INT(X)); 575assert_checkequal(x, INT(X));
576
405x=list(1,x,2);save(TMPDIR+"/foo","x"); 577x=list(1,x,2);save(TMPDIR+"/foo","x");
406clear x; 578clear x;
407load(TMPDIR+"/foo"); 579load(TMPDIR+"/foo");
408assert_checkequal(x, list(1, INT(X), 2)); 580assert_checkequal(x, list(1, INT(X), 2));
581
409//abs 582//abs
410deff("y=INT(x)","y=int8(x)") 583deff("y=INT(x)","y=int8(x)")
411X = round(10*rand(1,30))-5; 584X = round(10*rand(1,30))-5;
412x = INT(X); 585x = INT(X);
413assert_checkequal(abs(x), INT(abs(X))); 586assert_checkequal(abs(x), INT(abs(X)));
587
414deff("y=INT(x)","y=int16(x)") 588deff("y=INT(x)","y=int16(x)")
415X = round(10*rand(1,30))-5; 589X = round(10*rand(1,30))-5;
416x = INT(X); 590x = INT(X);
417assert_checkequal(abs(x), INT(abs(X))); 591assert_checkequal(abs(x), INT(abs(X)));
592
418//matrix 593//matrix
419deff("y=INT(x)","y=int8(x)") 594deff("y=INT(x)","y=int8(x)")
420X = round(10*rand(1,30))-5; 595X = round(10*rand(1,30))-5;
@@ -422,12 +597,14 @@ x = INT(X);
422assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1))); 597assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1)));
423assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3))); 598assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3)));
424assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3))); 599assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3)));
600
425deff("y=INT(x)","y=uint8(x)") 601deff("y=INT(x)","y=uint8(x)")
426X = round(10*rand(1,30))-5; 602X = round(10*rand(1,30))-5;
427x = INT(X); 603x = INT(X);
428assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1))); 604assert_checkequal(matrix(x,10,-1), INT(matrix(X,10,-1)));
429assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3))); 605assert_checkequal(matrix(x,10,3), INT(matrix(X,10,3)));
430assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3))); 606assert_checkequal(matrix(x,-1,3), INT(matrix(X,-1,3)));
607
431//max min 608//max min
432deff("y=INT(x)","y=int8(x)") 609deff("y=INT(x)","y=int8(x)")
433X = round(10*rand(2,30))-5; 610X = round(10*rand(2,30))-5;
@@ -439,17 +616,20 @@ assert_checkequal(max(x, "r"), INT(max(X, "r")));
439assert_checkequal(max(x, "c"), INT(max(X, "c"))); 616assert_checkequal(max(x, "c"), INT(max(X, "c")));
440assert_checkequal(max(x, INT(2)), INT(max(X, 2))); 617assert_checkequal(max(x, INT(2)), INT(max(X, 2)));
441assert_checkequal(max(x, y), INT(max(X, Y))); 618assert_checkequal(max(x, y), INT(max(X, Y)));
619
442assert_checkequal(min(x), INT(min(X))); 620assert_checkequal(min(x), INT(min(X)));
443assert_checkequal(min(x, "r"), INT(min(X, "r"))); 621assert_checkequal(min(x, "r"), INT(min(X, "r")));
444assert_checkequal(min(x, "c"), INT(min(X, "c"))); 622assert_checkequal(min(x, "c"), INT(min(X, "c")));
445assert_checkequal(min(x, INT(2)), INT(min(X, 2))); 623assert_checkequal(min(x, INT(2)), INT(min(X, 2)));
446assert_checkequal(min(x, y), INT(min(X, Y))); 624assert_checkequal(min(x, y), INT(min(X, Y)));
625
447a = [0 3 7]; 626a = [0 3 7];
448b = [1 2 7]; 627b = [1 2 7];
449A = [0 3 7 5; 628A = [0 3 7 5;
4501 2 0 2 6291 2 0 2
4518 9 3 1]; 6308 9 3 1];
452types=["double","int32","uint32","int16","uint16","int8","uint8"]; 631types=["double","int32","uint32","int16","uint16","int8","uint8"];
632
453// checking max(a,b) 633// checking max(a,b)
454[mx, kx] = max(a, b); 634[mx, kx] = max(a, b);
455for t1 = types 635for t1 = types
@@ -461,6 +641,7 @@ for t1 = types
461 end 641 end
462 end 642 end
463end 643end
644
464// checking min(a,b) 645// checking min(a,b)
465[mn,kn]=min(a,b); 646[mn,kn]=min(a,b);
466for t1=types 647for t1=types
@@ -472,6 +653,7 @@ for t1=types
472 end 653 end
473 end 654 end
474end 655end
656
475// checking max(A) 657// checking max(A)
476[mx,kx]=max(A); 658[mx,kx]=max(A);
477for t1=types 659for t1=types
@@ -481,6 +663,7 @@ for t1=types
481 disp("max("+t1+")"),pause 663 disp("max("+t1+")"),pause
482 end 664 end
483end 665end
666
484// checking min(A) 667// checking min(A)
485[mx,kx]=min(A); 668[mx,kx]=min(A);
486for t1=types 669for t1=types
@@ -490,6 +673,8 @@ for t1=types
490 disp("min("+t1+")"),pause 673 disp("min("+t1+")"),pause
491 end 674 end
492end 675end
676
677
493// checking max(A,'r') 678// checking max(A,'r')
494[mx,kx]=max(A,"r"); 679[mx,kx]=max(A,"r");
495for t1=types 680for t1=types
@@ -499,6 +684,7 @@ for t1=types
499 disp("max("+t1+",''r'')"),pause 684 disp("max("+t1+",''r'')"),pause
500 end 685 end
501end 686end
687
502// checking min(A,'r') 688// checking min(A,'r')
503[mx,kx]=min(A,"r"); 689[mx,kx]=min(A,"r");
504for t1=types 690for t1=types
@@ -508,6 +694,7 @@ for t1=types
508 disp("min("+t1+",''r'')"),pause 694 disp("min("+t1+",''r'')"),pause
509 end 695 end
510end 696end
697
511// checking max(A,'c') 698// checking max(A,'c')
512[mx,kx]=max(A,"c"); 699[mx,kx]=max(A,"c");
513for t1=types 700for t1=types
@@ -517,6 +704,7 @@ for t1=types
517 disp("max("+t1+",''c'')"),pause 704 disp("max("+t1+",''c'')"),pause
518 end 705 end
519end 706end
707
520// checking min(A,'c') 708// checking min(A,'c')
521[mx,kx]=min(A,"c"); 709[mx,kx]=min(A,"c");
522for t1=types 710for t1=types
@@ -526,4 +714,6 @@ for t1=types
526 disp("min("+t1+",''c'')"),pause 714 disp("min("+t1+",''c'')"),pause
527 end 715 end
528end 716end
717
718
529//int32 int8 ... iconvert 719//int32 int8 ... iconvert
diff --git a/scilab/modules/integer/tests/unit_tests/intops.tst b/scilab/modules/integer/tests/unit_tests/intops.tst
index c18f8f0..1938aaf 100644
--- a/scilab/modules/integer/tests/unit_tests/intops.tst
+++ b/scilab/modules/integer/tests/unit_tests/intops.tst
@@ -2,11 +2,11 @@
2// ============================================================================= 2// =============================================================================
3// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4// Copyright (C) ????-2008 - INRIA 4// Copyright (C) ????-2008 - INRIA
5// Copyright (C) 2016 - Samuel GOUGEON
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
8 9
9
10funcprot(0); 10funcprot(0);
11 11
12//extractions 12//extractions
@@ -262,34 +262,91 @@ assert_checkequal(x1 .* x2, int8(X1 .* X2));
262assert_checkequal(x1' * x2, int8(X1' * X2)); 262assert_checkequal(x1' * x2, int8(X1' * X2));
263assert_checkequal(x1 * x2', int8(X1 * X2')); 263assert_checkequal(x1 * x2', int8(X1 * X2'));
264 264
265// comparaisons 265// Implicit conversions by a*b, a/b, a+b, a-b
266X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); 266icodes = [ 1 2 4 8 11 12 14 18];
267assert_checkequal(x1>x2, X1>X2); 267for i = 1:8
268assert_checkequal(x1>=x2, X1>=X2); 268 for j = i:8
269assert_checkequal(x1<x2, X1<X2); 269 ic = icodes(i);
270assert_checkequal(x1<=x2, X1<=X2); 270 jc = icodes(j);
271assert_checkequal(x1<>x2, X1<>X2); 271 if ic<10 & jc<10 | ic>10 & jc>10
272 expected = max(ic,jc);
273 else
274 expected = 10 + max(modulo([ic jc],10));
275 end
276 ap = iconvert(120,ic);
277 am = iconvert(-125,ic);
278 bp = iconvert(120,jc);
279 bm = iconvert(-125,jc);
280 // *
281 assert_checkequal(inttype(ap*bp), expected);
282 assert_checkequal(inttype(am*bp), expected);
283 assert_checkequal(inttype(ap*bm), expected);
284 assert_checkequal(inttype(am*bm), expected);
285 // +
286 assert_checkequal(inttype(ap+bp), expected);
287 assert_checkequal(inttype(am+bp), expected);
288 assert_checkequal(inttype(ap+bm), expected);
289 assert_checkequal(inttype(am+bm), expected);
290 // -
291 assert_checkequal(inttype(ap-bp), expected);
292 assert_checkequal(inttype(am-bp), expected);
293 assert_checkequal(inttype(ap-bm), expected);
294 assert_checkequal(inttype(am-bm), expected);
295 // /
296 assert_checkequal(inttype(ap/bp), expected);
297 assert_checkequal(inttype(am/bp), expected);
298 assert_checkequal(inttype(ap/bm), expected);
299 assert_checkequal(inttype(am/bm), expected);
300 // ^
301// assert_checkequal(inttype(ap^bp), expected);
302// assert_checkequal(inttype(am^bp), expected);
303// assert_checkequal(inttype(ap^bm), expected);
304// assert_checkequal(inttype(am^bm), expected);
305 end
306end
272 307
273X1 = 1:10; x1 = int8(X1); 308// Comparisons
274assert_checkequal(x1>x2, X1>X2); 309// -----------
275assert_checkequal(x1>=x2, X1>=X2); 310icodes = [0 1 2 4 8 11 12 14 18];
276assert_checkequal(x1<x2, X1<X2); 311for i = icodes
277assert_checkequal(x1<=x2, X1<=X2); 312 for j = icodes
278assert_checkequal(x1<>x2, X1<>X2); 313 a = iconvert(2,i);
279 314 b = iconvert(1,j);
280X2 = 2:11;x2 = int8(X2); 315 assert_checktrue(a>b);
281assert_checkequal(x1>x2, X1>X2); 316 assert_checktrue(a>=b);
282assert_checkequal(x1>=x2, X1>=X2); 317 assert_checktrue(b<a);
283assert_checkequal(x1<x2, X1<X2); 318 assert_checktrue(b<=a);
284assert_checkequal(x1<=x2, X1<=X2); 319 assert_checktrue(a~=b);
285assert_checkequal(x1<>x2, X1<>X2); 320 assert_checkfalse(a==b);
286 321
287X1 = 1;x1 = int8(X1); 322 a = iconvert(2:10,i);
288assert_checkequal(x1>x2, X1>X2); 323 b = iconvert(1,j);
289assert_checkequal(x1>=x2, X1>=X2); 324 assert_checktrue(and(a>b));
290assert_checkequal(x1<x2, X1<X2); 325 assert_checktrue(and(a>=b));
291assert_checkequal(x1<=x2, X1<=X2); 326 assert_checktrue(and(b<a));
292assert_checkequal(x1<>x2, X1<>X2); 327 assert_checktrue(and(b<=a));
328 assert_checktrue(and(a~=b));
329 assert_checkfalse(or(a==b));
330
331 a = iconvert(10,i);
332 b = iconvert(1:9,j);
333 assert_checktrue(and(a>b));
334 assert_checktrue(and(a>=b));
335 assert_checktrue(and(b<a));
336 assert_checktrue(and(b<=a));
337 assert_checktrue(and(a~=b));
338 assert_checkfalse(or(a==b));
339
340 a = iconvert(2:10,i);
341 b = iconvert(1:9,j);
342 assert_checktrue(and(a>b));
343 assert_checktrue(and(a>=b));
344 assert_checktrue(and(b<a));
345 assert_checktrue(and(b<=a));
346 assert_checktrue(and(a~=b));
347 assert_checkfalse(or(a==b));
348 end
349end
293 350
294//division 351//division
295X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2); 352X1 = 1;X2 = 7;x1 = int8(X1);x2 = int8(X2);
diff --git a/scilab/modules/overloading/macros/%i_2_i.sci b/scilab/modules/overloading/macros/%i_2_i.sci
new file mode 100644
index 0000000..cad2586
--- /dev/null
+++ b/scilab/modules/overloading/macros/%i_2_i.sci
@@ -0,0 +1,16 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2016 - Samuel GOUGEON
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12
13// Implements a > b
14function r = %i_2_i(a, b)
15 r = b < a
16end
diff --git a/scilab/modules/overloading/macros/%i_4_i.sci b/scilab/modules/overloading/macros/%i_4_i.sci
new file mode 100644
index 0000000..6b7910e
--- /dev/null
+++ b/scilab/modules/overloading/macros/%i_4_i.sci
@@ -0,0 +1,16 @@
1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) 2016 - Samuel GOUGEON
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12
13// Implements a >= b
14function r = %i_4_i(a, b)
15 r = b <= a
16end