Commit a622302
authored
Consistently check matrix sizes in matmul (#1152)
Fixes #1147, and
makes the error messages more verbose.
Before
```julia
julia> zeros(0,4) * zeros(1)
ERROR: DimensionMismatch: second dimension of matrix, 4, does not match length of input vector, 1
[...]
julia> mul!(zeros(0), zeros(2,2), zeros(2))
ERROR: DimensionMismatch: first dimension of matrix, 2, does not match length of output vector, 0
[...]
```
After
```julia
julia> zeros(0,4) * zeros(1)
ERROR: DimensionMismatch: incompatible dimensions for matrix multiplication: tried to multiply a matrix of size (0, 4) with a vector of length 1. The second dimension of the matrix: 4, does not match the length of the vector: 1.
[...]
julia> zeros(0,4) * zeros(1,1)
ERROR: DimensionMismatch: incompatible dimensions for matrix multiplication: tried to multiply a matrix of size (0, 4) with a matrix of size (1, 1). The second dimension of the first matrix: 4, does not match the first dimension of the second matrix: 1.
[...]
julia> mul!(zeros(0), zeros(2,2), zeros(2))
ERROR: DimensionMismatch: incompatible destination size: the destination vector of length 0 is incomatible with the product of a matrix of size (2, 2) and a vector of length 2. The destination must be of length 2.
[...]
julia> mul!(zeros(0,1), zeros(3,2), zeros(2,3))
ERROR: DimensionMismatch: incompatible destination size: the destination matrix of size (0, 1) is incomatible with the product of a matrix of size (3, 2) and a matrix of size (2, 3). The destination must be of size (3, 3).
[...]
```1 parent 6e5ea12 commit a622302
File tree
6 files changed
+128
-118
lines changed- src
- test
6 files changed
+128
-118
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | | - | |
| 500 | + | |
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| |||
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
533 | | - | |
| 533 | + | |
534 | 534 | | |
535 | 535 | | |
536 | 536 | | |
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | 569 | | |
586 | 570 | | |
587 | 571 | | |
| |||
603 | 587 | | |
604 | 588 | | |
605 | 589 | | |
606 | | - | |
| 590 | + | |
607 | 591 | | |
608 | 592 | | |
609 | 593 | | |
| |||
851 | 835 | | |
852 | 836 | | |
853 | 837 | | |
854 | | - | |
| 838 | + | |
855 | 839 | | |
856 | 840 | | |
857 | 841 | | |
| |||
894 | 878 | | |
895 | 879 | | |
896 | 880 | | |
897 | | - | |
| 881 | + | |
898 | 882 | | |
899 | 883 | | |
900 | 884 | | |
| |||
924 | 908 | | |
925 | 909 | | |
926 | 910 | | |
927 | | - | |
| 911 | + | |
928 | 912 | | |
929 | 913 | | |
930 | 914 | | |
| |||
957 | 941 | | |
958 | 942 | | |
959 | 943 | | |
960 | | - | |
| 944 | + | |
961 | 945 | | |
962 | 946 | | |
963 | 947 | | |
| |||
1027 | 1011 | | |
1028 | 1012 | | |
1029 | 1013 | | |
1030 | | - | |
| 1014 | + | |
1031 | 1015 | | |
1032 | 1016 | | |
1033 | 1017 | | |
| |||
1063 | 1047 | | |
1064 | 1048 | | |
1065 | 1049 | | |
1066 | | - | |
| 1050 | + | |
1067 | 1051 | | |
1068 | 1052 | | |
1069 | 1053 | | |
| |||
1093 | 1077 | | |
1094 | 1078 | | |
1095 | 1079 | | |
1096 | | - | |
| 1080 | + | |
1097 | 1081 | | |
1098 | 1082 | | |
1099 | 1083 | | |
| |||
1137 | 1121 | | |
1138 | 1122 | | |
1139 | 1123 | | |
1140 | | - | |
| 1124 | + | |
1141 | 1125 | | |
1142 | 1126 | | |
1143 | 1127 | | |
| |||
1168 | 1152 | | |
1169 | 1153 | | |
1170 | 1154 | | |
1171 | | - | |
| 1155 | + | |
1172 | 1156 | | |
1173 | 1157 | | |
1174 | 1158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | 325 | | |
347 | | - | |
| 326 | + | |
348 | 327 | | |
349 | 328 | | |
350 | 329 | | |
351 | 330 | | |
352 | | - | |
| 331 | + | |
353 | 332 | | |
354 | 333 | | |
355 | 334 | | |
356 | 335 | | |
357 | | - | |
| 336 | + | |
358 | 337 | | |
359 | 338 | | |
360 | 339 | | |
| |||
363 | 342 | | |
364 | 343 | | |
365 | 344 | | |
366 | | - | |
| 345 | + | |
367 | 346 | | |
368 | 347 | | |
369 | 348 | | |
| |||
375 | 354 | | |
376 | 355 | | |
377 | 356 | | |
378 | | - | |
| 357 | + | |
379 | 358 | | |
380 | 359 | | |
381 | 360 | | |
| |||
386 | 365 | | |
387 | 366 | | |
388 | 367 | | |
389 | | - | |
| 368 | + | |
390 | 369 | | |
391 | 370 | | |
392 | 371 | | |
| |||
507 | 486 | | |
508 | 487 | | |
509 | 488 | | |
510 | | - | |
| 489 | + | |
511 | 490 | | |
512 | 491 | | |
513 | 492 | | |
| |||
532 | 511 | | |
533 | 512 | | |
534 | 513 | | |
535 | | - | |
536 | | - | |
| 514 | + | |
| 515 | + | |
537 | 516 | | |
538 | 517 | | |
539 | 518 | | |
540 | 519 | | |
541 | | - | |
542 | | - | |
| 520 | + | |
| 521 | + | |
543 | 522 | | |
544 | 523 | | |
545 | 524 | | |
| |||
0 commit comments