Skip to content

Commit

Permalink
Fix :slow matrix multiplication for previous Julia versions prior t…
Browse files Browse the repository at this point in the history
…o 1.11
  • Loading branch information
OlivierHnt committed Oct 22, 2024
1 parent d9dcd1e commit fa8cbd3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,19 @@ LinearAlgebra.mul!(C::AbstractVecOrMat{<:RealOrComplexI}, A::AbstractMatrix, B::
LinearAlgebra.mul!(C::AbstractVecOrMat{<:RealOrComplexI}, A::AbstractMatrix{<:RealOrComplexI}, B::AbstractVecOrMat, α::Number, β::Number) =
_mul!(matmul_mode(), C, A, B, α, β)

_mul!(::MatMulMode{:slow}, C, A, B, α, β) = LinearAlgebra._mul!(C, A, B, α, β)
function _mul!(::MatMulMode{:slow}, C, A::AbstractMatrix, B::AbstractVector, α, β)
@inbounds for l axes(A, 2), i axes(A, 1)
C[i] = A[i,l] * B[l] * α + C[i] * β
end
return C
end

function _mul!(::MatMulMode{:slow}, C, A::AbstractMatrix, B::AbstractMatrix, α, β)
@inbounds for j axes(B, 2), l axes(A, 2), i axes(A, 1)
C[i,j] = A[i,l] * B[l,j] * α + C[i,j] * β
end
return C
end

# fast matrix multiplication
# Note: Rump's algorithm
Expand Down

0 comments on commit fa8cbd3

Please sign in to comment.