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