fix subtraction and addition on sparse
[scilab.git] / scilab / modules / ast / tests / unit_tests / sparse.dia.ref
1 //
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2012 - DIGITEO - Antoine ELIAS
4 // Copyright (C) 2012 - Scilab Enterprises - Cedric Delamarre
5 //
6 // This file must be used under the terms of the CeCILL.
7 // This source file is licensed as described in the file COPYING, which
8 // you should have received as part of this distribution.  The terms
9 // are also available at
10 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11 //
12 //
13 // <-- CLI SHELL MODE -->
14 // sparse function
15 //from dense form
16 s=[ 1,0,0,0,0,0,0;
17     0,1,0,0,0,0,0;
18     0,0,1,0,0,0,0;
19     0,0,1,1,0,0,0;
20     0,0,1,1,1,0,0;
21     0,0,1,1,0,1,0;
22     0,0,1,1,0,1,1];
23 sp=sparse(s);
24 assert_checkequal(size(s), size(sp));
25 assert_checkequal(full(sp), s);
26 //from coord
27 sp = sparse([1 1;2 2;3 3;4 3;4 4;5 3;5 4;5 5;6 3;6 4;6 6;7 3;7 4;7 6;7 7], [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]);
28 assert_checkequal(size(s), size(sp));
29 assert_checkequal(full(sp), s);
30 //with size
31 newsp = sparse([], [], [10,20]);
32 assert_checkequal(size(newsp), [10,20]);
33 //concatenation
34 spc = [sp [1; 0; 1; 0; 1; 0; 1]];
35 sc = [s [1; 0; 1; 0; 1; 0; 1]];
36 assert_checkequal(full(spc), sc);
37 spc = [sp ;[1 0 1 0 1 0 1]];
38 sc = [s ;[1 0 1 0 1 0 1]];
39 assert_checkequal(full(spc), sc);
40 spc = [[1; 0; 1; 0; 1; 0; 1] sp];
41 sc = [[1; 0; 1; 0; 1; 0; 1] s];
42 assert_checkequal(full(spc), sc);
43 spc = [[1 0 1 0 1 0 1]; sp];
44 sc = [[1 0 1 0 1 0 1]; s];
45 assert_checkequal(full(spc), sc);
46 sc = [s s];
47 spc = [sp sp];
48 assert_checkequal(full(spc), sc);
49 sc = [s; s];
50 spc = [sp; sp];
51 assert_checkequal(full(spc), sc);
52 sc = [s s];
53 spc = [sp sp];
54 assert_checkequal(full(spc), sc);
55 A = sparse(1);
56 A = [A 0];
57 A = [A 0];
58 A = [A 0];
59 assert_checkequal(full(A), [1 0 0 0]);
60 assert_checkequal(size(A, 'c'), 4);
61 //extraction
62 assert_checkequal(full(sp(:)), s(:));
63 assert_checkequal(size(sp(:)), size(s(:)));
64 assert_checkequal(full(sp(1:7, 1:7)), s(1:7, 1:7));
65 assert_checkequal(size(sp(1:7, 1:7)), size(s(1:7, 1:7)));
66 assert_checkequal(full(sp(1:4, :)), s(1:4, :));
67 assert_checkequal(size(sp(1:4, :)), size(s(1:4, :)));
68 assert_checkequal(full(sp(:, 2:6)), s(:, 2:6));
69 assert_checkequal(size(sp(:, 2:6)), size(s(:, 2:6)));
70 assert_checkequal(full(sp(:, $)), s(:, $));
71 assert_checkequal(size(sp(:, $)), size(s(:, $)));
72 //next tests get from old module sparse (Scilab 5.4)
73 ij=[1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6];
74 v=[1;2;3;4;5;6;7;8;9];
75 ij1=[1 6;1 2;6 5];
76 v1=[-1;-1;-1];
77 vc=v+%i*(21:29)';
78 v1c=v1+%i*[0;0.3;-1.2];
79 zer=sparse([],[],[6,6]);
80 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
81 b=sparse([1 6;1 2;6 5],[-1;-1;-1],[6 6]);
82 ma=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9),[6 6]);
83 mb=sparse([1 6;1 2;6 5],-[-1;-1;-1],[6 6]);
84 ac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
85 bc=sparse([1 6;1 2;6 5],[-1;-1;-1]+%i*[0;0.3;-1.2],[6 6]);
86 mac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9)-%i*(21:29),[6 6]);
87 mbc=sparse([1 6;1 2;6 5],[1;1;1]+%i*[0;-0.3;1.2],[6 6]);
88 //-------------------------------------------------------------
89 //test des primitives sparse, full
90 //--------------------------------------------------------------
91 //  -- for real matrix
92 assert_checkequal(full(sparse(0.3)), 0.3);
93 v=0*ones(1,3);v(3)=5;v(1)=1;
94 assert_checkequal(full(sparse([1 1;1 3],[1 5])), v);
95 v=0*ones(1,300);v(300)=5;v(1)=1;
96 assert_checkequal(full(sparse([1 1;1 300],[1 5])), v);
97 v=0*ones(3,1);v(3)=5;v(1)=1;
98 assert_checkequal(full(sparse([1 1;3 1],[1 5])), v);
99 v=0*ones(300,1);v(300)=5;v(1)=1;
100 assert_checkequal(full(sparse([1 1;300 1],[1 5])), v);
101 sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
102 a=[0,0,3,0,2,1;;5,0,0,4,0,0;0,0,0,0,0,0;0,0,7,6,0,0;8,0,0,0,0,0;0,0,0,0,0,9];
103 assert_checkequal(full(sp), a);
104 sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[8 6]);a(8,6)=0;
105 assert_checkequal(full(sp), a);
106 assert_checkequal(full(sparse([],[],[4 10])), 0*ones(4,10));
107 v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
108 a=[0;10;11;12;0;13];
109 assert_checkequal(full(v), a);
110 v=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
111 a=[0,10,11,12,0,13];
112 assert_checkequal(full(v), a);
113 //  -- for complex matrix
114 sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
115 a=[0,0,3+%i*23,0,2+%i*22,1+%i*21
116    5+%i*25,0,0,4+%i*24,0,0
117    0,0,0,0,0,0
118    0,0,7+%i*27,6+%i*26,0,0
119    8+%i*28,0,0,0,0,0
120    0,0,0,0,0,9+%i*29];
121 assert_checkequal(full(sp), a);
122 sp=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[8 6]);
123 a(8,6)=0;
124 assert_checkequal(full(sp), a);
125 v=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
126 a=[0;10-%i*3;11;12+%i*5;0;13+%i*0.5];
127 assert_checkequal(full(v), a);
128 v=sparse([1 2;1 3;1 4;1 6],[10-3*%i;11;12+5*%i;13+0.5*%i],[1,6]);
129 a=[0,10-%i*3,11,12+%i*5,0,13+%i*0.5];
130 assert_checkequal(full(v), a);
131 //-----------------------------------------------
132 // addition and substraction tests
133 //-----------------------------------------------
134 // -- real real
135 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
136 b=sparse([1 6;1 2;6 5],[-1;-1;-1],[6 6]);
137 v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
138 vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
139 ma=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9),[6 6]);
140 mb=sparse([1 6;1 2;6 5],-[-1;-1;-1],[6 6]);
141 zer=sparse([],[],[6,6]);
142 ac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],(1:9)+%i*(21:29),[6 6]);
143 bc=sparse([1 6;1 2;6 5],[-1;-1;-1]+%i*[0;0.3;-1.2],[6 6]);
144 vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
145 vct=sparse([1 2;1 3;1 4;1 6],[10-3*%i;11;12+5*%i;13+0.5*%i],[1,6]);
146 mac=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],-(1:9)-%i*(21:29),[6 6]);
147 mbc=sparse([1 6;1 2;6 5],[1;1;1]+%i*[0;-0.3;1.2],[6 6]);
148 assert_checkequal(full(v+sparse([],[],[6,1])), full(v));
149 assert_checkequal(full(sparse([],[],[6,1])+v), full(v));
150 assert_checkequal(full(v+v), full(v)+full(v));
151 assert_checkequal(full(v-v), full(v)-full(v));
152 assert_checkequal(full(vt+sparse([],[],[1,6])), full(vt));
153 assert_checkequal(full(vt+vt), full(vt)+full(vt));
154 assert_checkequal(full(vt-vt), full(vt)-full(vt));
155 assert_checkequal(full(zer+zer), 0*ones(6,6));
156 assert_checkequal(full(a+a), full(a)+full(a));
157 assert_checkequal(full(b+b), full(b)+full(b));
158 assert_checkequal(full(a+zer), full(a));
159 assert_checkequal(full(zer+a), full(a));
160 assert_checkequal(full(b+a), full(b)+full(a));
161 assert_checkequal(full(a+b), full(b)+full(a));
162 assert_checkequal(full(a+ma), full(a)+full(ma));
163 assert_checkequal(full(a-a), full(a)-full(a));
164 assert_checkequal(full(a-ma), full(a)-full(ma));
165 assert_checkequal(full(b-mb), full(b)-full(mb));
166 assert_checkequal(full(a-zer), full(a));
167 assert_checkequal(full(zer-a), -full(a));
168 assert_checkequal(full(a-mb), full(a)-full(mb));
169 //  -- real complex
170 assert_checkequal(full(sparse([],[],[6,1])+vc), full(vc));
171 assert_checkequal(full(v+vc), full(v)+full(vc));
172 assert_checkequal(full(v-vc), full(v)-full(vc));
173 assert_checkequal(full(vt+vct), full(vt)+full(vct));
174 assert_checkequal(full(vt-vct), full(vt)-full(vct));
175 assert_checkequal(full(a+ac), full(a)+full(ac));
176 assert_checkequal(full(b+bc), full(b)+full(bc));
177 assert_checkequal(full(a+bc), full(a)+full(bc));
178 assert_checkequal(full(zer+ac), full(zer)+full(ac));
179 assert_checkequal(full(b+ac), full(b)+full(ac));
180 assert_checkequal(full(a-ac), full(a)-full(ac));
181 assert_checkequal(full(b-bc), full(b)-full(bc));
182 assert_checkequal(full(a-bc), full(a)-full(bc));
183 assert_checkequal(full(zer-ac), full(zer)-full(ac));
184 assert_checkequal(full(b-ac), full(b)-full(ac));
185 // -- complex real
186 assert_checkequal(full(vc+v), full(vc)+full(v));
187 assert_checkequal(full(vc-v), full(vc)-full(v));
188 assert_checkequal(full(vct+vt), full(vct)+full(vt));
189 assert_checkequal(full(vct-vt), full(vct)-full(vt));
190 assert_checkequal(full(ac+a), full(ac)+full(a));
191 assert_checkequal(full(bc+b), full(bc)+full(b));
192 assert_checkequal(full(ac+b), full(ac)+full(b));
193 assert_checkequal(full(ac+zer), full(zer)+full(ac));
194 assert_checkequal(full(bc+a), full(bc)+full(a));
195 assert_checkequal(full(ac-a), full(ac)-full(a));
196 assert_checkequal(full(bc-b), full(bc)-full(b));
197 assert_checkequal(full(ac-b), full(ac)-full(b));
198 assert_checkequal(full(ac-zer), -full(zer)+full(ac));
199 assert_checkequal(full(bc-a), full(bc)-full(a));
200 // -- complex complex
201 assert_checkequal(full(vc+vc), full(vc)+full(vc));
202 assert_checkequal(full(vc-vc), full(vc)-full(vc));
203 assert_checkequal(full(vct+vct), full(vct)+full(vct));
204 assert_checkequal(full(vct-vct), full(vct)-full(vct));
205 assert_checkequal(full(ac+ac), full(ac)+full(ac));
206 assert_checkequal(full(bc+bc), full(bc)+full(bc));
207 assert_checkequal(full(ac+bc), full(ac)+full(bc));
208 assert_checkequal(full(bc+ac), full(bc)+full(ac));
209 assert_checkequal(real(full(ac-ac)), full(zer));
210 assert_checkequal(imag(full(ac-ac)), full(zer));
211 assert_checkequal(real(full(bc-bc)), full(zer));
212 assert_checkequal(imag(full(bc-bc)), full(zer));
213 assert_checkequal(full(ac-bc), full(ac)-full(bc));
214 assert_checkequal(full(bc-ac), full(bc)-full(ac));
215 // sparse full and full sparse operation (soft coded apoerations)
216 assert_checkequal(full(a+1), full(a)+1);
217 assert_checkequal(full(1+a), full(a)+1);
218 assert_checkequal(full(a+ones(6,6)), full(a)+ones(6,6));
219 assert_checkequal(full(ones(6,6)+a), full(a)+ones(6,6));
220 assert_checkequal(full(a+2*eye()), full(a)+2*eye());
221 assert_checkequal(full(2*eye()+a), full(a)+2*eye());
222 assert_checkequal(full(a-1), full(a)-1);
223 assert_checkequal(full(1-a), 1-full(a));
224 assert_checkequal(full(a-ones(6,6)), full(a)-ones(6,6));
225 assert_checkequal(full(ones(6,6)-a), ones(6,6)-full(a));
226 assert_checkequal(full(a-2*eye()), full(a)-2*eye());
227 assert_checkequal(full(2*eye()-a), 2*eye()-full(a));
228 assert_checkequal(full(ac+1), full(ac)+1);
229 assert_checkequal(full(1+ac), full(ac)+1);
230 assert_checkequal(full(ac+ones(6,6)), full(ac)+ones(6,6));
231 assert_checkequal(full(ones(6,6)+ac), full(ac)+ones(6,6));
232 assert_checkequal(full(ac+2*eye()), full(ac)+2*eye());
233 assert_checkequal(full(2*eye()+ac), full(ac)+2*eye());
234 assert_checkequal(full(ac-1), full(ac)-1);
235 assert_checkequal(full(1-ac), 1-full(ac));
236 assert_checkequal(full(ac-ones(6,6)), full(ac)-ones(6,6));
237 assert_checkequal(full(ones(6,6)-ac), ones(6,6)-full(ac));
238 assert_checkequal(full(ac-2*eye()), full(ac)-2*eye());
239 assert_checkequal(full(2*eye()-ac), 2*eye()-full(ac));
240 assert_checkequal(full(ac+full(bc)), full(ac)+full(bc));
241 assert_checkequal(full(ac-full(bc)), full(ac)-full(bc));
242 assert_checkequal(full(full(ac)+full(bc)), full(ac)+full(bc));
243 //-----------------------------------------------
244 // multiplication tests
245 //-----------------------------------------------
246 // real x real
247 // sparse scalar , saclar sparse
248 assert_checkequal(full(a*2), full(a)*2);
249 assert_checkequal(full(2*a), full(a)*2);
250 assert_checkequal(a*[], []);
251 assert_checkequal([]*a, []);
252 c=rand(6,6);
253 assert_checkequal(a*c, full(a)*c);
254 assert_checkequal(c*a, c*full(a));
255 // sparse sparse
256 assert_checkequal(full(zer*zer), full(zer));
257 assert_checkequal(full(a*zer), full(zer));
258 assert_checkequal(full(zer*a), full(zer));
259 assert_checkequal(full(a*a), full(a)*full(a));
260 assert_checkequal(full(b*b), full(b)*full(b));
261 assert_checkequal(full(a*b), full(a)*full(b));
262 assert_checkequal(full(b*a), full(b)*full(a));
263 // complex x real real x complex
264 // sparse scalar , scalar sparse
265 assert_checkequal(full(ac*2), full(ac)*2);
266 assert_checkequal(full(2*ac), full(ac)*2);
267 assert_checkequal(full((2+%i)*a), (2+%i)*full(a));
268 assert_checkequal(full(a*(2+%i)), (2+%i)*full(a));
269 assert_checkequal(ac*[], []);
270 assert_checkequal([]*ac, []);
271 c=rand(6,6);
272 cc=c+rand(6,6)*%i;
273 assert_checkequal(ac*c, full(ac)*c);
274 assert_checkequal(cc*a, cc*full(a));
275 // sparse sparse
276 assert_checkequal(real(full(ac*zer)), full(zer));
277 assert_checkequal(imag(full(ac*zer)), full(zer));
278 assert_checkequal(real(full(zer*ac)), full(zer));
279 assert_checkequal(imag(full(zer*ac)), full(zer));
280 assert_checkequal(full(ac*a), full(ac)*full(a));
281 assert_checkequal(full(ac*a), full(ac)*full(a));
282 assert_checkequal(full(bc*b), full(bc)*full(b));
283 assert_checkequal(full(a*bc), full(a)*full(bc));
284 assert_checkequal(full(b*ac), full(b)*full(ac));
285 // // complex x complex
286 assert_checkequal(ac*cc, full(ac)*cc);
287 assert_checkequal(cc*ac, cc*full(ac));
288 // sparse sparse
289 assert_checkequal(full(ac*ac), full(ac)*full(ac));
290 assert_checkequal(full(bc*bc), full(bc)*full(bc));
291 assert_checkequal(full(bc*ac), full(bc)*full(ac));
292 //----------------------------------------------------------
293 // element wise multiplication tests
294 //----------------------------------------------------------
295 assert_checkequal(full(ac.*2), full(ac)*2);
296 assert_checkequal(full((2).*ac), full(ac)*2);
297 assert_checkequal(a.*[], []);
298 assert_checkequal([].*a, []);
299 c=rand(6,6);
300 //if norm(a*c-full(a)*c) >100*%eps then bugmes();quit;end
301 //if norm(c*a-c*full(a)) >100*%eps then bugmes();quit;end
302 // sparse sparse
303 assert_checkequal(full(zer.*zer), full(zer));
304 assert_checkequal(full(a.*zer), full(zer));
305 assert_checkequal(full(zer.*a), full(zer));
306 assert_checkequal(full(a.*a), full(a).*full(a));
307 assert_checkequal(full(b.*b), full(b).*full(b));
308 assert_checkequal(full(a.*b), full(a).*full(b));
309 assert_checkequal(full(b.*a), full(b).*full(a));
310 // complex x real real x complex
311 // sparse scalar , scalar sparse
312 assert_checkequal(full((2+%i).*a), (2+%i).*full(a));
313 assert_checkequal(full(a.*(2+%i)), (2+%i).*full(a));
314 assert_checkequal(ac.*[], []);
315 assert_checkequal([].*ac, []);
316 c=rand(6,6);
317 cc=c+rand(6,6)*%i;
318 assert_checkequal(full(ac.*c), full(ac).*c);
319 assert_checkequal(full(cc.*a), cc.*full(a));
320 // sparse sparse
321 assert_checkequal(full(ac.*zer), full(zer)*%i);
322 assert_checkequal(full(zer.*ac), full(zer)*%i);
323 assert_checkequal(full(ac.*a), full(ac).*full(a));
324 assert_checkequal(full(bc.*b), full(bc).*full(b));
325 assert_checkequal(full(a.*bc), full(a).*full(bc));
326 assert_checkequal(full(b.*ac), full(b).*full(ac));
327 // // complex x complex
328 assert_checkequal(full(ac.*cc), full(ac).*cc);
329 assert_checkequal(full(cc.*ac), cc.*full(ac));
330 // sparse sparse
331 assert_checkequal(full(ac.*ac), full(ac).*full(ac));
332 assert_checkequal(full(bc.*bc), full(bc).*full(bc));
333 assert_checkequal(full(bc.*ac), full(bc).*full(ac));
334 // ----------------------------------------------------------
335 // test de la transposition
336 //-----------------------------------------------------------
337 assert_checkequal(full(a'), full(a)');
338 assert_checkequal(full(ac'), full(ac)');
339 assert_checkequal(full(zer'), full(zer)' );
340 v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
341 assert_checkequal(full(v'), full(v)');
342 assert_checkequal(full((v')'), full(v));
343 vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);
344 assert_checkequal(full(vc'), full(vc)');
345 assert_checkequal(full((vc')'), full(vc));
346 // ----------------------------------------------------------
347 // test des concatenation
348 //-----------------------------------------------------------
349 assert_checkequal(full([a]), full(a));
350 assert_checkequal(full([a b]), [full(a) full(b)]);
351 assert_checkequal(full([a;b]), [full(a);full(b)]);
352 assert_checkequal(full([a []]), full(a));
353 assert_checkequal(full([a;[]]), full(a));
354 assert_checkequal(full([a zer]), [full(a) full(zer)]);
355 assert_checkequal(full([zer;b]), [full(zer);full(b)]);
356 assert_checkequal(full([ac]), full(ac));
357 assert_checkequal(full([ac b]), [full(ac) full(b)]);
358 assert_checkequal(full([ac;b]), [full(ac);full(b)]);
359 assert_checkequal(full([ac []]), full(ac));
360 assert_checkequal(full([ac;[]]), full(ac));
361 assert_checkequal(full([a bc]), [full(a) full(bc)]);
362 assert_checkequal(full([a;bc]), [full(a);full(bc)]);
363 assert_checkequal(full([ac bc]), [full(ac) full(bc)]);
364 assert_checkequal(full([ac;bc]), [full(ac);full(bc)]);
365 // ----------------------------------------------------------
366 // test des extractions
367 //-----------------------------------------------------------
368 af=full(a);
369 assert_checkequal(full(a(1,3)), af(1,3));
370 assert_checkequal(full(a(1,4)), af(1,4));
371 assert_checkequal(full(a(1,:)), af(1,:));
372 v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);vf=full(v);
373 assert_checkequal(full(v(:)), vf(:));
374 assert_checkequal(full(v(3:4)), vf(3:4));
375 assert_checkequal(full(v([1 5])), vf([1 5]));
376 assert_checkequal(full(v([4 3])), vf([4 3]));
377 assert_checkequal(full(v([4 4])), vf([4 4]));
378 assert_checkequal(full(v([1 1])), vf([1 1]));
379 v=v';vf=vf';
380 assert_checkequal(full(v(:)), vf(:));
381 assert_checkequal(full(v(3:4)), vf(3:4));
382 assert_checkequal(full(v([1 5])), vf([1 5]));
383 assert_checkequal(full(v([4 3])), vf([4 3]));
384 assert_checkequal(full(v([4 4])), vf([4 4]));
385 assert_checkequal(full(v([1 1])), vf([1 1]));
386 acff=full(ac);
387 assert_checkequal(full(ac(1,3)), acff(1,3));
388 assert_checkequal(full(ac(1,4)), acff(1,4));
389 assert_checkequal(full(ac(1,:)), acff(1,:));
390 vc=sparse([2 1;3 1;4 1;6 1],[10-3*%i;11;12+5*%i;13+0.5*%i],[6,1]);vcf=full(vc);
391 assert_checkequal(full(vc(:)), vcf(:));
392 assert_checkequal(full(vc(3:4)), vcf(3:4));
393 assert_checkequal(full(vc([1 5])), vcf([1 5]));
394 assert_checkequal(full(vc([4 3])), vcf([4 3]));
395 assert_checkequal(full(vc([4 4])), vcf([4 4]));
396 assert_checkequal(full(vc([1 1])), vcf([1 1]));
397 vc=vc';vcf=vcf';
398 assert_checkequal(full(vc(:)), vcf(:));
399 assert_checkequal(full(vc(3:4)), vcf(3:4));
400 assert_checkequal(full(vc([1 5])), vcf([1 5]));
401 assert_checkequal(full(vc([4 3])), vcf([4 3]));
402 assert_checkequal(full(vc([4 4])), vcf([4 4]));
403 assert_checkequal(full(vc([1 1])), vcf([1 1]));
404 // ----------------------------------------------------------
405 // test des insertions
406 //-----------------------------------------------------------
407 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
408 vt=sparse([1 2;1 3;1 4;1 6],[10;11;12;13],[1,6]);
409 // full line insertion
410 //----------------------
411 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
412 assert_checkequal(full(a1), A);
413 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
414 assert_checkequal(full(a1), A);
415 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
416 assert_checkequal(full(a1), A);
417 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
418 assert_checkequal(full(a1), A);
419 a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
420 assert_checkequal(full(a1), A);
421 a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
422 assert_checkequal(full(a1), A);
423 a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([1 3],:)=[Vt;2*Vt];
424 assert_checkequal(full(a1), A);
425 a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([3 1],:)=[Vt;2*Vt];
426 assert_checkequal(full(a1), A);
427 a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);Vt=full(vt);A([1 3 1],:)=[Vt;2*Vt;3*Vt];
428 assert_checkequal(full(a1), A);
429 //  insert zero vector
430 vt=sparse([],[],[1,6]);
431 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
432 assert_checkequal(full(a1), A);
433 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
434 assert_checkequal(full(a1), A);
435 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
436 assert_checkequal(full(a1), A);
437 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
438 assert_checkequal(full(a1), A);
439 a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
440 assert_checkequal(full(a1), A);
441 a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
442 assert_checkequal(full(a1), A);
443 a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([1 3],:)=[Vt;2*Vt];
444 assert_checkequal(full(a1), A);
445 a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);Vt=full(vt);A([3 1],:)=[Vt;2*Vt];
446 assert_checkequal(full(a1), A);
447 a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);Vt=full(vt);A([1 3 1],:)=[Vt;2*Vt;3*Vt];
448 assert_checkequal(full(a1), A);
449 a=sparse([],[],[6,6]);
450 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
451 assert_checkequal(full(a1), A);
452 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
453 assert_checkequal(full(a1), A);
454 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
455 assert_checkequal(full(a1), A);
456 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
457 assert_checkequal(full(a1), A);
458 a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
459 assert_checkequal(full(a1), A);
460 a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
461 assert_checkequal(full(a1), A);
462 b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);
463 a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
464 assert_checkequal(full(a1), A);
465 a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
466 assert_checkequal(full(a1), A);
467 b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);
468 a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
469 assert_checkequal(full(a1), A);
470 //  insert zero vector
471 vt=sparse([],[],[1,6]);
472 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
473 assert_checkequal(full(a1), A);
474 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
475 assert_checkequal(full(a1), A);
476 a1=a;a1(1,:)=vt;A=full(a);Vt=full(vt);A(1,:)=Vt;
477 assert_checkequal(full(a1), A);
478 a1=a;a1(3,:)=vt;A=full(a);Vt=full(vt);A(3,:)=Vt;
479 assert_checkequal(full(a1), A);
480 a1=a;a1(7,:)=vt;A=full(a);Vt=full(vt);A(7,:)=Vt;
481 assert_checkequal(full(a1), A);
482 a1=a;a1(8,:)=vt;A=full(a);Vt=full(vt);A(8,:)=Vt;
483 assert_checkequal(full(a1), A);
484 b=sparse([1 1;1 3;1 6;2 1;2 2;2 4],10:15,[2,6]);
485 a1=a;a1([1 3],:)=b;A=full(a);B=full(b);A([1 3],:)=B;
486 assert_checkequal(full(a1), A);
487 a1=a;a1([3 1],:)=b;A=full(a);B=full(b);A([3 1],:)=B;
488 assert_checkequal(full(a1), A);
489 b=sparse([1 1;1 3;1 6;2 1;2 2;2 4;3 3;3 5],10:17,[3,6]);
490 a1=a;a1([1 3 1],:)=b;A=full(a);B=full(b);A([1 3 1],:)=B;
491 assert_checkequal(full(a1), A);
492 // full column insertion
493 //----------------------
494 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
495 v=sparse([2 1;3 1;4 1;6 1],[10;11;12;13],[6,1]);
496 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
497 assert_checkequal(full(a1), A);
498 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
499 assert_checkequal(full(a1), A);
500 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
501 assert_checkequal(full(a1), A);
502 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
503 assert_checkequal(full(a1), A);
504 a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
505 assert_checkequal(full(a1), A);
506 //
507 a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
508 assert_checkequal(full(a1), A);
509 a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
510 assert_checkequal(full(a1), A);
511 b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
512 a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
513 assert_checkequal(full(a1), A);
514 a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
515 assert_checkequal(full(a1), A);
516 b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
517 a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
518 assert_checkequal(full(a1), A);
519 v=sparse([],[],[6,1]);
520 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
521 assert_checkequal(full(a1), A);
522 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
523 assert_checkequal(full(a1), A);
524 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
525 assert_checkequal(full(a1), A);
526 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
527 assert_checkequal(full(a1), A);
528 a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
529 assert_checkequal(full(a1), A);
530 //
531 a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
532 assert_checkequal(full(a1), A);
533 a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
534 assert_checkequal(full(a1), A);
535 b=sparse([],[],[6,2]);
536 a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
537 assert_checkequal(full(a1), A);
538 a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
539 assert_checkequal(full(a1), A);
540 b=sparse([],[],[6,3]);
541 a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
542 assert_checkequal(full(a1), A);
543 a=sparse([],[],[6,6]);
544 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
545 assert_checkequal(full(a1), A);
546 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
547 assert_checkequal(full(a1), A);
548 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
549 assert_checkequal(full(a1), A);
550 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
551 assert_checkequal(full(a1), A);
552 a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
553 assert_checkequal(full(a1), A);
554 //
555 a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
556 assert_checkequal(full(a1), A);
557 a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
558 assert_checkequal(full(a1), A);
559 b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
560 a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
561 assert_checkequal(full(a1), A);
562 a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
563 assert_checkequal(full(a1), A);
564 b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
565 a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
566 assert_checkequal(full(a1), A);
567 v=sparse([],[],[6,1]);
568 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
569 assert_checkequal(full(a1), A);
570 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
571 assert_checkequal(full(a1), A);
572 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
573 assert_checkequal(full(a1), A);
574 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
575 assert_checkequal(full(a1), A);
576 a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
577 assert_checkequal(full(a1), A);
578 //
579 a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
580 assert_checkequal(full(a1), A);
581 a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
582 assert_checkequal(full(a1), A);
583 b=sparse([1 2;2 1;3 1;3 2;4 1;6 2],10:15,[6,2]);
584 a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
585 assert_checkequal(full(a1), A);
586 a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
587 assert_checkequal(full(a1), A);
588 b=sparse([1 2;2 1;2 3;3 1;3 2;4 1;5 3;6 2],10:17,[6,3]);
589 a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
590 assert_checkequal(full(a1), A);
591 v=sparse([],[],[6,1]);
592 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
593 assert_checkequal(full(a1), A);
594 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
595 assert_checkequal(full(a1), A);
596 a1=a;a1(:,1)=v;A=full(a);V=full(v);A(:,1)=V;
597 assert_checkequal(full(a1), A);
598 a1=a;a1(:,2)=v;A=full(a);V=full(v);A(:,2)=V;
599 assert_checkequal(full(a1), A);
600 a1=a;a1(:,3)=v;A=full(a);V=full(v);A(:,3)=V;
601 assert_checkequal(full(a1), A);
602 //
603 a1=a;a1(:,7)=v;A=full(a);V=full(v);A(:,7)=V;
604 assert_checkequal(full(a1), A);
605 a1=a;a1(:,8)=v;A=full(a);V=full(v);A(:,8)=V;
606 assert_checkequal(full(a1), A);
607 b=sparse([],[],[6,2]);
608 a1=a;a1(:,[1 3])=b;A=full(a);B=full(b);A(:,[1 3])=B;
609 assert_checkequal(full(a1), A);
610 a1=a;a1(:,[3 1])=b;A=full(a);B=full(b);A(:,[3 1])=B;
611 assert_checkequal(full(a1), A);
612 b=sparse([],[],[6,3]);
613 a1=a;a1(:,[1 3 1])=b;A=full(a);B=full(b);A(:,[1 3 1])=B;
614 assert_checkequal(full(a1), A);
615 // row column insertion
616 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
617 b=sparse([1 2;1 3;3 3],-(1:3),[3,3]);
618 a1=a;a1(1,1)=sparse(30);A=full(a);A(1,1)=30;
619 assert_checkequal(full(a1), A);
620 a1=a;a1(1,6)=sparse(30);A=full(a);A(1,6)=30;
621 assert_checkequal(full(a1), A);
622 a1=a;a1(1,8)=sparse(30);A=full(a);A(1,8)=30;
623 assert_checkequal(full(a1), A);
624 a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=full(b);
625 assert_checkequal(full(a1), A);
626 a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=full(b);
627 assert_checkequal(full(a1), A);
628 a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=full(b);
629 assert_checkequal(full(a1), A);
630 a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=full(b);
631 assert_checkequal(full(a1), A);
632 a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=full(b);
633 assert_checkequal(full(a1), A);
634 a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=full(b);
635 assert_checkequal(full(a1), A);
636 a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=full(b);
637 assert_checkequal(full(a1), A);
638 a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=full(b);
639 assert_checkequal(full(a1), A);
640 //sparse full
641 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
642 vt=11:16;
643 // full line insertion
644 //----------------------
645 a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
646 assert_checkequal(full(a1), A);
647 a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
648 assert_checkequal(full(a1), A);
649 a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
650 assert_checkequal(full(a1), A);
651 a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
652 assert_checkequal(full(a1), A);
653 a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
654 assert_checkequal(full(a1), A);
655 a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
656 assert_checkequal(full(a1), A);
657 a1=a;a1([1 3],:)=[vt;2*vt];A=full(a);A([1 3],:)=[vt;2*vt];
658 assert_checkequal(full(a1), A);
659 a1=a;a1([3 1],:)=[vt;2*vt];A=full(a);A([3 1],:)=[vt;2*vt];
660 assert_checkequal(full(a1), A);
661 a1=a;a1([1 3 1],:)=[vt;2*vt;3*vt];A=full(a);A([1 3 1],:)=[vt;2*vt;3*vt];
662 assert_checkequal(full(a1), A);
663 a=sparse([],[],[6,6]);
664 a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
665 assert_checkequal(full(a1), A);
666 a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
667 assert_checkequal(full(a1), A);
668 a1=a;a1(1,:)=vt;A=full(a);A(1,:)=vt;
669 assert_checkequal(full(a1), A);
670 a1=a;a1(3,:)=vt;A=full(a);A(3,:)=vt;
671 assert_checkequal(full(a1), A);
672 a1=a;a1(7,:)=vt;A=full(a);A(7,:)=vt;
673 assert_checkequal(full(a1), A);
674 a1=a;a1(8,:)=vt;A=full(a);A(8,:)=vt;
675 assert_checkequal(full(a1), A);
676 b=[1:6;11:16];
677 a1=a;a1([1 3],:)=b;A=full(a);A([1 3],:)=b;
678 assert_checkequal(full(a1), A);
679 a1=a;a1([3 1],:)=b;A=full(a);A([3 1],:)=b;
680 assert_checkequal(full(a1), A);
681 b=[1:6;11:16;21:26];
682 a1=a;a1([1 3 1],:)=b;A=full(a);A([1 3 1],:)=b;
683 assert_checkequal(full(a1), A);
684 // full column insertion
685 //----------------------
686 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
687 v=(1:6)';
688 a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
689 assert_checkequal(full(a1), A);
690 a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
691 assert_checkequal(full(a1), A);
692 a1=a;a1(:,1)=v;A=full(a);A(:,1)=v;
693 assert_checkequal(full(a1), A);
694 a1=a;a1(:,2)=v;A=full(a);A(:,2)=v;
695 assert_checkequal(full(a1), A);
696 a1=a;a1(:,3)=v;A=full(a);A(:,3)=v;
697 assert_checkequal(full(a1), A);
698 //
699 a1=a;a1(:,7)=v;A=full(a);A(:,7)=v;
700 assert_checkequal(full(a1), A);
701 a1=a;a1(:,8)=v;A=full(a);A(:,8)=v;
702 assert_checkequal(full(a1), A);
703 b=[(1:6)' (11:16)'];
704 a1=a;a1(:,[1 3])=b;A=full(a);A(:,[1 3])=b;
705 assert_checkequal(full(a1), A);
706 a1=a;a1(:,[3 1])=b;A=full(a);A(:,[3 1])=b;
707 assert_checkequal(full(a1), A);
708 b=[(1:6)' (11:16)' (21:26)'];
709 a1=a;a1(:,[1 3 1])=b;A=full(a);A(:,[1 3 1])=b;
710 assert_checkequal(full(a1), A);
711 //********
712 // row column insertion
713 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
714 b=-[1 2 3;4 5 6;7 8 9];
715 a1=a;a1(1,1)=30;A=full(a);A(1,1)=30;
716 assert_checkequal(full(a1), A);
717 a1=a;a1(1,6)=30;A=full(a);A(1,6)=30;
718 assert_checkequal(full(a1), A);
719 a1=a;a1(1,8)=30;A=full(a);A(1,8)=30;
720 assert_checkequal(full(a1), A);
721 a1=a;a1(1:3,1:3)=b;A=full(a);A(1:3,1:3)=b;
722 assert_checkequal(full(a1), A);
723 a1=a;a1(1:3,6:8)=b;A=full(a);A(1:3,6:8)=b;
724 assert_checkequal(full(a1), A);
725 a1=a;a1(6:8,1:3)=b;A=full(a);A(6:8,1:3)=b;
726 assert_checkequal(full(a1), A);
727 a1=a;a1([3 2 1],1:3)=b;A=full(a);A([3 2 1],1:3)=b;
728 assert_checkequal(full(a1), A);
729 a1=a;a1([1 2 1],1:3)=b;A=full(a);A([1 2 1],1:3)=b;
730 assert_checkequal(full(a1), A);
731 a1=a;a1([3 2 1],[3 2 1])=b;A=full(a);A([3 2 1],[3 2 1])=b;
732 assert_checkequal(full(a1), A);
733 a1=a;a1([1 2 1],[3 2 1])=b;A=full(a);A([1 2 1],[3 2 1])=b;
734 assert_checkequal(full(a1), A);
735 a1=a;a1([1 2 1],[1 2 1])=b;A=full(a);A([1 2 1],[1 2 1])=b;
736 assert_checkequal(full(a1), A);
737 // vector insertion
738 v=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);
739 v1=v;v1(1)=33;V=full(v);V(1)=33;
740 assert_checkequal(full(v1), V);
741 v1=v;v1(2)=33;V=full(v);V(2)=33;
742 assert_checkequal(full(v1), V);
743 v1=v;v1(8)=33;V=full(v);V(8)=33;
744 assert_checkequal(full(v1), V);
745 v1=v;v1([1 2 8])=[5;10;33];V=full(v);V([1 2 8])=[5;10;33];
746 assert_checkequal(full(v1), V);
747 v1=v;v1(:)=[];
748 assert_checkequal(full(v1), []);
749 v1=v;v1(1)=sparse(33);V=full(v);V(1)=33;
750 assert_checkequal(full(v1), V);
751 v1=v;v1(2)=sparse(33);V=full(v);V(2)=33;
752 assert_checkequal(full(v1), V);
753 v1=v;v1(8)=sparse(33);V=full(v);V(8)=33;
754 assert_checkequal(full(v1), V);
755 v1=v;v1([1 2 8])=sparse([5;10;33]);V=full(v);V([1 2 8])=[5;10;33];
756 assert_checkequal(full(v1), V);
757 v1=v;v1([1 2 1])=sparse([5;10;33]);V=full(v);V([1 2 1])=[5;10;33];
758 assert_checkequal(full(v1), V);
759 v1=v;v1(:)=[];
760 assert_checkequal(full(v1), []);
761 v1=v;v1(:)=sparse([2 1],44,[6 1]);V=full(v);V(:)=[0;44;0;0;0;0];
762 assert_checkequal(full(v1), V);
763 v=v';
764 v1=v;v1(1)=33;V=full(v);V(1)=33;
765 assert_checkequal(full(v1), V);
766 v1=v;v1(2)=33;V=full(v);V(2)=33;
767 assert_checkequal(full(v1), V);
768 v1=v;v1(8)=33;V=full(v);V(8)=33;
769 assert_checkequal(full(v1), V);
770 v1=v;v1([1 2 8])=[5 10 33];V=full(v);V([1 2 8])=[5 10 33];
771 assert_checkequal(full(v1), V);
772 v1=v;v1(1)=sparse(33);V=full(v);V(1)=33;
773 assert_checkequal(full(v1), V);
774 v1=v;v1(2)=sparse(33);V=full(v);V(2)=33;
775 assert_checkequal(full(v1), V);
776 v1=v;v1(8)=sparse(33);V=full(v);V(8)=33;
777 assert_checkequal(full(v1), V);
778 v1=v;v1([1 2 8])=sparse([5 10 33]);V=full(v);V([1 2 8])=[5 10 33];
779 assert_checkequal(full(v1), V);
780 v1=v;v1([1 2 1])=sparse([5 10 33]);V=full(v);V([1 2 1])=[5 10 33];
781 assert_checkequal(full(v1), V);
782 v1=v;v1(:)=sparse([1 2],44,[1,6]);V=full(v);V(:)=[0 44 0 0 0 0];
783 assert_checkequal(full(v1), V);
784 v1=v;v1(1)=[];V=full(v);V(1)=[];
785 assert_checkequal(full(v1), V);
786 //test des comparaisons
787 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
788 b=sparse([1 6;1 2;6 5],[10;-1;-1],[6 6]);
789 assert_checkequal(full(a==a), full(a)==full(a));
790 assert_checkequal(full(a<>a), (full(a)<>full(a)));
791 assert_checkequal(full(a>sparse(5)), (full(a)>5));
792 assert_checkequal(full(sparse(5)>a), (5>full(a)));
793 assert_checkequal(full(b>a), (full(b)>full(a)));
794 assert_checkequal(full(a==full(a)), full(a)==full(a));
795 assert_checkequal(full(a<>full(a)), (full(a)<>full(a)));
796 assert_checkequal(full(a>5), (full(a)>5));
797 assert_checkequal(full(5>a), (5>full(a)));
798 assert_checkequal(full(b>full(a)), (full(b)>full(a)));
799 assert_checkequal(full(full(a)==a), full(a)==full(a));
800 assert_checkequal(full(full(a)<>a), (full(a)<>full(a)));
801 assert_checkequal(full(full(a)>sparse(5)), (full(a)>5));
802 assert_checkequal(full(full(b)>a), (full(b)>full(a)));
803 a=sparse([1 1;3 1;6 1],[10 11 12],[6 1]);
804 assert_checkequal(full(a==a), full(a)==full(a));
805 assert_checkequal(full(a<>a), (full(a)<>full(a)));
806 assert_checkequal(full(a>sparse(5)), (full(a)>5));
807 assert_checkequal(full(sparse(5)>a), (5>full(a)));
808 assert_checkequal(full(a==full(a)), full(a)==full(a));
809 assert_checkequal(full(a<>full(a)), (full(a)<>full(a)));
810 assert_checkequal(full(a>5), (full(a)>5));
811 assert_checkequal(full(5>a), (5>full(a)));
812 assert_checkequal(full(full(a)==a), full(a)==full(a));
813 assert_checkequal(full(full(a)<>a), (full(a)<>full(a)));
814 assert_checkequal(full(full(a)>sparse(5)), (full(a)>5));
815 a=a';
816 assert_checkequal(full(a==a), full(a)==full(a));
817 assert_checkequal(full(a<>a), (full(a)<>full(a)));
818 assert_checkequal(full(a>sparse(5)), (full(a)>5));
819 assert_checkequal(full(sparse(5)>a), (5>full(a)));
820 assert_checkequal(full(a==full(a)), full(a)==full(a));
821 assert_checkequal(full(a<>full(a)), (full(a)<>full(a)));
822 assert_checkequal(full(a>5), (full(a)>5));
823 assert_checkequal(full(5>a), (5>full(a)));
824 assert_checkequal(full(full(a)==a), full(a)==full(a));
825 assert_checkequal(full(full(a)<>a), (full(a)<>full(a)));
826 assert_checkequal(full(full(a)>sparse(5)), (full(a)>5));
827 a=sparse([1 6;1 5;1 3;2 4;2 1;4 4;4 3;5 1;6 6],1:9,[6 6]);
828 b=sparse([1 6;1 2;5 5],[10;-1;-1],[5 6]);
829 assert_checkfalse(a==b);
830 assert_checktrue(a<>b);