I’m working on some by hand matrix multiplication.
function slowMult!(A::AbstractMatrix{T},B::AbstractMatrix{T}) where T<:Number
C = Matrix{T}(undef,size(A,1),size(B,2))
for i in 1:size(A,1)
for j in 1:size(B,2)
@inbounds @views C[i,j] = dot(A[i,:], B[:,j])
end
end
return C
end
This is obviously not going to be the fastest approach, but what’s really weird is that calling this function on 2 512
by 512
matrices is about 2x slower than on 514
by 514
matrices. The timing code is
T,N=Int,512
A = rand(T,N,N)
B = rand(T,N,N)
slowMult!(rand(T,1,1),rand(T,1,1)
C= @btime slowMult!($A,$B)