1 #![cfg_attr(rustfmt, rustfmt_skip)]
2 
3 use na::{Matrix,
4          DMatrix,
5          Matrix3, Matrix4, Matrix5,
6          Matrix4x3, Matrix3x4, Matrix5x3, Matrix3x5, Matrix4x5, Matrix5x4};
7 use na::{Dynamic, U2, U3, U5};
8 
9 
10 #[test]
upper_lower_triangular()11 fn upper_lower_triangular() {
12     let m = Matrix4::new(
13         11.0, 12.0, 13.0, 14.0,
14         21.0, 22.0, 23.0, 24.0,
15         31.0, 32.0, 33.0, 34.0,
16         41.0, 42.0, 43.0, 44.0);
17 
18     let um = Matrix4::new(
19         11.0, 12.0, 13.0, 14.0,
20          0.0, 22.0, 23.0, 24.0,
21          0.0,  0.0, 33.0, 34.0,
22          0.0,  0.0,  0.0, 44.0);
23 
24     let lm = Matrix4::new(
25         11.0,  0.0,  0.0,  0.0,
26         21.0, 22.0,  0.0,  0.0,
27         31.0, 32.0, 33.0,  0.0,
28         41.0, 42.0, 43.0, 44.0);
29 
30     let computed_um = m.upper_triangle();
31     let computed_lm = m.lower_triangle();
32 
33     assert_eq!(um, computed_um);
34     assert_eq!(lm, computed_lm);
35 
36     let symm_um = Matrix4::new(
37         11.0, 12.0, 13.0, 14.0,
38         12.0, 22.0, 23.0, 24.0,
39         13.0, 23.0, 33.0, 34.0,
40         14.0, 24.0, 34.0, 44.0);
41 
42     let symm_lm = Matrix4::new(
43         11.0, 21.0, 31.0, 41.0,
44         21.0, 22.0, 32.0, 42.0,
45         31.0, 32.0, 33.0, 43.0,
46         41.0, 42.0, 43.0, 44.0);
47 
48     let mut computed_symm_um = m.clone();
49     let mut computed_symm_lm = m.clone();
50 
51     computed_symm_um.fill_lower_triangle_with_upper_triangle();
52     computed_symm_lm.fill_upper_triangle_with_lower_triangle();
53     assert_eq!(symm_um, computed_symm_um);
54     assert_eq!(symm_lm, computed_symm_lm);
55 
56 
57     let m = Matrix5x3::new(
58         11.0, 12.0, 13.0,
59         21.0, 22.0, 23.0,
60         31.0, 32.0, 33.0,
61         41.0, 42.0, 43.0,
62         51.0, 52.0, 53.0);
63 
64     let um = Matrix5x3::new(
65         11.0, 12.0, 13.0,
66          0.0, 22.0, 23.0,
67          0.0,  0.0, 33.0,
68          0.0,  0.0,  0.0,
69          0.0,  0.0,  0.0);
70 
71     let lm = Matrix5x3::new(
72         11.0,  0.0,  0.0,
73         21.0, 22.0,  0.0,
74         31.0, 32.0, 33.0,
75         41.0, 42.0, 43.0,
76         51.0, 52.0, 53.0);
77 
78     let computed_um = m.upper_triangle();
79     let computed_lm = m.lower_triangle();
80 
81     assert_eq!(um, computed_um);
82     assert_eq!(lm, computed_lm);
83 
84 
85     let m = Matrix3x5::new(
86         11.0, 12.0, 13.0, 14.0, 15.0,
87         21.0, 22.0, 23.0, 24.0, 25.0,
88         31.0, 32.0, 33.0, 34.0, 35.0);
89 
90     let um = Matrix3x5::new(
91         11.0, 12.0, 13.0, 14.0, 15.0,
92          0.0, 22.0, 23.0, 24.0, 25.0,
93          0.0,  0.0, 33.0, 34.0, 35.0);
94 
95     let lm = Matrix3x5::new(
96         11.0,  0.0,  0.0,  0.0, 0.0,
97         21.0, 22.0,  0.0,  0.0, 0.0,
98         31.0, 32.0, 33.0,  0.0, 0.0);
99 
100     let computed_um = m.upper_triangle();
101     let computed_lm = m.lower_triangle();
102 
103     assert_eq!(um, computed_um);
104     assert_eq!(lm, computed_lm);
105 
106     let mut m = Matrix4x5::new(
107         11.0, 12.0, 13.0, 14.0, 15.0,
108         21.0, 22.0, 23.0, 24.0, 25.0,
109         31.0, 32.0, 33.0, 34.0, 35.0,
110         41.0, 42.0, 43.0, 44.0, 45.0);
111 
112     let expected_m = Matrix4x5::new(
113         11.0, 12.0,  0.0,  0.0,  0.0,
114         21.0, 22.0, 23.0,  0.0,  0.0,
115         31.0, 32.0, 33.0, 34.0,  0.0,
116         41.0, 42.0, 43.0, 44.0, 45.0);
117 
118     m.fill_upper_triangle(0.0, 2);
119 
120     assert_eq!(m, expected_m);
121 
122     let mut m = Matrix4x5::new(
123         11.0, 12.0, 13.0, 14.0, 15.0,
124         21.0, 22.0, 23.0, 24.0, 25.0,
125         31.0, 32.0, 33.0, 34.0, 35.0,
126         41.0, 42.0, 43.0, 44.0, 45.0);
127 
128     let expected_m = Matrix4x5::new(
129         11.0, 12.0, 13.0, 14.0, 15.0,
130         21.0, 22.0, 23.0, 24.0, 25.0,
131          0.0, 32.0, 33.0, 34.0, 35.0,
132          0.0,  0.0, 43.0, 44.0, 45.0);
133 
134     m.fill_lower_triangle(0.0, 2);
135 
136     assert_eq!(m, expected_m);
137 
138     let mut m = Matrix5x4::new(
139         11.0, 12.0, 13.0, 14.0,
140         21.0, 22.0, 23.0, 24.0,
141         31.0, 32.0, 33.0, 34.0,
142         41.0, 42.0, 43.0, 44.0,
143         51.0, 52.0, 53.0, 54.0);
144 
145     let expected_m = Matrix5x4::new(
146         11.0, 12.0,  0.0,  0.0,
147         21.0, 22.0, 23.0,  0.0,
148         31.0, 32.0, 33.0, 34.0,
149         41.0, 42.0, 43.0, 44.0,
150         51.0, 52.0, 53.0, 54.0);
151 
152     m.fill_upper_triangle(0.0, 2);
153 
154     assert_eq!(m, expected_m);
155 
156     let mut m = Matrix5x4::new(
157         11.0, 12.0, 13.0, 14.0,
158         21.0, 22.0, 23.0, 24.0,
159         31.0, 32.0, 33.0, 34.0,
160         41.0, 42.0, 43.0, 44.0,
161         51.0, 52.0, 53.0, 54.0);
162 
163     let expected_m = Matrix5x4::new(
164         11.0, 12.0, 13.0, 14.0,
165         21.0, 22.0, 23.0, 24.0,
166          0.0, 32.0, 33.0, 34.0,
167          0.0,  0.0, 43.0, 44.0,
168          0.0,  0.0,  0.0, 54.0);
169 
170     m.fill_lower_triangle(0.0, 2);
171 
172     assert_eq!(m, expected_m);
173 }
174 
175 #[test]
swap_rows()176 fn swap_rows() {
177     let mut m = Matrix5x3::new(
178         11.0, 12.0, 13.0,
179         21.0, 22.0, 23.0,
180         31.0, 32.0, 33.0,
181         41.0, 42.0, 43.0,
182         51.0, 52.0, 53.0);
183 
184     let expected = Matrix5x3::new(
185         11.0, 12.0, 13.0,
186         41.0, 42.0, 43.0,
187         31.0, 32.0, 33.0,
188         21.0, 22.0, 23.0,
189         51.0, 52.0, 53.0);
190 
191     m.swap_rows(1, 3);
192 
193     assert_eq!(m, expected);
194 }
195 
196 #[test]
swap_columns()197 fn swap_columns() {
198     let mut m = Matrix3x5::new(
199         11.0, 12.0, 13.0, 14.0, 15.0,
200         21.0, 22.0, 23.0, 24.0, 25.0,
201         31.0, 32.0, 33.0, 34.0, 35.0);
202 
203     let expected = Matrix3x5::new(
204         11.0, 14.0, 13.0, 12.0, 15.0,
205         21.0, 24.0, 23.0, 22.0, 25.0,
206         31.0, 34.0, 33.0, 32.0, 35.0);
207 
208     m.swap_columns(1, 3);
209 
210     assert_eq!(m, expected);
211 }
212 
213 #[test]
remove_columns()214 fn remove_columns() {
215     let m = Matrix3x5::new(
216         11, 12, 13, 14, 15,
217         21, 22, 23, 24, 25,
218         31, 32, 33, 34, 35);
219 
220     let expected1 = Matrix3x4::new(
221         12, 13, 14, 15,
222         22, 23, 24, 25,
223         32, 33, 34, 35);
224 
225     let expected2 = Matrix3x4::new(
226         11, 12, 13, 14,
227         21, 22, 23, 24,
228         31, 32, 33, 34);
229 
230     let expected3 = Matrix3x4::new(
231         11, 12, 14, 15,
232         21, 22, 24, 25,
233         31, 32, 34, 35);
234 
235     assert_eq!(m.remove_column(0), expected1);
236     assert_eq!(m.remove_column(4), expected2);
237     assert_eq!(m.remove_column(2), expected3);
238 
239     let expected1 = Matrix3::new(
240         13, 14, 15,
241         23, 24, 25,
242         33, 34, 35);
243 
244     let expected2 = Matrix3::new(
245         11, 12, 13,
246         21, 22, 23,
247         31, 32, 33);
248 
249     let expected3 = Matrix3::new(
250         11, 12, 15,
251         21, 22, 25,
252         31, 32, 35);
253 
254     assert_eq!(m.remove_fixed_columns::<U2>(0), expected1);
255     assert_eq!(m.remove_fixed_columns::<U2>(3), expected2);
256     assert_eq!(m.remove_fixed_columns::<U2>(2), expected3);
257 
258     // The following is just to verify that the return type dimensions is correctly inferred.
259     let computed: Matrix<_, U3, Dynamic, _> = m.remove_columns(3, 2);
260     assert!(computed.eq(&expected2));
261 }
262 
263 #[test]
remove_columns_at()264 fn remove_columns_at() {
265     let m = DMatrix::from_row_slice(5, 5, &[
266         11, 12, 13, 14, 15,
267         21, 22, 23, 24, 25,
268         31, 32, 33, 34, 35,
269         41, 42, 43, 44, 45,
270         51, 52, 53, 54, 55
271     ]);
272 
273     let expected1 = DMatrix::from_row_slice(5, 4, &[
274         12, 13, 14, 15,
275         22, 23, 24, 25,
276         32, 33, 34, 35,
277         42, 43, 44, 45,
278         52, 53, 54, 55
279     ]);
280 
281     assert_eq!(m.remove_columns_at(&[0]), expected1);
282 
283     let m = DMatrix::from_row_slice(5, 5, &[
284         11, 12, 13, 14, 15,
285         21, 22, 23, 24, 25,
286         31, 32, 33, 34, 35,
287         41, 42, 43, 44, 45,
288         51, 52, 53, 54, 55
289     ]);
290 
291     let expected2 = DMatrix::from_row_slice(5, 3, &[
292         11, 13, 15,
293         21, 23, 25,
294         31, 33, 35,
295         41, 43, 45,
296         51, 53, 55
297     ]);
298 
299     assert_eq!(m.remove_columns_at(&[1,3]), expected2);
300 
301     let m = DMatrix::from_row_slice(5, 5, &[
302         11, 12, 13, 14, 15,
303         21, 22, 23, 24, 25,
304         31, 32, 33, 34, 35,
305         41, 42, 43, 44, 45,
306         51, 52, 53, 54, 55
307     ]);
308 
309     let expected3 = DMatrix::from_row_slice(5, 2, &[
310         12, 13,
311         22, 23,
312         32, 33,
313         42, 43,
314         52, 53,
315     ]);
316 
317     assert_eq!(m.remove_columns_at(&[0,3,4]), expected3);
318 }
319 
320 
321 #[test]
remove_rows()322 fn remove_rows() {
323     let m = Matrix5x3::new(
324         11, 12, 13,
325         21, 22, 23,
326         31, 32, 33,
327         41, 42, 43,
328         51, 52, 53);
329 
330     let expected1 = Matrix4x3::new(
331         21, 22, 23,
332         31, 32, 33,
333         41, 42, 43,
334         51, 52, 53);
335 
336     let expected2 = Matrix4x3::new(
337         11, 12, 13,
338         21, 22, 23,
339         31, 32, 33,
340         41, 42, 43);
341 
342     let expected3 = Matrix4x3::new(
343         11, 12, 13,
344         21, 22, 23,
345         41, 42, 43,
346         51, 52, 53);
347 
348     assert_eq!(m.remove_row(0), expected1);
349     assert_eq!(m.remove_row(4), expected2);
350     assert_eq!(m.remove_row(2), expected3);
351 
352     let expected1 = Matrix3::new(
353         31, 32, 33,
354         41, 42, 43,
355         51, 52, 53);
356 
357     let expected2 = Matrix3::new(
358         11, 12, 13,
359         21, 22, 23,
360         31, 32, 33);
361 
362     let expected3 = Matrix3::new(
363         11, 12, 13,
364         21, 22, 23,
365         51, 52, 53);
366 
367     assert_eq!(m.remove_fixed_rows::<U2>(0), expected1);
368     assert_eq!(m.remove_fixed_rows::<U2>(3), expected2);
369     assert_eq!(m.remove_fixed_rows::<U2>(2), expected3);
370 
371     // The following is just to verify that the return type dimensions is correctly inferred.
372     let computed: Matrix<_, Dynamic, U3, _> = m.remove_rows(3, 2);
373     assert!(computed.eq(&expected2));
374 }
375 
376 #[test]
remove_rows_at()377 fn remove_rows_at() {
378     let m = DMatrix::from_row_slice(5, 5, &[
379         11, 12, 13, 14, 15,
380         21, 22, 23, 24, 25,
381         31, 32, 33, 34, 35,
382         41, 42, 43, 44, 45,
383         51, 52, 53, 54, 55
384     ]);
385 
386     let expected1 = DMatrix::from_row_slice(4, 5, &[
387         21, 22, 23, 24, 25,
388         31, 32, 33, 34, 35,
389         41, 42, 43, 44, 45,
390         51, 52, 53, 54, 55
391     ]);
392 
393     assert_eq!(m.remove_rows_at(&[0]), expected1);
394 
395     let m = DMatrix::from_row_slice(5, 5, &[
396         11, 12, 13, 14, 15,
397         21, 22, 23, 24, 25,
398         31, 32, 33, 34, 35,
399         41, 42, 43, 44, 45,
400         51, 52, 53, 54, 55
401     ]);
402 
403     let expected2 = DMatrix::from_row_slice(3, 5, &[
404         11, 12, 13, 14, 15,
405         31, 32, 33, 34, 35,
406         51, 52, 53, 54, 55
407     ]);
408 
409     assert_eq!(m.remove_rows_at(&[1,3]), expected2);
410 
411     let m = DMatrix::from_row_slice(5, 5, &[
412         11, 12, 13, 14, 15,
413         21, 22, 23, 24, 25,
414         31, 32, 33, 34, 35,
415         41, 42, 43, 44, 45,
416         51, 52, 53, 54, 55
417     ]);
418 
419     let expected3 = DMatrix::from_row_slice(2, 5, &[
420         21, 22, 23, 24, 25,
421         31, 32, 33, 34, 35
422     ]);
423 
424     assert_eq!(m.remove_rows_at(&[0,3,4]), expected3);
425 }
426 
427 
428 #[test]
insert_columns()429 fn insert_columns() {
430     let m = Matrix5x3::new(
431         11, 12, 13,
432         21, 22, 23,
433         31, 32, 33,
434         41, 42, 43,
435         51, 52, 53);
436 
437     let expected1 = Matrix5x4::new(
438         0, 11, 12, 13,
439         0, 21, 22, 23,
440         0, 31, 32, 33,
441         0, 41, 42, 43,
442         0, 51, 52, 53);
443 
444     let expected2 = Matrix5x4::new(
445         11, 12, 13, 0,
446         21, 22, 23, 0,
447         31, 32, 33, 0,
448         41, 42, 43, 0,
449         51, 52, 53, 0);
450 
451     let expected3 = Matrix5x4::new(
452         11, 12, 0, 13,
453         21, 22, 0, 23,
454         31, 32, 0, 33,
455         41, 42, 0, 43,
456         51, 52, 0, 53);
457 
458     assert_eq!(m.insert_column(0, 0), expected1);
459     assert_eq!(m.insert_column(3, 0), expected2);
460     assert_eq!(m.insert_column(2, 0), expected3);
461 
462     let expected1 = Matrix5::new(
463         0, 0, 11, 12, 13,
464         0, 0, 21, 22, 23,
465         0, 0, 31, 32, 33,
466         0, 0, 41, 42, 43,
467         0, 0, 51, 52, 53);
468 
469     let expected2 = Matrix5::new(
470         11, 12, 13, 0, 0,
471         21, 22, 23, 0, 0,
472         31, 32, 33, 0, 0,
473         41, 42, 43, 0, 0,
474         51, 52, 53, 0, 0);
475 
476     let expected3 = Matrix5::new(
477         11, 12, 0, 0, 13,
478         21, 22, 0, 0, 23,
479         31, 32, 0, 0, 33,
480         41, 42, 0, 0, 43,
481         51, 52, 0, 0, 53);
482 
483     assert_eq!(m.insert_fixed_columns::<U2>(0, 0), expected1);
484     assert_eq!(m.insert_fixed_columns::<U2>(3, 0), expected2);
485     assert_eq!(m.insert_fixed_columns::<U2>(2, 0), expected3);
486 
487     // The following is just to verify that the return type dimensions is correctly inferred.
488     let computed: Matrix<_, U5, Dynamic, _> = m.insert_columns(3, 2, 0);
489     assert!(computed.eq(&expected2));
490 }
491 
492 #[test]
insert_columns_to_empty_matrix()493 fn insert_columns_to_empty_matrix() {
494     let m1 = DMatrix::repeat(0, 0, 0);
495     let m2 = DMatrix::repeat(3, 0, 0);
496 
497     let expected1 = DMatrix::repeat(0, 5, 42);
498     let expected2 = DMatrix::repeat(3, 5, 42);
499 
500     assert_eq!(expected1, m1.insert_columns(0, 5, 42));
501     assert_eq!(expected2, m2.insert_columns(0, 5, 42));
502 }
503 
504 #[test]
insert_rows()505 fn insert_rows() {
506     let m = Matrix3x5::new(
507         11, 12, 13, 14, 15,
508         21, 22, 23, 24, 25,
509         31, 32, 33, 34, 35);
510 
511     let expected1 = Matrix4x5::new(
512          0,  0,  0,  0,  0,
513         11, 12, 13, 14, 15,
514         21, 22, 23, 24, 25,
515         31, 32, 33, 34, 35);
516 
517     let expected2 = Matrix4x5::new(
518         11, 12, 13, 14, 15,
519         21, 22, 23, 24, 25,
520         31, 32, 33, 34, 35,
521          0,  0,  0,  0,  0);
522 
523     let expected3 = Matrix4x5::new(
524         11, 12, 13, 14, 15,
525         21, 22, 23, 24, 25,
526          0,  0,  0,  0,  0,
527         31, 32, 33, 34, 35);
528 
529     assert_eq!(m.insert_row(0, 0), expected1);
530     assert_eq!(m.insert_row(3, 0), expected2);
531     assert_eq!(m.insert_row(2, 0), expected3);
532 
533     let expected1 = Matrix5::new(
534          0,  0,  0,  0,  0,
535          0,  0,  0,  0,  0,
536         11, 12, 13, 14, 15,
537         21, 22, 23, 24, 25,
538         31, 32, 33, 34, 35);
539 
540     let expected2 = Matrix5::new(
541         11, 12, 13, 14, 15,
542         21, 22, 23, 24, 25,
543         31, 32, 33, 34, 35,
544          0,  0,  0,  0,  0,
545          0,  0,  0,  0,  0);
546 
547     let expected3 = Matrix5::new(
548         11, 12, 13, 14, 15,
549         21, 22, 23, 24, 25,
550          0,  0,  0,  0,  0,
551          0,  0,  0,  0,  0,
552         31, 32, 33, 34, 35);
553 
554     assert_eq!(m.insert_fixed_rows::<U2>(0, 0), expected1);
555     assert_eq!(m.insert_fixed_rows::<U2>(3, 0), expected2);
556     assert_eq!(m.insert_fixed_rows::<U2>(2, 0), expected3);
557 
558     // The following is just to verify that the return type dimensions is correctly inferred.
559     let computed: Matrix<_, Dynamic, U5, _> = m.insert_rows(3, 2, 0);
560     assert!(computed.eq(&expected2));
561 }
562 
563 #[test]
insert_rows_to_empty_matrix()564 fn insert_rows_to_empty_matrix() {
565     let m1 = DMatrix::repeat(0, 0, 0);
566     let m2 = DMatrix::repeat(0, 5, 0);
567 
568     let expected1 = DMatrix::repeat(3, 0, 42);
569     let expected2 = DMatrix::repeat(3, 5, 42);
570 
571     assert_eq!(expected1, m1.insert_rows(0, 3, 42));
572     assert_eq!(expected2, m2.insert_rows(0, 3, 42));
573 }
574 
575 #[test]
resize()576 fn resize() {
577     let m = Matrix3x5::new(
578         11, 12, 13, 14, 15,
579         21, 22, 23, 24, 25,
580         31, 32, 33, 34, 35);
581 
582     let add_colls = DMatrix::from_row_slice(3, 6, &[
583         11, 12, 13, 14, 15, 42,
584         21, 22, 23, 24, 25, 42,
585         31, 32, 33, 34, 35, 42]);
586 
587     let del_colls = DMatrix::from_row_slice(3, 4, &[
588         11, 12, 13, 14,
589         21, 22, 23, 24,
590         31, 32, 33, 34]);
591 
592     let add_rows = DMatrix::from_row_slice(4, 5, &[
593         11, 12, 13, 14, 15,
594         21, 22, 23, 24, 25,
595         31, 32, 33, 34, 35,
596         42, 42, 42, 42, 42]);
597 
598     let del_rows = DMatrix::from_row_slice(2, 5, &[
599         11, 12, 13, 14, 15,
600         21, 22, 23, 24, 25]);
601 
602     let add_add = DMatrix::from_row_slice(5, 6, &[
603         11, 12, 13, 14, 15, 42,
604         21, 22, 23, 24, 25, 42,
605         31, 32, 33, 34, 35, 42,
606         42, 42, 42, 42, 42, 42,
607         42, 42, 42, 42, 42, 42]);
608 
609     let del_del = DMatrix::from_row_slice(1, 2, &[11, 12]);
610 
611     let add_del = DMatrix::from_row_slice(5, 2, &[
612         11, 12,
613         21, 22,
614         31, 32,
615         42, 42,
616         42, 42]);
617 
618     let del_add = DMatrix::from_row_slice(1, 8, &[
619         11, 12, 13, 14, 15, 42, 42, 42]);
620 
621     assert_eq!(add_colls, m.resize(3, 6, 42));
622     assert_eq!(del_colls, m.resize(3, 4, 42));
623     assert_eq!(add_rows, m.resize(4, 5, 42));
624     assert_eq!(del_rows, m.resize(2, 5, 42));
625     assert_eq!(del_del, m.resize(1, 2, 42));
626     assert_eq!(add_add, m.resize(5, 6, 42));
627     assert_eq!(add_del, m.resize(5, 2, 42));
628     assert_eq!(del_add, m.resize(1, 8, 42));
629 }
630 
631 #[test]
resize_empty_matrix()632 fn resize_empty_matrix() {
633     let m1 = DMatrix::repeat(0, 0, 0);
634     let m2 = DMatrix::repeat(1, 0, 0); // Less rows than target size.
635     let m3 = DMatrix::repeat(3, 0, 0); // Same rows as target size.
636     let m4 = DMatrix::repeat(9, 0, 0); // More rows than target size.
637     let m5 = DMatrix::repeat(0, 1, 0); // Less columns than target size.
638     let m6 = DMatrix::repeat(0, 5, 0); // Same columns as target size.
639     let m7 = DMatrix::repeat(0, 9, 0); // More columns than target size.
640 
641     let resized = DMatrix::repeat(3, 5, 42);
642     let resized_wo_rows = DMatrix::repeat(0, 5, 42);
643     let resized_wo_cols = DMatrix::repeat(3, 0, 42);
644 
645     assert_eq!(resized, m1.clone().resize(3, 5, 42));
646     assert_eq!(resized, m2.clone().resize(3, 5, 42));
647     assert_eq!(resized, m3.clone().resize(3, 5, 42));
648     assert_eq!(resized, m4.clone().resize(3, 5, 42));
649     assert_eq!(resized, m5.clone().resize(3, 5, 42));
650     assert_eq!(resized, m6.clone().resize(3, 5, 42));
651     assert_eq!(resized, m7.clone().resize(3, 5, 42));
652 
653     assert_eq!(resized_wo_rows, m1.clone().resize(0, 5, 42));
654     assert_eq!(resized_wo_rows, m2.clone().resize(0, 5, 42));
655     assert_eq!(resized_wo_rows, m3.clone().resize(0, 5, 42));
656     assert_eq!(resized_wo_rows, m4.clone().resize(0, 5, 42));
657     assert_eq!(resized_wo_rows, m5.clone().resize(0, 5, 42));
658     assert_eq!(resized_wo_rows, m6.clone().resize(0, 5, 42));
659     assert_eq!(resized_wo_rows, m7.clone().resize(0, 5, 42));
660 
661     assert_eq!(resized_wo_cols, m1.clone().resize(3, 0, 42));
662     assert_eq!(resized_wo_cols, m2.clone().resize(3, 0, 42));
663     assert_eq!(resized_wo_cols, m3.clone().resize(3, 0, 42));
664     assert_eq!(resized_wo_cols, m4.clone().resize(3, 0, 42));
665     assert_eq!(resized_wo_cols, m5.clone().resize(3, 0, 42));
666     assert_eq!(resized_wo_cols, m6.clone().resize(3, 0, 42));
667     assert_eq!(resized_wo_cols, m7.clone().resize(3, 0, 42));
668 
669     assert_eq!(m1, m1.clone().resize(0, 0, 42));
670     assert_eq!(m1, m2.resize(0, 0, 42));
671     assert_eq!(m1, m3.resize(0, 0, 42));
672     assert_eq!(m1, m4.resize(0, 0, 42));
673     assert_eq!(m1, m5.resize(0, 0, 42));
674     assert_eq!(m1, m6.resize(0, 0, 42));
675     assert_eq!(m1, m7.resize(0, 0, 42));
676 }
677