ac08816e70b1c8a4110c60b64eed422d9c6a9599
[scilab.git] / scilab / modules / ast / tests / unit_tests / subtraction.dia.ref
1 // ============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2012 - DIGITEO - Antoine ELIAS
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // ============================================================================
7 // <-- CLI SHELL MODE -->
8 s = %s;
9 empty = [];
10 r = 2;
11 R = [1,2;3,4];
12 R3(:,:,1) = R;
13 R3(:,:,2) = R';
14 c = 1 + 2*%i;
15 C = [1+2*%i,2+4*%i;3+6*%i,4+8*%i];
16 C3(:,:,1) = C;
17 C3(:,:,2) = C';
18 e = eye();
19 ec = (5+%i) * eye();
20 p = 1 + %s - %s**2;
21 pc = 1 + %s - %s**2 + ( 2 - 3 * %s + 4 * %s**2 ) * %i;
22 P = [2*p, -3*p;4*p,-5*p];
23 PC = [2*pc, -3*pc;4*pc,-5*pc];
24 SP = sparse([1,2;4,5;3,10],[1,2,3]);
25 SPC = sparse([1,2;4,5;3,10],[1,2,3]) * ( 1 + 4*%i);
26 i8 = int8(-8);
27 ui8 = uint8(8);
28 I8 = int8([-8 -16 ; -24 -32]);
29 UI8 = uint8([8 16 ; 24 32]);
30 I16 = int16([-16 -32 ; -48 -64]);
31 UI16 = uint16([16 32 ; 48 64]);
32 i16 = int16(-16);
33 ui16 = uint16(16);
34 i32 = int32(-32);
35 ui32 = uint32(32);
36 I32 = int32([-32 -64 ; -96 -128]);
37 UI32 = uint32([32 64 ; 96 128]);
38 assert_checkequal(empty - empty, []);
39 assert_checkequal(empty - r, -2);
40 assert_checkequal(empty - c, -1-%i*2);
41 assert_checkequal(empty - R, [-1,-2;-3,-4]);
42 assert_checkequal(empty - C, [-1-%i*2,-2-%i*4;-3-%i*6,-4-%i*8]);
43 assert_checkequal(empty - e, (-1)*eye());
44 assert_checkequal(empty - ec, (-5-%i)*eye());
45 assert_checkequal(empty - p, -1-s+s^2);
46 assert_checkequal(empty - pc, -1-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2);
47 assert_checkequal(empty - P, [-2-2*s+2*s^2,3+3*s-3*s^2;-4-4*s+4*s^2,5+5*s-5*s^2]);
48 assert_checkequal(empty - PC, [-2-%i*4+(-2+%i*6)*s+(2-%i*8)*s^2,3+%i*6+(3-%i*9)*s+(-3+%i*12)*s^2;-4-%i*8+(-4+%i*12)*s+(4-%i*16)*s^2,5+%i*10+(5-%i*15)*s+(-5+%i*20)*s^2]);
49 assert_checkequal(empty - SP, sparse([1,2;3,10;4,5],[-1;-3;-2],[4,10]));
50 assert_checkequal(empty - SPC, sparse([1,2;3,10;4,5],[-1-%i*4;-3-%i*12;-2-%i*8],[4,10]));
51 assert_checkequal(empty - i8, int8(8));
52 assert_checkequal(empty - I8, int8([8,16;24,32]));
53 assert_checkequal(empty - ui8, uint8(248));
54 assert_checkequal(empty - UI8, uint8([248,240;232,224]));
55 assert_checkequal(empty - i16, int16(16));
56 assert_checkequal(empty - I16, int16([16,32;48,64]));
57 assert_checkequal(empty - ui16, uint16(65520));
58 assert_checkequal(empty - UI16, uint16([65520,65504;65488,65472]));
59 assert_checkequal(empty - i32, int32(32));
60 assert_checkequal(empty - I32, int32([32,64;96,128]));
61 assert_checkequal(empty - ui32, uint32(4294967264));
62 assert_checkequal(empty - UI32, uint32([4294967264,4294967232;4294967200,4294967168]));
63 assert_checkequal(r - empty, 2);
64 assert_checkequal(r - r, 0);
65 assert_checkequal(r - c,  1-%i*2);
66 assert_checkequal(r - R, [1,0;-1,-2]);
67 assert_checkequal(r - C, [ 1-%i*2,-%i*4;-1-%i*6,-2-%i*8]);
68 assert_checkequal(r - e, 1);
69 assert_checkequal(r - ec, -3-%i);
70 assert_checkequal(r - p, 1-s+s^2);
71 assert_checkequal(r - pc, 1-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2);
72 assert_checkequal(r - P, [-2*s+2*s^2,5+3*s-3*s^2;-2-4*s+4*s^2,7+5*s-5*s^2]);
73 assert_checkequal(r - PC, [-%i*4+(-2+%i*6)*s+(2-%i*8)*s^2,5+%i*6+(3-%i*9)*s+(-3+%i*12)*s^2;-2-%i*8+(-4+%i*12)*s+(4-%i*16)*s^2,7+%i*10+(5-%i*15)*s+(-5+%i*20)*s^2]);
74 assert_checkequal(r - SP, [2,1,2,2,2,2,2,2,2,2;2,2,2,2,2,2,2,2,2,2;2,2,2,2,2,2,2,2,2,-1;2,2,2,2,0,2,2,2,2,2]);
75 assert_checkequal(r - SPC, [ 2, 1-%i*4, 2, 2, 2, 2, 2, 2, 2, 2; 2, 2, 2, 2, 2, 2, 2, 2, 2, 2; 2, 2, 2, 2, 2, 2, 2, 2, 2,-1-%i*12; 2, 2, 2, 2,-%i*8, 2, 2, 2, 2, 2]);
76 assert_checkequal(r - i8, int8(10));
77 assert_checkequal(r - I8, int8([10,18;26,34]));
78 assert_checkequal(r - ui8, uint8(250));
79 assert_checkequal(r - UI8, uint8([250,242;234,226]));
80 assert_checkequal(r - i16, int16(18));
81 assert_checkequal(r - I16, int16([18,34;50,66]));
82 assert_checkequal(r - ui16, uint16(65522));
83 assert_checkequal(r - UI16, uint16([65522,65506;65490,65474]));
84 assert_checkequal(r - i32, int32(34));
85 assert_checkequal(r - I32, int32([34,66;98,130]));
86 assert_checkequal(r - ui32, uint32(4294967266));
87 assert_checkequal(r - UI32, uint32([4294967266,4294967234;4294967202,4294967170]));
88 assert_checkequal(c - empty,  1+%i*2);
89 assert_checkequal(c - r, -1+%i*2);
90 assert_checkequal(c - c, 0*%i);
91 assert_checkequal(c - R, [%i*2,-1+%i*2;-2+%i*2,-3+%i*2]);
92 assert_checkequal(c - C, [0,-1-%i*2;-2-%i*4,-3-%i*6]);
93 assert_checkequal(c - e, %i*2);
94 assert_checkequal(c - ec, -4+%i);
95 assert_checkequal(c - p, %i*2-s+s^2);
96 assert_checkequal(c - pc, (-1+%i*3)*s+(1-%i*4)*s^2);
97 assert_checkequal(c - P, [-1+%i*2-2*s+2*s^2,4+%i*2+3*s-3*s^2;-3+%i*2-4*s+4*s^2,6+%i*2+5*s-5*s^2]);
98 assert_checkequal(c - PC, [-1-%i*2+(-2+%i*6)*s+(2-%i*8)*s^2,4+%i*8+(3-%i*9)*s+(-3+%i*12)*s^2;-3-%i*6+(-4+%i*12)*s+(4-%i*16)*s^2,6+%i*12+(5-%i*15)*s+(-5+%i*20)*s^2]);
99 assert_checkequal(c - SP, [ 1+%i*2,%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2; 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2; 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2,-2+%i*2; 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2,-1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2]);
100 assert_checkequal(c - SPC, [ 1+%i*2,-%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2; 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2; 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2,-2-%i*10; 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2,-1-%i*6, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2, 1+%i*2]);
101 assert_checkequal(R - empty, [1,2;3,4]);
102 assert_checkequal(R - r, [-1,0;1,2]);
103 assert_checkequal(R - c, [-%i*2, 1-%i*2; 2-%i*2, 3-%i*2]);
104 assert_checkequal(R - R, [0,0;0,0]);
105 assert_checkequal(R - C, [-%i*2,-%i*4;-%i*6,-%i*8]);
106 assert_checkequal(R - e, [0,2;3,3]);
107 assert_checkequal(R - ec, [-4-%i, 2; 3,-1-%i]);
108 assert_checkequal(R - p, [-s+s^2,1-s+s^2;2-s+s^2,3-s+s^2]);
109 assert_checkequal(R - pc, [-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2,1-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2;2-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2,3-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2]);
110 assert_checkequal(R - P, [-1-2*s+2*s^2,5+3*s-3*s^2;-1-4*s+4*s^2,9+5*s-5*s^2]);
111 assert_checkequal(R - PC, [-1-%i*4+(-2+%i*6)*s+(2-%i*8)*s^2,5+%i*6+(3-%i*9)*s+(-3+%i*12)*s^2;-1-%i*8+(-4+%i*12)*s+(4-%i*16)*s^2,9+%i*10+(5-%i*15)*s+(-5+%i*20)*s^2]);
112 assert_checkequal(R - i8, int8([9,10;11,12]));
113 assert_checkequal(R - I8, int8([9,18;27,36]));
114 assert_checkequal(R - ui8, uint8([249,250;251,252]));
115 assert_checkequal(R - UI8, uint8([249,242;235,228]));
116 assert_checkequal(R - i16, int16([17,18;19,20]));
117 assert_checkequal(R - I16, int16([17,34;51,68]));
118 assert_checkequal(R - ui16, uint16([65521,65522;65523,65524]));
119 assert_checkequal(R - UI16, uint16([65521,65506;65491,65476]));
120 assert_checkequal(R - i32, int32([33,34;35,36]));
121 assert_checkequal(R - I32, int32([33,66;99,132]));
122 assert_checkequal(R - ui32, uint32([4294967265,4294967266;4294967267,4294967268]));
123 assert_checkequal(R - UI32, uint32([4294967265,4294967234;4294967203,4294967172]));
124 assert_checkequal(C - empty, [ 1+%i*2, 2+%i*4; 3+%i*6, 4+%i*8]);
125 assert_checkequal(C - r, [-1+%i*2,%i*4; 1+%i*6, 2+%i*8]);
126 assert_checkequal(C - c, [0, 1+%i*2; 2+%i*4, 3+%i*6]);
127 assert_checkequal(C - R, [%i*2,%i*4;%i*6,%i*8]);
128 assert_checkequal(C - C, [0,0;0,0] * %i);
129 assert_checkequal(C - e, [%i*2, 2+%i*4; 3+%i*6, 3+%i*8]);
130 assert_checkequal(C - ec, [-4+%i, 2+%i*4; 3+%i*6,-1+%i*7]);
131 assert_checkequal(C - p, [%i*2-s+s^2,1+%i*4-s+s^2;2+%i*6-s+s^2,3+%i*8-s+s^2]);
132 assert_checkequal(C - pc, [(-1+%i*3)*s+(1-%i*4)*s^2,1+%i*2+(-1+%i*3)*s+(1-%i*4)*s^2;2+%i*4+(-1+%i*3)*s+(1-%i*4)*s^2,3+%i*6+(-1+%i*3)*s+(1-%i*4)*s^2]);
133 assert_checkequal(C - P, [-1+%i*2-2*s+2*s^2,5+%i*4+3*s-3*s^2;-1+%i*6-4*s+4*s^2,9+%i*8+5*s-5*s^2]);
134 assert_checkequal(C - PC, [-1-%i*2+(-2+%i*6)*s+(2-%i*8)*s^2,5+%i*10+(3-%i*9)*s+(-3+%i*12)*s^2;-1-%i*2+(-4+%i*12)*s+(4-%i*16)*s^2,9+%i*18+(5-%i*15)*s+(-5+%i*20)*s^2]);
135 assert_checkequal(e - empty, eye());
136 assert_checkequal(e - r, -1);
137 assert_checkequal(e - c, -%i*2);
138 assert_checkequal(e - R, [0,-2;-3,-3]);
139 assert_checkequal(e - C, [-%i*2,-2-%i*4;-3-%i*6,-3-%i*8]);
140 assert_checkequal(e - e, (0)*eye());
141 assert_checkequal(e - ec, (-4-%i)*eye());
142 assert_checkequal(e - p, -s+s^2);
143 assert_checkequal(e - pc, -%i*2+(-1+%i*3)*s+(1-%i*4)*s^2);
144 assert_checkequal(e - P, [-1-2*s+2*s^2,3+3*s-3*s^2;-4-4*s+4*s^2,6+5*s-5*s^2]);
145 assert_checkequal(e - PC, [-1-%i*4+(-2+%i*6)*s+(2-%i*8)*s^2,3+%i*6+(3-%i*9)*s+(-3+%i*12)*s^2;-4-%i*8+(-4+%i*12)*s+(4-%i*16)*s^2,6+%i*10+(5-%i*15)*s+(-5+%i*20)*s^2]);
146 assert_checkequal(e - SP, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[1;-1;1;1;-3;1;-2],[4,10]));
147 assert_checkequal(e - SPC, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[ 1;-1-%i*4; 1; 1;-3-%i*12; 1;-2-%i*8],[4,10]));
148 assert_checkequal(ec - empty, ( 5+%i)*eye());
149 assert_checkequal(ec - r,  3+%i);
150 assert_checkequal(ec - c,  4-%i);
151 assert_checkequal(ec - R, [ 4+%i,-2;-3, 1+%i]);
152 assert_checkequal(ec - C, [ 4-%i,-2-%i*4;-3-%i*6, 1-%i*7]);
153 assert_checkequal(ec - e, ( 4+%i)*eye());
154 assert_checkequal(ec - ec, (0*%i)*eye());
155 assert_checkequal(ec - p, 4+%i-s+s^2);
156 assert_checkequal(ec - pc, 4-%i+(-1+%i*3)*s+(1-%i*4)*s^2);
157 assert_checkequal(ec - P, [3+%i-2*s+2*s^2,3+3*s-3*s^2;-4-4*s+4*s^2,10+%i+5*s-5*s^2]);
158 assert_checkequal(ec - PC, [3-%i*3+(-2+%i*6)*s+(2-%i*8)*s^2,3+%i*6+(3-%i*9)*s+(-3+%i*12)*s^2;-4-%i*8+(-4+%i*12)*s+(4-%i*16)*s^2,10+%i*11+(5-%i*15)*s+(-5+%i*20)*s^2]);
159 assert_checkequal(ec - SP, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[ 5+%i;-1; 5+%i; 5+%i;-3; 5+%i;-2],[4,10]));
160 assert_checkequal(ec - SPC, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[ 5+%i;-1-%i*4; 5+%i; 5+%i;-3-%i*12; 5+%i;-2-%i*8],[4,10]));
161 assert_checkequal(p - empty, 1+s-s^2);
162 assert_checkequal(p - r, -1+s-s^2);
163 assert_checkequal(p - c, -%i*2+s-s^2);
164 assert_checkequal(p - R, [s-s^2,-1+s-s^2;-2+s-s^2,-3+s-s^2]);
165 assert_checkequal(p - C, [-%i*2+s-s^2,-1-%i*4+s-s^2;-2-%i*6+s-s^2,-3-%i*8+s-s^2]);
166 assert_checkequal(p - e, s-s^2);
167 assert_checkequal(p - ec, -4-%i+s-s^2);
168 assert_checkequal(p - p, 0*s);
169 assert_checkequal(p - pc, -%i*2+(%i*3)*s+(-%i*4)*s^2);
170 assert_checkequal(p - P, [-1-s+s^2,4+4*s-4*s^2;-3-3*s+3*s^2,6+6*s-6*s^2]);
171 assert_checkequal(p - PC, [-1-%i*4+(-1+%i*6)*s+(1-%i*8)*s^2,4+%i*6+(4-%i*9)*s+(-4+%i*12)*s^2;-3-%i*8+(-3+%i*12)*s+(3-%i*16)*s^2,6+%i*10+(6-%i*15)*s+(-6+%i*20)*s^2]);
172 assert_checkequal(pc - empty, 1+%i*2+(1-%i*3)*s+(-1+%i*4)*s^2);
173 assert_checkequal(pc - r, -1+%i*2+(1-%i*3)*s+(-1+%i*4)*s^2);
174 assert_checkequal(pc - c, (1-%i*3)*s+(-1+%i*4)*s^2);
175 assert_checkequal(pc - R, [%i*2+(1-%i*3)*s+(-1+%i*4)*s^2,-1+%i*2+(1-%i*3)*s+(-1+%i*4)*s^2;-2+%i*2+(1-%i*3)*s+(-1+%i*4)*s^2,-3+%i*2+(1-%i*3)*s+(-1+%i*4)*s^2]);
176 assert_checkequal(pc - C, [(1-%i*3)*s+(-1+%i*4)*s^2,-1-%i*2+(1-%i*3)*s+(-1+%i*4)*s^2;-2-%i*4+(1-%i*3)*s+(-1+%i*4)*s^2,-3-%i*6+(1-%i*3)*s+(-1+%i*4)*s^2]);
177 assert_checkequal(pc - e, %i*2+(1-%i*3)*s+(-1+%i*4)*s^2);
178 assert_checkequal(pc - ec, -4+%i+(1-%i*3)*s+(-1+%i*4)*s^2);
179 assert_checkequal(pc - p, %i*2+(-%i*3)*s+(%i*4)*s^2);
180 assert_checkequal(pc - pc, 0*s);
181 assert_checkequal(pc - P, [-1+%i*2+(-1-%i*3)*s+(1+%i*4)*s^2,4+%i*2+(4-%i*3)*s+(-4+%i*4)*s^2;-3+%i*2+(-3-%i*3)*s+(3+%i*4)*s^2,6+%i*2+(6-%i*3)*s+(-6+%i*4)*s^2]);
182 assert_checkequal(pc - PC, [-1-%i*2+(-1+%i*3)*s+(1-%i*4)*s^2,4+%i*8+(4-%i*12)*s+(-4+%i*16)*s^2;-3-%i*6+(-3+%i*9)*s+(3-%i*12)*s^2,6+%i*12+(6-%i*18)*s+(-6+%i*24)*s^2]);
183 assert_checkequal(P - empty, [2+2*s-2*s^2,-3-3*s+3*s^2;4+4*s-4*s^2,-5-5*s+5*s^2]);
184 assert_checkequal(P - r, [2*s-2*s^2,-5-3*s+3*s^2;2+4*s-4*s^2,-7-5*s+5*s^2]);
185 assert_checkequal(P - c, [1-%i*2+2*s-2*s^2,-4-%i*2-3*s+3*s^2;3-%i*2+4*s-4*s^2,-6-%i*2-5*s+5*s^2]);
186 assert_checkequal(P - R, [1+2*s-2*s^2,-5-3*s+3*s^2;1+4*s-4*s^2,-9-5*s+5*s^2]);
187 assert_checkequal(P - C, [1-%i*2+2*s-2*s^2,-5-%i*4-3*s+3*s^2;1-%i*6+4*s-4*s^2,-9-%i*8-5*s+5*s^2]);
188 assert_checkequal(P - e, [1+2*s-2*s^2,-3-3*s+3*s^2;4+4*s-4*s^2,-6-5*s+5*s^2]);
189 assert_checkequal(P - ec, [-3-%i+2*s-2*s^2,-3-3*s+3*s^2;4+4*s-4*s^2,-10-%i-5*s+5*s^2]);
190 assert_checkequal(P - p, [1+s-s^2,-4-4*s+4*s^2;3+3*s-3*s^2,-6-6*s+6*s^2]);
191 assert_checkequal(P - pc, [1-%i*2+(1+%i*3)*s+(-1-%i*4)*s^2,-4-%i*2+(-4+%i*3)*s+(4-%i*4)*s^2;3-%i*2+(3+%i*3)*s+(-3-%i*4)*s^2,-6-%i*2+(-6+%i*3)*s+(6-%i*4)*s^2]);
192 assert_checkequal(P - P, [0*s,0*s;0*s,0*s]);
193 assert_checkequal(P - PC, [-%i*4+(%i*6)*s+(-%i*8)*s^2,%i*6+(-%i*9)*s+(%i*12)*s^2;-%i*8+(%i*12)*s+(-%i*16)*s^2,%i*10+(-%i*15)*s+(%i*20)*s^2]);
194 assert_checkequal(PC - empty, [2+%i*4+(2-%i*6)*s+(-2+%i*8)*s^2,-3-%i*6+(-3+%i*9)*s+(3-%i*12)*s^2;4+%i*8+(4-%i*12)*s+(-4+%i*16)*s^2,-5-%i*10+(-5+%i*15)*s+(5-%i*20)*s^2]);
195 assert_checkequal(PC - r, [%i*4+(2-%i*6)*s+(-2+%i*8)*s^2,-5-%i*6+(-3+%i*9)*s+(3-%i*12)*s^2;2+%i*8+(4-%i*12)*s+(-4+%i*16)*s^2,-7-%i*10+(-5+%i*15)*s+(5-%i*20)*s^2]);
196 assert_checkequal(PC - c, [1+%i*2+(2-%i*6)*s+(-2+%i*8)*s^2,-4-%i*8+(-3+%i*9)*s+(3-%i*12)*s^2;3+%i*6+(4-%i*12)*s+(-4+%i*16)*s^2,-6-%i*12+(-5+%i*15)*s+(5-%i*20)*s^2]);
197 assert_checkequal(PC - R, [1+%i*4+(2-%i*6)*s+(-2+%i*8)*s^2,-5-%i*6+(-3+%i*9)*s+(3-%i*12)*s^2;1+%i*8+(4-%i*12)*s+(-4+%i*16)*s^2,-9-%i*10+(-5+%i*15)*s+(5-%i*20)*s^2]);
198 assert_checkequal(PC - C, [1+%i*2+(2-%i*6)*s+(-2+%i*8)*s^2,-5-%i*10+(-3+%i*9)*s+(3-%i*12)*s^2;1+%i*2+(4-%i*12)*s+(-4+%i*16)*s^2,-9-%i*18+(-5+%i*15)*s+(5-%i*20)*s^2]);
199 assert_checkequal(PC - e, [1+%i*4+(2-%i*6)*s+(-2+%i*8)*s^2,-3-%i*6+(-3+%i*9)*s+(3-%i*12)*s^2;4+%i*8+(4-%i*12)*s+(-4+%i*16)*s^2,-6-%i*10+(-5+%i*15)*s+(5-%i*20)*s^2]);
200 assert_checkequal(PC - ec, [-3+%i*3+(2-%i*6)*s+(-2+%i*8)*s^2,-3-%i*6+(-3+%i*9)*s+(3-%i*12)*s^2;4+%i*8+(4-%i*12)*s+(-4+%i*16)*s^2,-10-%i*11+(-5+%i*15)*s+(5-%i*20)*s^2]);
201 assert_checkequal(PC - p, [1+%i*4+(1-%i*6)*s+(-1+%i*8)*s^2,-4-%i*6+(-4+%i*9)*s+(4-%i*12)*s^2;3+%i*8+(3-%i*12)*s+(-3+%i*16)*s^2,-6-%i*10+(-6+%i*15)*s+(6-%i*20)*s^2]);
202 assert_checkequal(PC - pc, [1+%i*2+(1-%i*3)*s+(-1+%i*4)*s^2,-4-%i*8+(-4+%i*12)*s+(4-%i*16)*s^2;3+%i*6+(3-%i*9)*s+(-3+%i*12)*s^2,-6-%i*12+(-6+%i*18)*s+(6-%i*24)*s^2]);
203 assert_checkequal(PC - P, [%i*4+(-%i*6)*s+(%i*8)*s^2,-%i*6+(%i*9)*s+(-%i*12)*s^2;%i*8+(-%i*12)*s+(%i*16)*s^2,-%i*10+(%i*15)*s+(-%i*20)*s^2]);
204 assert_checkequal(PC - PC, [0*s,0*s;0*s,0*s]);
205 assert_checkequal(SP - empty, sparse([1,2;3,10;4,5],[1;3;2],[4,10]));
206 assert_checkequal(SP - r, [-2,-1,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,1;-2,-2,-2,-2,0,-2,-2,-2,-2,-2]);
207 assert_checkequal(SP - c, [-1-%i*2,-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2;-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2;-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2, 2-%i*2;-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2, 1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2]);
208 assert_checkequal(SP - e, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[-1;1;-1;-1;3;-1;2],[4,10]));
209 assert_checkequal(SP - ec, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[-5-%i; 1;-5-%i;-5-%i; 3;-5-%i; 2],[4,10]));
210 assert_checkequal(SP - SP, sparse([],[],[4,10]));
211 assert_checkequal(SP - SPC, sparse([1,2;3,10;4,5],[-%i*4;-%i*12;-%i*8],[4,10]));
212 assert_checkequal(SPC - empty, sparse([1,2;3,10;4,5],[ 1+%i*4; 3+%i*12; 2+%i*8],[4,10]));
213 assert_checkequal(SPC - r, [-2,-1+%i*4,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2,-2;-2,-2,-2,-2,-2,-2,-2,-2,-2, 1+%i*12;-2,-2,-2,-2,%i*8,-2,-2,-2,-2,-2]);
214 assert_checkequal(SPC - c, [-1-%i*2,%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2;-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2;-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2, 2+%i*10;-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2, 1+%i*6,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2,-1-%i*2]);
215 assert_checkequal(SPC - e, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[-1; 1+%i*4;-1;-1; 3+%i*12;-1; 2+%i*8],[4,10]));
216 assert_checkequal(SPC - ec, sparse([1,1;1,2;2,2;3,3;3,10;4,4;4,5],[-5-%i; 1+%i*4;-5-%i;-5-%i; 3+%i*12;-5-%i; 2+%i*8],[4,10]));
217 assert_checkequal(SPC - SP, sparse([1,2;3,10;4,5],[%i*4;%i*12;%i*8],[4,10]));
218 assert_checkequal(SPC - SPC, sparse([],[],[4,10]));
219 assert_checkequal(i8 - empty, int8(-8));
220 assert_checkequal(i8 - r, int8(-10));
221 assert_checkequal(i8 - R, int8([-9,-10;-11,-12]));
222 assert_checkequal(i8 - i8, int8(0));
223 assert_checkequal(i8 - I8, int8([0,8;16,24]));
224 assert_checkequal(i8 - ui8, uint8(240));
225 assert_checkequal(i8 - UI8, uint8([240,232;224,216]));
226 assert_checkequal(i8 - i16, int16(8));
227 assert_checkequal(i8 - I16, int16([8,24;40,56]));
228 assert_checkequal(i8 - ui16, uint16(65512));
229 assert_checkequal(i8 - UI16, uint16([65512,65496;65480,65464]));
230 assert_checkequal(i8 - i32, int32(24));
231 assert_checkequal(i8 - I32, int32([24,56;88,120]));
232 assert_checkequal(i8 - ui32, uint32(4294967256));
233 assert_checkequal(i8 - UI32, uint32([4294967256,4294967224;4294967192,4294967160]));
234 assert_checkequal(I8 - empty, int8([-8,-16;-24,-32]));
235 assert_checkequal(I8 - r, int8([-10,-18;-26,-34]));
236 assert_checkequal(I8 - R, int8([-9,-18;-27,-36]));
237 assert_checkequal(I8 - i8, int8([0,-8;-16,-24]));
238 assert_checkequal(I8 - I8, int8([0,0;0,0]));
239 assert_checkequal(I8 - ui8, uint8([240,232;224,216]));
240 assert_checkequal(I8 - UI8, uint8([240,224;208,192]));
241 assert_checkequal(I8 - i16, int16([8,0;-8,-16]));
242 assert_checkequal(I8 - I16, int16([8,16;24,32]));
243 assert_checkequal(I8 - ui16, uint16([65512,65504;65496,65488]));
244 assert_checkequal(I8 - UI16, uint16([65512,65488;65464,65440]));
245 assert_checkequal(I8 - i32, int32([24,16;8,0]));
246 assert_checkequal(I8 - I32, int32([24,48;72,96]));
247 assert_checkequal(I8 - ui32, uint32([4294967256,4294967248;4294967240,4294967232]));
248 assert_checkequal(I8 - UI32, uint32([4294967256,4294967216;4294967176,4294967136]));
249 assert_checkequal(ui8 - empty, uint8(8));
250 assert_checkequal(ui8 - r, uint8(6));
251 assert_checkequal(ui8 - R, uint8([7,6;5,4]));
252 assert_checkequal(ui8 - i8, uint8(16));
253 assert_checkequal(ui8 - I8, uint8([16,24;32,40]));
254 assert_checkequal(ui8 - ui8, uint8(0));
255 assert_checkequal(ui8 - UI8, uint8([0,248;240,232]));
256 assert_checkequal(ui8 - i16, uint16(24));
257 assert_checkequal(ui8 - I16, uint16([24,40;56,72]));
258 assert_checkequal(ui8 - ui16, uint16(65528));
259 assert_checkequal(ui8 - UI16, uint16([65528,65512;65496,65480]));
260 assert_checkequal(ui8 - i32, uint32(40));
261 assert_checkequal(ui8 - I32, uint32([40,72;104,136]));
262 assert_checkequal(ui8 - ui32, uint32(4294967272));
263 assert_checkequal(ui8 - UI32, uint32([4294967272,4294967240;4294967208,4294967176]));
264 assert_checkequal(UI8 - empty, uint8([8,16;24,32]));
265 assert_checkequal(UI8 - r, uint8([6,14;22,30]));
266 assert_checkequal(UI8 - R, uint8([7,14;21,28]));
267 assert_checkequal(UI8 - i8, uint8([16,24;32,40]));
268 assert_checkequal(UI8 - I8, uint8([16,32;48,64]));
269 assert_checkequal(UI8 - ui8, uint8([0,8;16,24]));
270 assert_checkequal(UI8 - UI8, uint8([0,0;0,0]));
271 assert_checkequal(UI8 - i16, uint16([24,32;40,48]));
272 assert_checkequal(UI8 - I16, uint16([24,48;72,96]));
273 assert_checkequal(UI8 - ui16, uint16([65528,0;8,16]));
274 assert_checkequal(UI8 - UI16, uint16([65528,65520;65512,65504]));
275 assert_checkequal(UI8 - i32, uint32([40,48;56,64]));
276 assert_checkequal(UI8 - I32, uint32([40,80;120,160]));
277 assert_checkequal(UI8 - ui32, uint32([4294967272,4294967280;4294967288,0]));
278 assert_checkequal(UI8 - UI32, uint32([4294967272,4294967248;4294967224,4294967200]));
279 assert_checkequal(i16 - empty, int16(-16));
280 assert_checkequal(i16 - r, int16(-18));
281 assert_checkequal(i16 - R, int16([-17,-18;-19,-20]));
282 assert_checkequal(i16 - i8, int16(-8));
283 assert_checkequal(i16 - I8, int16([-8,0;8,16]));
284 assert_checkequal(i16 - ui8, uint16(65512));
285 assert_checkequal(i16 - UI8, uint16([65512,65504;65496,65488]));
286 assert_checkequal(i16 - i16, int16(0));
287 assert_checkequal(i16 - I16, int16([0,16;32,48]));
288 assert_checkequal(i16 - ui16, uint16(65504));
289 assert_checkequal(i16 - UI16, uint16([65504,65488;65472,65456]));
290 assert_checkequal(i16 - i32, int32(16));
291 assert_checkequal(i16 - I32, int32([16,48;80,112]));
292 assert_checkequal(i16 - ui32, uint32(4294967248));
293 assert_checkequal(i16 - UI32, uint32([4294967248,4294967216;4294967184,4294967152]));
294 assert_checkequal(I16 - empty, int16([-16,-32;-48,-64]));
295 assert_checkequal(I16 - r, int16([-18,-34;-50,-66]));
296 assert_checkequal(I16 - R, int16([-17,-34;-51,-68]));
297 assert_checkequal(I16 - i8, int16([-8,-24;-40,-56]));
298 assert_checkequal(I16 - I8, int16([-8,-16;-24,-32]));
299 assert_checkequal(I16 - ui8, uint16([65512,65496;65480,65464]));
300 assert_checkequal(I16 - UI8, uint16([65512,65488;65464,65440]));
301 assert_checkequal(I16 - i16, int16([0,-16;-32,-48]));
302 assert_checkequal(I16 - I16, int16([0,0;0,0]));
303 assert_checkequal(I16 - ui16, uint16([65504,65488;65472,65456]));
304 assert_checkequal(I16 - UI16, uint16([65504,65472;65440,65408]));
305 assert_checkequal(I16 - i32, int32([16,0;-16,-32]));
306 assert_checkequal(I16 - I32, int32([16,32;48,64]));
307 assert_checkequal(I16 - ui32, uint32([4294967248,4294967232;4294967216,4294967200]));
308 assert_checkequal(I16 - UI32, uint32([4294967248,4294967200;4294967152,4294967104]));
309 assert_checkequal(ui16 - empty, uint16(16));
310 assert_checkequal(ui16 - r, uint16(14));
311 assert_checkequal(ui16 - R, uint16([15,14;13,12]));
312 assert_checkequal(ui16 - i8, uint16(24));
313 assert_checkequal(ui16 - I8, uint16([24,32;40,48]));
314 assert_checkequal(ui16 - ui8, uint16(8));
315 assert_checkequal(ui16 - UI8, uint16([8,0;65528,65520]));
316 assert_checkequal(ui16 - i16, uint16(32));
317 assert_checkequal(ui16 - I16, uint16([32,48;64,80]));
318 assert_checkequal(ui16 - ui16, uint16(0));
319 assert_checkequal(ui16 - UI16, uint16([0,65520;65504,65488]));
320 assert_checkequal(ui16 - i32, uint32(48));
321 assert_checkequal(ui16 - I32, uint32([48,80;112,144]));
322 assert_checkequal(ui16 - ui32, uint32(4294967280));
323 assert_checkequal(ui16 - UI32, uint32([4294967280,4294967248;4294967216,4294967184]));
324 assert_checkequal(UI16 - empty, uint16([16,32;48,64]));
325 assert_checkequal(UI16 - r, uint16([14,30;46,62]));
326 assert_checkequal(UI16 - R, uint16([15,30;45,60]));
327 assert_checkequal(UI16 - i8, uint16([24,40;56,72]));
328 assert_checkequal(UI16 - I8, uint16([24,48;72,96]));
329 assert_checkequal(UI16 - ui8, uint16([8,24;40,56]));
330 assert_checkequal(UI16 - UI8, uint16([8,16;24,32]));
331 assert_checkequal(UI16 - i16, uint16([32,48;64,80]));
332 assert_checkequal(UI16 - I16, uint16([32,64;96,128]));
333 assert_checkequal(UI16 - ui16, uint16([0,16;32,48]));
334 assert_checkequal(UI16 - UI16, uint16([0,0;0,0]));
335 assert_checkequal(UI16 - i32, uint32([48,64;80,96]));
336 assert_checkequal(UI16 - I32, uint32([48,96;144,192]));
337 assert_checkequal(UI16 - ui32, uint32([4294967280,0;16,32]));
338 assert_checkequal(UI16 - UI32, uint32([4294967280,4294967264;4294967248,4294967232]));
339 assert_checkequal(i32 - empty, int32(-32));
340 assert_checkequal(i32 - r, int32(-34));
341 assert_checkequal(i32 - R, int32([-33,-34;-35,-36]));
342 assert_checkequal(i32 - i8, int32(-24));
343 assert_checkequal(i32 - I8, int32([-24,-16;-8,0]));
344 assert_checkequal(i32 - ui8, uint32(4294967256));
345 assert_checkequal(i32 - UI8, uint32([4294967256,4294967248;4294967240,4294967232]));
346 assert_checkequal(i32 - i16, int32(-16));
347 assert_checkequal(i32 - I16, int32([-16,0;16,32]));
348 assert_checkequal(i32 - ui16, uint32(4294967248));
349 assert_checkequal(i32 - UI16, uint32([4294967248,4294967232;4294967216,4294967200]));
350 assert_checkequal(i32 - i32, int32(0));
351 assert_checkequal(i32 - I32, int32([0,32;64,96]));
352 assert_checkequal(i32 - ui32, uint32(4294967232));
353 assert_checkequal(i32 - UI32, uint32([4294967232,4294967200;4294967168,4294967136]));
354 assert_checkequal(I32 - empty, int32([-32,-64;-96,-128]));
355 assert_checkequal(I32 - r, int32([-34,-66;-98,-130]));
356 assert_checkequal(I32 - R, int32([-33,-66;-99,-132]));
357 assert_checkequal(I32 - i8, int32([-24,-56;-88,-120]));
358 assert_checkequal(I32 - I8, int32([-24,-48;-72,-96]));
359 assert_checkequal(I32 - ui8, uint32([4294967256,4294967224;4294967192,4294967160]));
360 assert_checkequal(I32 - UI8, uint32([4294967256,4294967216;4294967176,4294967136]));
361 assert_checkequal(I32 - i16, int32([-16,-48;-80,-112]));
362 assert_checkequal(I32 - I16, int32([-16,-32;-48,-64]));
363 assert_checkequal(I32 - ui16, uint32([4294967248,4294967216;4294967184,4294967152]));
364 assert_checkequal(I32 - UI16, uint32([4294967248,4294967200;4294967152,4294967104]));
365 assert_checkequal(I32 - i32, int32([0,-32;-64,-96]));
366 assert_checkequal(I32 - I32, int32([0,0;0,0]));
367 assert_checkequal(I32 - ui32, uint32([4294967232,4294967200;4294967168,4294967136]));
368 assert_checkequal(I32 - UI32, uint32([4294967232,4294967168;4294967104,4294967040]));
369 assert_checkequal(ui32 - empty, uint32(32));
370 assert_checkequal(ui32 - r, uint32(30));
371 assert_checkequal(ui32 - R, uint32([31,30;29,28]));
372 assert_checkequal(ui32 - i8, uint32(40));
373 assert_checkequal(ui32 - I8, uint32([40,48;56,64]));
374 assert_checkequal(ui32 - ui8, uint32(24));
375 assert_checkequal(ui32 - UI8, uint32([24,16;8,0]));
376 assert_checkequal(ui32 - i16, uint32(48));
377 assert_checkequal(ui32 - I16, uint32([48,64;80,96]));
378 assert_checkequal(ui32 - ui16, uint32(16));
379 assert_checkequal(ui32 - UI16, uint32([16,0;4294967280,4294967264]));
380 assert_checkequal(ui32 - i32, uint32(64));
381 assert_checkequal(ui32 - I32, uint32([64,96;128,160]));
382 assert_checkequal(ui32 - ui32, uint32(0));
383 assert_checkequal(ui32 - UI32, uint32([0,4294967264;4294967232,4294967200]));
384 assert_checkequal(UI32 - empty, uint32([32,64;96,128]));
385 assert_checkequal(UI32 - r, uint32([30,62;94,126]));
386 assert_checkequal(UI32 - R, uint32([31,62;93,124]));
387 assert_checkequal(UI32 - i8, uint32([40,72;104,136]));
388 assert_checkequal(UI32 - I8, uint32([40,80;120,160]));
389 assert_checkequal(UI32 - ui8, uint32([24,56;88,120]));
390 assert_checkequal(UI32 - UI8, uint32([24,48;72,96]));
391 assert_checkequal(UI32 - i16, uint32([48,80;112,144]));
392 assert_checkequal(UI32 - I16, uint32([48,96;144,192]));
393 assert_checkequal(UI32 - ui16, uint32([16,48;80,112]));
394 assert_checkequal(UI32 - UI16, uint32([16,32;48,64]));
395 assert_checkequal(UI32 - i32, uint32([64,96;128,160]));
396 assert_checkequal(UI32 - I32, uint32([64,128;192,256]));
397 assert_checkequal(UI32 - ui32, uint32([0,32;64,96]));
398 assert_checkequal(UI32 - UI32, uint32([0,0;0,0]));
399 // OPPOSITE
400 // - []
401 assert_checkequal(-[], []);
402 // - eye
403 assert_checkequal(-e, eye() * -1);
404 // - eye complex
405 assert_checkequal(-ec, (-5-%i) * eye());
406 // - double
407 assert_checkequal(-r, -2);
408 // - double complex
409 assert_checkequal(-c, - 1 - 2*%i);
410 // - DOUBLE
411 assert_checkequal(-R, [-1 -2;-3 -4]);
412 // - DOUBLE COMPLEX
413 assert_checkequal(-C, [-1-2*%i -2-4*%i;-3-6*%i -4-8*%i]);
414 // - int
415 assert_checkequal(-i8, int8(8));
416 assert_checkequal(-i16, int16(16));
417 assert_checkequal(-i32, int32(32));
418 assert_checkequal(-ui8, uint8(-8));
419 assert_checkequal(-ui16, uint16(-16));
420 assert_checkequal(-ui32, uint32(-32));
421 // - INT
422 assert_checkequal(-I8, int8([8 16 ; 24 32]));
423 assert_checkequal(-I16, int16([16 32 ; 48 64]));
424 assert_checkequal(-I32, int32([32 64 ; 96 128]));
425 assert_checkequal(-UI8, uint8([-8 -16 ; -24 -32]));
426 assert_checkequal(-UI16, uint16([-16 -32 ; -48 -64]));
427 assert_checkequal(-UI32, uint32([-32 -64 ; -96 -128]));
428 // - SPARSE
429 assert_checkequal(-SP, sparse([1,2;4,5;3,10],[-1,-2,-3]));
430 // - SPARSE COMPLEX
431 assert_checkequal(-SPC, sparse([1,2;4,5;3,10],[1,2,3]) * ( -1 - 4*%i));
432 // - polynom
433 assert_checkequal(-p, -1-%s+%s**2);
434 // - polynom complex
435 assert_checkequal(-pc, - 1 - %s + %s**2 + ( - 2 + 3 * %s - 4 * %s**2 ) * %i);
436 // - POLYNOM
437 assert_checkequal(-P, [-2-2*%s+2*%s**2 3+3*%s-3*%s**2; -4-4*%s+4*%s**2, 5+5*%s-5*%s**2]);
438 // - POLYNOM COMPLEX
439 assert_checkequal(-PC, [-2-2*%s+2*%s**2 3+3*%s-3*%s**2; -4-4*%s+4*%s**2, 5+5*%s-5*%s**2] + ([-4+6*%s-8*%s**2 6-9*%s+12*%s**2; -8+12*%s-16*%s**2 10-15*%s+20*%s**2] * %i));