@@ -412,50 +412,58 @@ lmul!(A, B)
412412
413413_vec_or_mat_str (s:: Tuple{Any} ) = " vector"
414414_vec_or_mat_str (s:: Tuple{Any,Any} ) = " matrix"
415- @noinline function matmul_size_check (sizeA:: Tuple{Integer,Vararg{Integer}} , sizeB:: Tuple{Integer,Vararg{Integer}} )
415+ function matmul_size_check (sizeA:: Tuple{Integer,Vararg{Integer}} , sizeB:: Tuple{Integer,Vararg{Integer}} )
416416 szA2 = get (sizeA, 2 , 1 )
417417 if szA2 != sizeB[1 ]
418- strA = _vec_or_mat_str (sizeA)
419- strB = _vec_or_mat_str (sizeB)
420- B_size_len = length (sizeB) == 1 ? sizeB[1 ] : sizeB
421- size_or_len_str_B = B_size_len isa Integer ? " length" : " size"
422- dim_or_len_str_B = B_size_len isa Integer ? " length" : " first dimension"
423- pos_str_A = LazyString (length (sizeA) == length (sizeB) ? " first " : " " , strA)
424- pos_str_B = LazyString (length (sizeA) == length (sizeB) ? " second " : " " , strB)
425- throw (DimensionMismatch (
426- LazyString (
427- lazy " incompatible dimensions for matrix multiplication: " ,
428- lazy " tried to multiply a $strA of size $sizeA with a $strB of $size_or_len_str_B $B_size_len. " ,
429- lazy " The second dimension of the $pos_str_A: $szA2, does not match the $dim_or_len_str_B of the $pos_str_B: $(sizeB[1])."
430- )
431- )
432- )
418+ matmul_size_check_error (sizeA, sizeB)
433419 end
434420 return nothing
435421end
436- @noinline function matmul_size_check (sizeC:: Tuple{Integer,Vararg{Integer}} , sizeA:: Tuple{Integer,Vararg{Integer}} , sizeB:: Tuple{Integer,Vararg{Integer}} )
422+ @noinline function matmul_size_check_error (sizeA:: Tuple{Integer,Vararg{Integer}} , sizeB:: Tuple{Integer,Vararg{Integer}} )
423+ strA = _vec_or_mat_str (sizeA)
424+ strB = _vec_or_mat_str (sizeB)
425+ B_size_len = length (sizeB) == 1 ? sizeB[1 ] : sizeB
426+ size_or_len_str_B = B_size_len isa Integer ? " length" : " size"
427+ dim_or_len_str_B = B_size_len isa Integer ? " length" : " first dimension"
428+ pos_str_A = LazyString (length (sizeA) == length (sizeB) ? " first " : " " , strA)
429+ pos_str_B = LazyString (length (sizeA) == length (sizeB) ? " second " : " " , strB)
430+ throw (DimensionMismatch (
431+ LazyString (
432+ lazy " incompatible dimensions for matrix multiplication: " ,
433+ lazy " tried to multiply a $strA of size $sizeA with a $strB of $size_or_len_str_B $B_size_len. " ,
434+ lazy " The second dimension of the $pos_str_A: $szA2, does not match the $dim_or_len_str_B of the $pos_str_B: $(sizeB[1])."
435+ )
436+ )
437+ )
438+ return nothing
439+ end
440+ function matmul_size_check (sizeC:: Tuple{Integer,Vararg{Integer}} , sizeA:: Tuple{Integer,Vararg{Integer}} , sizeB:: Tuple{Integer,Vararg{Integer}} )
437441 matmul_size_check (sizeA, sizeB)
438442 szB2 = get (sizeB, 2 , 1 )
439443 szC2 = get (sizeC, 2 , 1 )
440444 if sizeC[1 ] != sizeA[1 ] || szC2 != szB2
441- strA = _vec_or_mat_str (sizeA)
442- strB = _vec_or_mat_str (sizeB)
443- strC = _vec_or_mat_str (sizeC)
444- C_size_len = length (sizeC) == 1 ? sizeC[1 ] : sizeC
445- size_or_len_str_C = C_size_len isa Integer ? " length" : " size"
446- B_size_len = length (sizeB) == 1 ? sizeB[1 ] : sizeB
447- size_or_len_str_B = B_size_len isa Integer ? " length" : " size"
448- destsize = length (sizeB) == length (sizeC) == 1 ? sizeA[1 ] : (sizeA[1 ], szB2)
449- size_or_len_str_dest = destsize isa Integer ? " length" : " size"
450- throw (DimensionMismatch (
451- LazyString (
452- " incompatible destination size: " ,
453- lazy " the destination $strC of $size_or_len_str_C $C_size_len is incomatible with the product of a $strA of size $sizeA and a $strB of $size_or_len_str_B $B_size_len. " ,
454- lazy " The destination must be of $size_or_len_str_dest $destsize."
455- )
445+ matmul_size_check_error (sizeC, sizeA, sizeB)
446+ end
447+ return nothing
448+ end
449+ @noinline function matmul_size_check_error (sizeC:: Tuple{Integer,Vararg{Integer}} , sizeA:: Tuple{Integer,Vararg{Integer}} , sizeB:: Tuple{Integer,Vararg{Integer}} )
450+ strA = _vec_or_mat_str (sizeA)
451+ strB = _vec_or_mat_str (sizeB)
452+ strC = _vec_or_mat_str (sizeC)
453+ C_size_len = length (sizeC) == 1 ? sizeC[1 ] : sizeC
454+ size_or_len_str_C = C_size_len isa Integer ? " length" : " size"
455+ B_size_len = length (sizeB) == 1 ? sizeB[1 ] : sizeB
456+ size_or_len_str_B = B_size_len isa Integer ? " length" : " size"
457+ destsize = length (sizeB) == length (sizeC) == 1 ? sizeA[1 ] : (sizeA[1 ], szB2)
458+ size_or_len_str_dest = destsize isa Integer ? " length" : " size"
459+ throw (DimensionMismatch (
460+ LazyString (
461+ " incompatible destination size: " ,
462+ lazy " the destination $strC of $size_or_len_str_C $C_size_len is incomatible with the product of a $strA of size $sizeA and a $strB of $size_or_len_str_B $B_size_len. " ,
463+ lazy " The destination must be of $size_or_len_str_dest $destsize."
456464 )
457465 )
458- end
466+ )
459467 return nothing
460468end
461469
0 commit comments