|  | 
| 51 | 51 | 
 | 
| 52 | 52 | # Matrix-vector multiplication | 
| 53 | 53 | function (*)(A::StridedMaybeAdjOrTransMat{T}, x::StridedVector{S}) where {T<:BlasFloat,S<:Real} | 
|  | 54 | +    matmul_size_check(size(A), size(x)) | 
| 54 | 55 |     TS = promote_op(matprod, T, S) | 
| 55 | 56 |     y = isconcretetype(TS) ? convert(AbstractVector{TS}, x) : x | 
| 56 | 57 |     mul!(similar(x, TS, size(A,1)), A, y) | 
| 57 | 58 | end | 
| 58 | 59 | function (*)(A::AbstractMatrix{T}, x::AbstractVector{S}) where {T,S} | 
|  | 60 | +    matmul_size_check(size(A), size(x)) | 
| 59 | 61 |     TS = promote_op(matprod, T, S) | 
| 60 | 62 |     mul!(similar(x, TS, axes(A,1)), A, x) | 
| 61 | 63 | end | 
| @@ -113,7 +115,10 @@ julia> [1 1; 0 1] * [1 0; 1 1] | 
| 113 | 115 | """ | 
| 114 | 116 | (*)(A::AbstractMatrix, B::AbstractMatrix) = mul(A, B) | 
| 115 | 117 | # we add an extra level of indirection to avoid ambiguities in * | 
| 116 |  | -function mul(A::AbstractMatrix, B::AbstractMatrix) | 
|  | 118 | +# We also define the core functionality within _mul to reuse the code elsewhere | 
|  | 119 | +mul(A::AbstractMatrix, B::AbstractMatrix) = _mul(A, B) | 
|  | 120 | +function _mul(A::AbstractMatrix, B::AbstractMatrix) | 
|  | 121 | +    matmul_size_check(size(A), size(B)) | 
| 117 | 122 |     TS = promote_op(matprod, eltype(A), eltype(B)) | 
| 118 | 123 |     mul!(matprod_dest(A, B, TS), A, B) | 
| 119 | 124 | end | 
|  | 
0 commit comments